From 0773c1dad512d46f1bdeb88f6b44b0cd8d44fdb8 Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Wed, 2 Sep 2015 11:26:36 -0700 Subject: [PATCH] Vagrant updates for Fedora 22 Make more updates so that Fedora 22 is able to be managed in both the baseline as well as lf_network Vagrant definitions * This swaps out the lex-dnsmasq puppet module for saz-dnsmasq * This cleans up the puppet manifest to be puppet-lint safe * This cleans up the puppet manifest to be puppet 4 compatible as F22 has puppet 4 in the upstream * We throw away the "cloud-init-post" scripting that was originally being done on EL & Fedora systems as we have been using better techniques that do not require it Change-Id: Ib6c26dc09dc0a295e23882b3bc10060ea9abf9bf Signed-off-by: Andrew Grimberg --- vagrant/baseline/bootstrap.sh | 26 +++- vagrant/lf-networking/confignetwork.pp | 68 ++++++--- vagrant/lf-networking/configure_lf_infra.sh | 159 +------------------- 3 files changed, 70 insertions(+), 183 deletions(-) diff --git a/vagrant/baseline/bootstrap.sh b/vagrant/baseline/bootstrap.sh index 2eb7a3c6f..08f1e0273 100644 --- a/vagrant/baseline/bootstrap.sh +++ b/vagrant/baseline/bootstrap.sh @@ -31,7 +31,11 @@ rh_systems() { # add in components we need or want on systems echo "---> Installing base packages" - yum install -y -q @base unzip xz puppet git perl-XML-XPath + yum install -y -q @base + # separate group installs from package installs since a non-existing + # group with dnf based systems (F21+) will fail the install if such + # a group does not exist + yum install -y -q unzip xz puppet git perl-XML-XPath # All of our systems require Java (because of Jenkins) # Install all versions of the OpenJDK devel but force 1.7.0 to be the @@ -39,8 +43,24 @@ rh_systems() { echo "---> Configuring OpenJDK" yum install -y -q 'java-*-openjdk-devel' - alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java - alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64 + + FACTER_OS=`/usr/bin/facter operatingsystem` + FACTER_OSVER=`/usr/bin/facter operatingsystemrelease` + case "$FACTER_OS" in + Fedora) + if [ "$FACTER_OSVER" -ge "21" ] + then + echo "---> not modifying java alternatives as OpenJDK 1.7.0 does not exist" + else + alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java + alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64 + fi + ;; + *) + alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java + alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64 + ;; + esac } ubuntu_systems() { diff --git a/vagrant/lf-networking/confignetwork.pp b/vagrant/lf-networking/confignetwork.pp index a34975895..6e295e8ec 100644 --- a/vagrant/lf-networking/confignetwork.pp +++ b/vagrant/lf-networking/confignetwork.pp @@ -1,10 +1,15 @@ # make system modifications to handle being on a private Rackspace network +# lint:ignore:80chars +notice ("Operating system detected is: '${::operatingsystem} ${::operatingsystemrelease}'") +# lint:endignore +notice ("Subdomain being used is: '${::subdomain}'") + # configure nameservers for domains case $::subdomain { /^dfw\./: { - $NS1 = '72.3.128.241' - $NS2 = '72.3.128.240' + $ns1 = '72.3.128.241' + $ns2 = '72.3.128.240' case $::subdomain { /opendaylight/: { $router = '10.30.11.1' @@ -18,8 +23,8 @@ case $::subdomain { } } /^ord\./: { - $NS1 = '173.203.4.9' - $NS2 = '173.203.4.8' + $ns1 = '173.203.4.9' + $ns2 = '173.203.4.8' $router = '10.30.32.1' } default: { @@ -28,50 +33,63 @@ case $::subdomain { } # dnsmasq -class { 'dnsmasq': - domain => $::subdomain, - expand_hosts => true, - domain_needed => true, +class { 'dnsmasq': } + +# Setup dnsmasq special domain handlers +dnsmasq::conf { 'LF-ns1': + ensure => present, + content => 'server=/linux-foundation.org/172.17.192.30', +} + +dnsmasq::conf { 'LF-ns2': + ensure => present, + content => 'server=/linux-foundation.org/172.17.192.31', } -# can only have one NS per handled domain because of how -# the puppet module is built -dnsmasq::dnsserver { 'linux-foundation.org': - domain => 'linux-foundation.org', - ip => '172.17.192.30', +dnsmasq::conf { 'ODL-ns1': + ensure => present, + content => 'server=/opendaylight.org/172.17.192.30', } -dnsmasq::dnsserver { 'opendaylight.org': - domain => 'opendaylight.org', - ip => '172.17.192.30', +dnsmasq::conf { 'ODL-ns2': + ensure => present, + content => 'server=/opendaylight.org/172.17.192.31', } -dnsmasq::dnsserver { 'odlforge.org': - domain => 'odlforge.org', - ip => '172.17.192.30', +dnsmasq::conf { 'ODLForge-ns1': + ensure => present, + content => 'server=/odlforge.org/172.17.192.30', +} + +dnsmasq::conf { 'ODLForge-ns2': + ensure => present, + content => 'server=/odlforge.org/172.17.192.31', } # fix the resolver file { '/etc/resolv.conf': content => "search ${::subdomain} nameserver 127.0.0.1 -nameserver ${NS1} -nameserver ${NS2} +nameserver ${ns1} +nameserver ${ns2} options timeout:2 -" +", } # set routing case $::operatingsystem { 'CentOS', 'Fedora', 'RedHat': { file { '/etc/sysconfig/network-scripts/route-eth0': - content => "default via ${router} dev eth0" + content => "default via ${router} dev eth0", } } 'Ubuntu': { file { '/etc/network/if-up.d/0000routing': - content => "#!/bin/sh\nip route add default via ${router} dev eth0" - mode => '0755' + content => "#!/bin/sh\nip route add default via ${router} dev eth0", + mode => '0755', } } + default: { + notice ("${::operatingsystem} is not supported by this configuration") + } } diff --git a/vagrant/lf-networking/configure_lf_infra.sh b/vagrant/lf-networking/configure_lf_infra.sh index 5bc33d8c0..f515750a9 100644 --- a/vagrant/lf-networking/configure_lf_infra.sh +++ b/vagrant/lf-networking/configure_lf_infra.sh @@ -13,7 +13,8 @@ all_systems() { # install specific versions of puppet modules puppet module install puppetlabs-stdlib -v 4.5.1 puppet module install puppetlabs-concat -v 1.2.0 - puppet module install lex-dnsmasq -v 2.6.1 + #puppet module install lex-dnsmasq -v 2.6.1 + puppet module install saz-dnsmasq -v 1.2.0 # write the subdomain information into a custom facter fact mkdir -p /etc/facter/facts.d/ @@ -25,36 +26,17 @@ all_systems() { } rh_systems_init() { - # for some reason not all systems have @base installed - yum install -y -q @base - - # also make sure that a few other utilities are definitely installed - yum install -y -q unzip xz - - # install some needed internal networking configurations - yum install -y dnsmasq puppet - # remove current networking configurations - rm -f /etc/sysconfig/network-scripts/{ifcfg,route}-{eth,docker}* + rm -f /etc/sysconfig/network-scripts/ifcfg-{eth,docker}* } rh_systems_post() { # don't let cloud-init do funny things to our routing chattr +i /etc/sysconfig/network-scripts/route-eth0 - # setup the needed routing - cat <> /etc/rc.d/post-cloud-init -#!/bin/bash - -# always force puppet to rerun -/usr/bin/puppet apply /vagrant/confignetwork.pp -EOL - - chmod +x /etc/rc.d/post-cloud-init - # so that the network stack doesn't futz with our resolv config # after we've configured it - chattr +i /etc/resolv.conf +# chattr +i /etc/resolv.conf } ubuntu_systems_post() { @@ -63,121 +45,6 @@ ubuntu_systems_post() { echo "---> do nothing for now" } -systemd_init() { - # create a post-cloud-init.service and enable it - cat < /etc/systemd/system/post-cloud-init.service -[Unit] -Description=Post cloud-init script (overwrites some cloud-init config) -After=cloud-init-local.service -Requires=cloud-init-local.service - -[Service] -Type=oneshot -ExecStart=/etc/rc.d/post-cloud-init -TimeoutSec=0 -#RemainAfterExit=yes -#SysVStartPriority=99 - -# Output needs to appear in instance console output -StandardOutput=journal+console - -[Install] -WantedBy=multi-user.target -EOL - - /usr/bin/systemctl enable post-cloud-init.service - chattr +i /etc/systemd/system/post-cloud-init.service -} - -sysv_init() { - # create the SysV init and enable it - cat < /etc/init.d/post-cloud-init -#!/bin/bash - -### BEGIN INIT INFO -# Provides: post-cloud-init -# Required-Start: $local_fs $network $named $remote_fs cloud-init-local -# Should-Start: $time -# Required-Stop: -# Should-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Setup dnsmasq for LF Rackspace environment -# Description: Setup dnsmasq for LF Rackspace environment after -# cloud-init-local - -# Return values acc. to LSB for all commands but status: -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess argument(s) -# 3 - unimplemented feature (e.g. "reload") -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) -# -# Note that starting an already running service, stopping -# or restarting a not-running service as well as the restart -# with force-reload (in case signaling is not supported) are -# considered a success. - -RETVAL=0 - -prog="post-cloud-init" - -start() { - echo -n $"Starting $prog: " - /etc/rc.d/post-cloud-init - RETVAL=$? - return $RETVAL -} - -stop() { - echo -n $"Shutting down $prog:" - # No-op - RETVAL=7 - return $RETVAL -} - -case "$1" in - start) - start - RETVAL=$? - ;; - stop) - stop - RETVAL=$? - ;; - restart|try-restart|condrestart) - start - RETVAL=$? - ;; - status) - echo -n $"Checking for service $prog: " - # Return value is slightly different for the status command: - # 0 - service up and running - # 1 - service dead, but /var/run pid file exists - # 2 - service dead, but /var/lock file exists - # 3 - service not running (unused) - # 4 - service status unknown :-( - # 5--199 reserved (5-99 LSB, 100-149 distro, 150-199 appl.) - RETVAL=4 - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}" - RETVAL=3 - ;; -esac - -exit $RETVAL -EOL - chmod +x /etc/init.d/post-cloud-init - - /sbin/chkconfig --add post-cloud-init - /sbin/chkconfig post-cloud-init on -} - # Execute setup that all systems need all_systems @@ -187,24 +54,6 @@ FACTER_OS=`/usr/bin/facter operatingsystem` case "$FACTER_OSFAMILY" in RedHat) rh_systems_init - case "$FACTER_OS" in - Fedora) - echo "---> Fedora found" - systemd_init - ;; - RedHat|CentOS) - if [ `/usr/bin/facter operatingsystemrelease | /bin/cut -d '.' -f1` = "7" ]; then - echo "---> CentOS 7" - systemd_init - else - echo "---> CentOS 6" - sysv_init - fi - ;; - *) - echo "---> Unknown RH Family OS: ${FACTER_OS}" - ;; - esac rh_systems_post ;; Debian) -- 2.36.6