diff --git a/files/gateway/midonet-static-uplink.service b/files/gateway/midonet-static-uplink.service new file mode 100644 index 0000000..abf7acf --- /dev/null +++ b/files/gateway/midonet-static-uplink.service @@ -0,0 +1,11 @@ +[Unit] +Description=Enables and configures the fake MidoNet static uplink interfaces +After=network.target + +[Service] +Type=simple +ExecStart=/usr/local/sbin/create_fake_uplink_l2.sh +TimeoutStartSec=0 + +[Install] +WantedBy=default.target diff --git a/manifests/gateway/static.pp b/manifests/gateway/static.pp index 9253301..e356d63 100644 --- a/manifests/gateway/static.pp +++ b/manifests/gateway/static.pp @@ -99,16 +99,34 @@ class midonet::gateway::static ( # Place script and helper files before executing it file { 'fake_uplink_script': ensure => $ensure_scripts, - path => "${scripts_dir}/create_fake_uplink_l2.sh", + path => "${scripts_dir}/${uplink_script}", content => template('midonet/gateway/create_fake_uplink_l2.sh.erb'), } # Finally, execute the script exec { 'run gateway static creation script': - command => "/bin/bash -x ${scripts_dir}/create_fake_uplink_l2.sh 2>&1 | tee /tmp/bash.out", + command => "/bin/bash -x ${scripts_dir}/${uplink_script} 2>&1 | tee ${scripts_dir}/${uplink_script}.out", returns => ['0', '7'], require => [ File['fake_uplink_script'], ] } + + # Ensure interfaces are configured and enabled at boot time + # (for the time being this is RHEL 7.x only) + if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '7' { + file { 'fake_uplink_script-STARTUP': + ensure => $ensure_scripts, + mode => '0775', + path => '/usr/local/sbin/create_fake_uplink_l2.sh', + content => template('midonet/gateway/create_fake_uplink_l2.sh.erb'), + } -> + file { 'fake_uplink_script-SERVICEFILE': + ensure => $ensure_scripts, + mode => '0644', + path => '/etc/systemd/system/midonet-static-uplink.service', + source => 'puppet:///modules/midonet/gateway/midonet-static-uplink.service', + } -> + service { 'midonet-static-uplink': enable => true } + } } diff --git a/spec/classes/midonet_gateway_static_spec.rb b/spec/classes/midonet_gateway_static_spec.rb index a70521b..945e188 100644 --- a/spec/classes/midonet_gateway_static_spec.rb +++ b/spec/classes/midonet_gateway_static_spec.rb @@ -25,7 +25,7 @@ describe 'midonet::gateway::static' do end it { is_expected.to contain_file('fake_uplink_script').with_ensure('present') } it { is_expected.to contain_exec('run gateway static creation script').with( - 'command' => '/bin/bash -x /tmp/create_fake_uplink_l2.sh 2>&1 | tee /tmp/bash.out' + 'command' => '/bin/bash -x /tmp/create_fake_uplink_l2.sh 2>&1 | tee /tmp/create_fake_uplink_l2.sh.out' ) } end end