Skip to content

Commit

Permalink
Prevent cloud-init from overwriting /etc/hosts (#707)
Browse files Browse the repository at this point in the history
* Prevent cloud-init from overwriting /etc/hosts

Some cloud vendors attempt to overwrite /etc/hosts, which is managed by set-fqdn
and other NS8 actions. This commit prevents cloud-init from overwriting its
contents and losing NS8 settings.

* Disable the hostname update

The host name is controlled by action set-fqdn. Once NS8 is installed
only NS8 can manage it. Changing the hostname by other ways can lead to
inconsistent cluster setup.

Refs NethServer/dev#6993
  • Loading branch information
DavidePrincipi authored Sep 20, 2024
1 parent f8f32f5 commit 9380bb8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/imageroot/var/lib/nethserver/node/install-finalize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ if ! grep -q ' cluster-leader$' /etc/hosts; then
echo "127.0.0.1 cluster-localnode" >> /etc/hosts
fi

if [ -f /etc/cloud/cloud.cfg ]; then
echo "Remove update_etc_hosts cloud-init module:"
sed -i.orig -r '/-\s*update_etc_hosts/ d ; /-\s*update_hostname/ d' /etc/cloud/cloud.cfg || :
fi

echo "Generate WireGuard VPN key pair:"
(umask 0077; wg genkey | tee /etc/nethserver/wg0.key | wg pubkey) | tee /etc/nethserver/wg0.pub

Expand Down

0 comments on commit 9380bb8

Please sign in to comment.