Created
May 1, 2015 22:50
-
-
Save TJM/6fb2191f321ce92b4183 to your computer and use it in GitHub Desktop.
Foreman fix_hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# | |
kind: snippet | |
name: fix_hosts | |
%> | |
echo "<%= @host %>" > /etc/hostname | |
hostname <%= @host %> | |
# CentOS 7 (Fedora 19+?) uses hostnamectl | |
[ -x /usr/bin/hostnamectl ] && /usr/bin/hostnamectl set-hostname <%= @host %> | |
# Cloud Init Data needs to be told to leave the hostname alone. | |
[ -f /etc/cloud/cloud.cfg ] && echo 'preserve_hostname: true' >> /etc/cloud/cloud.cfg | |
cat > /etc/hosts << EOF | |
<%# simple snippet to generate /etc/hosts when provisioning image based systems -%> | |
127.0.0.1 <%= @host %> <%= @host.shortname %> localhost localhost.localdomain | |
::1 ip6-localhost ip6-loopback | |
fe00::0 ip6-localnet | |
ff00::0 ip6-mcastprefix | |
ff02::1 ip6-allnodes | |
ff02::2 ip6-allrouters | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment