Use new verify job type with new freestyle project
[releng/builder.git] / vagrant / lib / lf-networking / configure_lf_infra.sh
1 #!/bin/bash
2
3 # script requires information about subdomain
4 if [ -z "$1" ]; then
5     >&2 echo "Please provide the subdomain to Vagrant"
6     exit 1
7 else
8     SUBDOM=$1
9 fi
10
11
12 all_systems() {
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
17     puppet module install saz-dnsmasq -v 1.2.0
18
19     # write the subdomain information into a custom facter fact
20     mkdir -p /etc/facter/facts.d/
21     echo "subdomain=${SUBDOM}" > /etc/facter/facts.d/subdomain.txt
22
23     # final bits
24     puppet apply /vagrant/lib/lf-networking/confignetwork.pp
25
26 }
27
28 rh_systems_init() {
29     # remove current networking configurations
30     rm -f /etc/sysconfig/network-scripts/ifcfg-eth*
31 }
32
33 rh_systems_post() {
34     # don't let cloud-init do funny things to our routing
35     chattr +i /etc/sysconfig/network-scripts/route-eth0
36
37     # so that the network stack doesn't futz with our resolv config
38     # after we've configured it
39 #    chattr +i /etc/resolv.conf
40 }
41
42 ubuntu_systems_post() {
43     # don't let cloud-init destroy our routing
44 #    chattr +i /etc/network/if-up.d/0000routing
45     echo "---> do nothing for now"
46 }
47
48 # Execute setup that all systems need
49 all_systems
50
51 echo "---> Checking distribution"
52 FACTER_OSFAMILY=`/usr/bin/facter osfamily`
53 FACTER_OS=`/usr/bin/facter operatingsystem`
54 case "$FACTER_OSFAMILY" in
55     RedHat)
56         rh_systems_init
57         rh_systems_post
58     ;;
59     Debian)
60         case "$FACTER_OS" in
61             Ubuntu)
62                 echo "---> Ubuntu found"
63                 ubuntu_systems_post
64             ;;
65             *)
66                 "---> Nothing to do for ${FACTER_OS}"
67             ;;
68         esac
69     ;;
70     *)
71         echo "---> Unknown OS: ${FACTER_OSFAMILY}"
72     ;;
73 esac
74
75 # vim: sw=4 ts=4 sts=4 et :