diskimage-builder/diskimage_builder/elements/base/install.d/10-cloud-init

18 lines
368 B
Text
Raw Normal View History

#!/bin/bash
# Tweak the stock ubuntu cloud-init config
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# cloud-init May not actually be installed
mkdir -p /etc/cloud/cloud.cfg.d
Make managing hosts entries optional Diskimage-builder currently writes cloud-init config file which adds a host entry mapping the hostname and FQDN to 127.0.0.1 into every image built. This is probably useful for some use cases but not for all, so we now allow customizing the manage_etc_hosts value via DIB_CLOUD_INIT_ETC_HOSTS variable and also not writing the config at all if that variable is explicitly set to an empty string (currently the default is 'localhost' but in the future the default will be empty string). Particular description of the problem this causes in TripleO follows: We get hosts files like this: ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 127.0.0.1 ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z.novalocal ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z # HEAT_HOSTS_START - Do not edit manually within this section! 192.0.2.17 ov-rl5i5saoc6h-0-wfzcsrqo34p6-controller-m3hy26lhxavl ov-rl5i5saoc6h-0-wfzcsrqo34p6-controller-m3hy26lhxavl.novalocal 192.0.2.15 ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z.novalocal 192.0.2.16 ov-rl5i5saoc6h-2-a6v7saxnivm5-controller-7jboskte34r7 ov-rl5i5saoc6h-2-a6v7saxnivm5-controller-7jboskte34r7.novalocal # HEAT_HOSTS_END The duplicate hostname/FQDN entry for 127.0.0.1 and 192.0.2.15 confuses Corosync, which then fails to start a cluster when using hostnames in the config file instead of IPs. Change-Id: Ia8582883f737548e2911d3f36a1943e5b236281b Partial-Bug: #1447497
2015-04-24 11:32:36 +00:00
if [ -n "${DIB_CLOUD_INIT_ETC_HOSTS:-}" ]; then
Make managing hosts entries optional Diskimage-builder currently writes cloud-init config file which adds a host entry mapping the hostname and FQDN to 127.0.0.1 into every image built. This is probably useful for some use cases but not for all, so we now allow customizing the manage_etc_hosts value via DIB_CLOUD_INIT_ETC_HOSTS variable and also not writing the config at all if that variable is explicitly set to an empty string (currently the default is 'localhost' but in the future the default will be empty string). Particular description of the problem this causes in TripleO follows: We get hosts files like this: ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 127.0.0.1 ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z.novalocal ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z # HEAT_HOSTS_START - Do not edit manually within this section! 192.0.2.17 ov-rl5i5saoc6h-0-wfzcsrqo34p6-controller-m3hy26lhxavl ov-rl5i5saoc6h-0-wfzcsrqo34p6-controller-m3hy26lhxavl.novalocal 192.0.2.15 ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z.novalocal 192.0.2.16 ov-rl5i5saoc6h-2-a6v7saxnivm5-controller-7jboskte34r7 ov-rl5i5saoc6h-2-a6v7saxnivm5-controller-7jboskte34r7.novalocal # HEAT_HOSTS_END The duplicate hostname/FQDN entry for 127.0.0.1 and 192.0.2.15 confuses Corosync, which then fails to start a cluster when using hostnames in the config file instead of IPs. Change-Id: Ia8582883f737548e2911d3f36a1943e5b236281b Partial-Bug: #1447497
2015-04-24 11:32:36 +00:00
dd of=/etc/cloud/cloud.cfg.d/10_etc_hosts.cfg << EOF
manage_etc_hosts: $DIB_CLOUD_INIT_ETC_HOSTS
EOF
Make managing hosts entries optional Diskimage-builder currently writes cloud-init config file which adds a host entry mapping the hostname and FQDN to 127.0.0.1 into every image built. This is probably useful for some use cases but not for all, so we now allow customizing the manage_etc_hosts value via DIB_CLOUD_INIT_ETC_HOSTS variable and also not writing the config at all if that variable is explicitly set to an empty string (currently the default is 'localhost' but in the future the default will be empty string). Particular description of the problem this causes in TripleO follows: We get hosts files like this: ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 127.0.0.1 ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z.novalocal ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z # HEAT_HOSTS_START - Do not edit manually within this section! 192.0.2.17 ov-rl5i5saoc6h-0-wfzcsrqo34p6-controller-m3hy26lhxavl ov-rl5i5saoc6h-0-wfzcsrqo34p6-controller-m3hy26lhxavl.novalocal 192.0.2.15 ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z ov-rl5i5saoc6h-1-hj5tzsbrdv4c-controller-dy6nuyarqy5z.novalocal 192.0.2.16 ov-rl5i5saoc6h-2-a6v7saxnivm5-controller-7jboskte34r7 ov-rl5i5saoc6h-2-a6v7saxnivm5-controller-7jboskte34r7.novalocal # HEAT_HOSTS_END The duplicate hostname/FQDN entry for 127.0.0.1 and 192.0.2.15 confuses Corosync, which then fails to start a cluster when using hostnames in the config file instead of IPs. Change-Id: Ia8582883f737548e2911d3f36a1943e5b236281b Partial-Bug: #1447497
2015-04-24 11:32:36 +00:00
fi