9 # Don't do anything if the file isn't there
10 if [ ! -f "$file" ]; then
14 if grep -q "^# HEAT_HOSTS_START" "$file"; then
16 awk -v v="$entries" '/^# HEAT_HOSTS_START/ {
20 }f &&!/^# HEAT_HOSTS_END$/{next}/^# HEAT_HOSTS_END$/{f=0}!f' "$file" > "$temp"
21 echo "INFO: Updating hosts file $file, check below for changes"
22 diff "$file" "$temp" || true
25 echo -ne "\n# HEAT_HOSTS_START - Do not edit manually within this section!\n" >> "$file"
26 echo "$entries" >> "$file"
27 echo -ne "# HEAT_HOSTS_END\n\n" >> "$file"
32 if [ ! -z "$hosts" ]; then
33 # cloud-init files are /etc/cloud/templates/hosts.OSNAME.tmpl
34 DIST=$(lsb_release -is | tr -s [A-Z] [a-z])
36 fedora|redhatenterpriseserver)
43 write_entries "/etc/cloud/templates/hosts.${name}.tmpl" "$hosts"
44 write_entries "/etc/hosts" "$hosts"
46 echo "No hosts in Heat, nothing written."