3 # script requires information about subdomain
5 >&2 echo "Please provide the subdomain to Vagrant"
13 # install specific versions of puppet modules
14 puppet module install puppetlabs-stdlib -v 4.5.1
15 puppet module install puppetlabs-concat -v 1.2.0
16 puppet module install lex-dnsmasq -v 2.6.1
18 # write the subdomain information into a custom facter fact
19 mkdir -p /etc/facter/facts.d/
20 echo "subdomain=${SUBDOM}" > /etc/facter/facts.d/subdomain.txt
23 puppet apply /vagrant/confignetwork.pp
28 # for some reason not all systems have @base installed
29 yum install -y -q @base
31 # also make sure that a few other utilities are definitely installed
32 yum install -y -q unzip xz
34 # install some needed internal networking configurations
35 yum install -y dnsmasq puppet
37 # remove current networking configurations
38 rm -f /etc/sysconfig/network-scripts/{ifcfg,route}-{eth,docker}*
42 # don't let cloud-init do funny things to our routing
43 chattr +i /etc/sysconfig/network-scripts/route-eth0
45 # setup the needed routing
46 cat <<EOL >> /etc/rc.d/post-cloud-init
49 # always force puppet to rerun
50 /usr/bin/puppet apply /vagrant/confignetwork.pp
53 chmod +x /etc/rc.d/post-cloud-init
55 # so that the network stack doesn't futz with our resolv config
56 # after we've configured it
57 chattr +i /etc/resolv.conf
60 ubuntu_systems_post() {
61 # don't let cloud-init destroy our routing
62 # chattr +i /etc/network/if-up.d/0000routing
63 echo "---> do nothing for now"
67 # create a post-cloud-init.service and enable it
68 cat <<EOL > /etc/systemd/system/post-cloud-init.service
70 Description=Post cloud-init script (overwrites some cloud-init config)
71 After=cloud-init-local.service
72 Requires=cloud-init-local.service
76 ExecStart=/etc/rc.d/post-cloud-init
81 # Output needs to appear in instance console output
82 StandardOutput=journal+console
85 WantedBy=multi-user.target
88 /usr/bin/systemctl enable post-cloud-init.service
89 chattr +i /etc/systemd/system/post-cloud-init.service
93 # create the SysV init and enable it
94 cat <<EOL > /etc/init.d/post-cloud-init
98 # Provides: post-cloud-init
99 # Required-Start: $local_fs $network $named $remote_fs cloud-init-local
100 # Should-Start: $time
103 # Default-Start: 2 3 4 5
104 # Default-Stop: 0 1 6
105 # Short-Description: Setup dnsmasq for LF Rackspace environment
106 # Description: Setup dnsmasq for LF Rackspace environment after
109 # Return values acc. to LSB for all commands but status:
111 # 1 - generic or unspecified error
112 # 2 - invalid or excess argument(s)
113 # 3 - unimplemented feature (e.g. "reload")
114 # 4 - user had insufficient privileges
115 # 5 - program is not installed
116 # 6 - program is not configured
117 # 7 - program is not running
118 # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
120 # Note that starting an already running service, stopping
121 # or restarting a not-running service as well as the restart
122 # with force-reload (in case signaling is not supported) are
123 # considered a success.
127 prog="post-cloud-init"
130 echo -n $"Starting $prog: "
131 /etc/rc.d/post-cloud-init
137 echo -n $"Shutting down $prog:"
152 restart|try-restart|condrestart)
157 echo -n $"Checking for service $prog: "
158 # Return value is slightly different for the status command:
159 # 0 - service up and running
160 # 1 - service dead, but /var/run pid file exists
161 # 2 - service dead, but /var/lock file exists
162 # 3 - service not running (unused)
163 # 4 - service status unknown :-(
164 # 5--199 reserved (5-99 LSB, 100-149 distro, 150-199 appl.)
168 echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
175 chmod +x /etc/init.d/post-cloud-init
177 /sbin/chkconfig --add post-cloud-init
178 /sbin/chkconfig post-cloud-init on
181 # Execute setup that all systems need
184 echo "---> Checking distribution"
185 FACTER_OSFAMILY=`/usr/bin/facter osfamily`
186 FACTER_OS=`/usr/bin/facter operatingsystem`
187 case "$FACTER_OSFAMILY" in
192 echo "---> Fedora found"
196 if [ `/usr/bin/facter operatingsystemrelease | /bin/cut -d '.' -f1` = "7" ]; then
205 echo "---> Unknown RH Family OS: ${FACTER_OS}"
213 echo "---> Ubuntu found"
217 "---> Nothing to do for ${FACTER_OS}"
222 echo "---> Unknown OS: ${FACTER_OSFAMILY}"
226 # vim: sw=4 ts=4 sts=4 et :