3 # for some reason not all systems have @base installed
4 yum install -y -q @base
6 # also make sure that a few other utilities are definitely installed
7 yum install -y -q unzip xz
9 # install some needed internal networking configurations
10 yum install -y dnsmasq puppet
12 # install specific versions of puppet modules
13 puppet module install puppetlabs-stdlib -v 4.5.1
14 puppet module install puppetlabs-concat -v 1.2.0
15 puppet module install lex-dnsmasq -v 2.6.1
17 # script requires information about subdomain
19 >&2 echo "Please provide the subdomain to Vagrant"
23 # write the subdomain information into a custom facter fact
24 mkdir -p /etc/facter/facts.d/
25 echo "subdomain=${1}" > /etc/facter/facts.d/subdomain.txt
27 # remove current networking configurations
28 rm -f /etc/sysconfig/network-scripts/{ifcfg,route}-{eth,docker}*
31 puppet apply /vagrant/confignetwork.pp
33 # so that cloud-init doesn't futz with our resolv config after we've
35 chattr +i /etc/resolv.conf
37 # don't let cloud-init do funny things to our routing
38 chattr +i /etc/sysconfig/network-scripts/route-eth0
40 # setup the needed routing
41 cat <<EOL >> /etc/rc.d/post-cloud-init
44 # always force puppet to rerun
45 /usr/bin/puppet apply /vagrant/confignetwork.pp
48 chmod +x /etc/rc.d/post-cloud-init
51 # create a post-cloud-init.service and enable it
52 cat <<EOL > /etc/systemd/system/post-cloud-init.service
54 Description=Post cloud-init script (overwrites some cloud-init config)
55 After=cloud-init-local.service
56 Requires=cloud-init-local.service
60 ExecStart=/etc/rc.d/post-cloud-init
65 # Output needs to appear in instance console output
66 StandardOutput=journal+console
69 WantedBy=multi-user.target
72 /usr/bin/systemctl enable post-cloud-init.service
73 chattr +i /etc/systemd/system/post-cloud-init.service
77 # create the SysV init and enable it
78 cat <<EOL > /etc/init.d/post-cloud-init
82 # Provides: post-cloud-init
83 # Required-Start: $local_fs $network $named $remote_fs cloud-init-local
87 # Default-Start: 2 3 4 5
89 # Short-Description: Setup dnsmasq for LF Rackspace environment
90 # Description: Setup dnsmasq for LF Rackspace environment after
93 # Return values acc. to LSB for all commands but status:
95 # 1 - generic or unspecified error
96 # 2 - invalid or excess argument(s)
97 # 3 - unimplemented feature (e.g. "reload")
98 # 4 - user had insufficient privileges
99 # 5 - program is not installed
100 # 6 - program is not configured
101 # 7 - program is not running
102 # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
104 # Note that starting an already running service, stopping
105 # or restarting a not-running service as well as the restart
106 # with force-reload (in case signaling is not supported) are
107 # considered a success.
111 prog="post-cloud-init"
114 echo -n $"Starting $prog: "
115 /etc/rc.d/post-cloud-init
121 echo -n $"Shutting down $prog:"
136 restart|try-restart|condrestart)
141 echo -n $"Checking for service $prog: "
142 # Return value is slightly different for the status command:
143 # 0 - service up and running
144 # 1 - service dead, but /var/run pid file exists
145 # 2 - service dead, but /var/lock file exists
146 # 3 - service not running (unused)
147 # 4 - service status unknown :-(
148 # 5--199 reserved (5-99 LSB, 100-149 distro, 150-199 appl.)
152 echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
159 chmod +x /etc/init.d/post-cloud-init
161 /sbin/chkconfig --add post-cloud-init
162 /sbin/chkconfig post-cloud-init on
165 echo "Checking distribution"
166 if [ `/usr/bin/facter operatingsystem` = "Fedora" ]; then
167 echo "---> Fedora found"
170 if [ `/usr/bin/facter operatingsystemrelease | /bin/cut -d '.' -f1` = "7" ]; then
179 # vim: sw=4 ts=4 sts=4 et :