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 puppet module install lex-dnsmasq
14 # script requires information about subdomain
16 >&2 echo "Please provide the subdomain to Vagrant"
20 # write the subdomain information into a custom facter fact
21 mkdir -p /etc/facter/facts.d/
22 echo "subdomain=${1}" > /etc/facter/facts.d/subdomain.txt
24 # remove current networking configurations
25 rm -f /etc/sysconfig/network-scripts/{ifcfg,route}-{eth,docker}*
28 puppet apply /vagrant/confignetwork.pp
30 # so that cloud-init doesn't futz with our resolv config after we've
32 chattr +i /etc/resolv.conf
34 # don't let cloud-init do funny things to our routing
35 chattr +i /etc/sysconfig/network-scripts/route-eth0
37 # create a docker bridge that doesn't trample our networks
38 # but only if docker is installed
39 DOCKER=`rpm -q docker-io`
40 if [ "$?" == "0" ]; then
41 echo "---> Docker installed, configuring docker bridge"
42 # fully overwrite the default, otherwise we end up with the options
43 # split over two lines which will fail
44 # Default: OPTIONS=--selinux-enabled
45 echo 'OPTIONS=--selinux-enabled --bip=10.250.0.254/24' > /etc/sysconfig/docker
46 # cat <<EOL > /etc/sysconfig/network-scripts/ifcfg-docker0
52 #NETMASK=255.255.255.0
55 # # don't let cloud-init do funny things to our docker bridge
56 # chattr +i /etc/sysconfig/network-scripts/ifcfg-docker0
57 cat /etc/sysconfig/docker
61 # setup the needed routing
62 cat <<EOL >> /etc/rc.d/post-cloud-init
65 # always force puppet to rerun
66 /usr/bin/puppet apply /vagrant/confignetwork.pp
69 chmod +x /etc/rc.d/post-cloud-init
72 # create a post-cloud-init.service and enable it
73 cat <<EOL > /etc/systemd/system/post-cloud-init.service
75 Description=Post cloud-init script (overwrites some cloud-init config)
76 After=cloud-init-local.service
77 Requires=cloud-init-local.service
81 ExecStart=/etc/rc.d/post-cloud-init
86 # Output needs to appear in instance console output
87 StandardOutput=journal+console
90 WantedBy=multi-user.target
93 /usr/bin/systemctl enable post-cloud-init.service
94 chattr +i /etc/systemd/system/post-cloud-init.service
98 # create the SysV init and enable it
99 cat <<EOL > /etc/init.d/post-cloud-init
103 # Provides: post-cloud-init
104 # Required-Start: $local_fs $network $named $remote_fs cloud-init-local
105 # Should-Start: $time
108 # Default-Start: 2 3 4 5
109 # Default-Stop: 0 1 6
110 # Short-Description: Setup dnsmasq for LF Rackspace environment
111 # Description: Setup dnsmasq for LF Rackspace environment after
114 # Return values acc. to LSB for all commands but status:
116 # 1 - generic or unspecified error
117 # 2 - invalid or excess argument(s)
118 # 3 - unimplemented feature (e.g. "reload")
119 # 4 - user had insufficient privileges
120 # 5 - program is not installed
121 # 6 - program is not configured
122 # 7 - program is not running
123 # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
125 # Note that starting an already running service, stopping
126 # or restarting a not-running service as well as the restart
127 # with force-reload (in case signaling is not supported) are
128 # considered a success.
132 prog="post-cloud-init"
135 echo -n $"Starting $prog: "
136 /etc/rc.d/post-cloud-init
142 echo -n $"Shutting down $prog:"
157 restart|try-restart|condrestart)
162 echo -n $"Checking for service $prog: "
163 # Return value is slightly different for the status command:
164 # 0 - service up and running
165 # 1 - service dead, but /var/run pid file exists
166 # 2 - service dead, but /var/lock file exists
167 # 3 - service not running (unused)
168 # 4 - service status unknown :-(
169 # 5--199 reserved (5-99 LSB, 100-149 distro, 150-199 appl.)
173 echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
180 chmod +x /etc/init.d/post-cloud-init
182 /sbin/chkconfig --add post-cloud-init
183 /sbin/chkconfig post-cloud-init on
186 echo "Checking distribution"
187 if [ `/usr/bin/facter operatingsystem` = "Fedora" ]; then
188 echo "---> Fedora found"
191 if [ `/usr/bin/facter operatingsystemrelease | /bin/cut -d '.' -f1` = "7" ]; then
200 # vim: sw=4 ts=4 sts=4 et :