Skip to content

Commit 1c425ba

Browse files
Clean Resolv.conf in official AMI build
1. Only cleanup resolv conf during official AMI build. In the future, we will evaluate to apply this improvement to all AMI builds. 2. Also clean up `/run/systemd/resolve/resolv.conf `. This file exists on Ubuntu Signed-off-by: Hanwen <[email protected]>
1 parent 17a93ba commit 1c425ba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cookbooks/aws-parallelcluster-platform/files/ami_cleanup.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
IS_OFFICIAL_AMI_BUILD=${1:-"false"}
4+
35
# clean up cloud init artifacts https://cloudinit.readthedocs.io/en/latest/topics/cli.html#clean
46
cloud-init clean -s
57

@@ -21,8 +23,10 @@ if [ "${ID}${VERSION_ID}" == "centos7" ]; then
2123
fi
2224

2325
# Clean resolv.conf if it's not managed by system
24-
if [ ! -L "/etc/resolv.conf" ]; then
25-
sed -i '/^nameserver/d' /etc/resolv.conf
26+
if [ "${IS_OFFICIAL_AMI_BUILD}" == "true" ]; then
27+
echo "Clean resolv.conf for official AMIs"
28+
echo -n > /etc/resolv.conf
29+
rm -f /run/systemd/resolve/resolv.conf
2630
fi
2731

2832
find /var/log -type f -exec /bin/rm -v {} \;

0 commit comments

Comments
 (0)