spec_helper_acceptance.rb 3.72 KB
Newer Older
1 2
require 'beaker-rspec'
require 'beaker-puppet'
Scott Barthelemy's avatar
Scott Barthelemy committed
3 4 5 6 7
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'

run_puppet_install_helper
install_module_on(hosts)
8 9 10 11 12 13 14 15 16

# The module saz-resolv_conf, used by this helper, requires puppetlabs-stdlibs < 5.0.0.
# The puppet-freeipa dependencies descrived by metadata.json installs puppetlabs-stdlib > 5.0.0.
# It is prefered, for the moment, to not use the helping function
# install_module_dependencies_on() until saz-resolv_conf accepts puppetlabs-stdlib > 5.0.0
#
# By this way, users of puppet-freeipa can use puppetlabs-stdlibs version > 5.0.0.
# and acceptance tests can use puppetlabs-stdlibs version < 5.0.0
#install_module_dependencies_on(hosts)
Scott Barthelemy's avatar
Scott Barthelemy committed
17 18 19 20 21

RSpec.configure do |c|
  # Configure all nodes in nodeset
  c.before :suite do
    hosts.each do |host|
22 23 24
      install_module_from_forge_on(host, 'saz-resolv_conf', '>= 4.0.0 < 5.0.0')
      install_module_from_forge_on(host, 'puppetlabs-stdlib', '>= 4.25.0 < 5.0.0')
      install_module_from_forge_on(host, 'stahnma-epel', '>= 1.3.1 < 2.0.0')
25

26 27 28 29
      pp = <<-EOS
        exec { 'stop network manager':
          command => 'systemctl stop NetworkManager',
          onlyif  => 'systemctl status NetworkManager',
30
          path    => '/usr/bin:/sbin:/bin',
31
        }
Fabien Combernous's avatar
Fabien Combernous committed
32 33 34 35 36
      EOS

      apply_manifest_on(host, pp, catch_failures: true)

      yumipv4 = <<-EOS
37 38 39
        exec {'echo "ip_resolve=4" >> /etc/yum.conf':
          onlyif => 'grep -v "^ip_resolve=4" /etc/yum.conf',
          path   => '/usr/bin:/sbin:/bin',
40 41
        }
      EOS
Fabien Combernous's avatar
Fabien Combernous committed
42
      apply_manifest_on(host, yumipv4, catch_failures: true) if fact('os.family') == 'RedHat'
43

44
    end
45

46 47
    ## Preconfigure master
    hosts_as('master').each do |master|
Scott Barthelemy's avatar
Scott Barthelemy committed
48
      pp = <<-EOS
49 50 51 52 53
        exec { 'set master /etc/hosts':
          path     => '/bin/',
          command  => 'echo -e "127.0.0.1       ipa-server-1.vagrant.example.lan ipa-server-1\n ::1     ip6-localhost ip6-loopback\n fe00::0 ip6-localnet\n ff00::0 ip6-mcastprefix\n ff02::1 ip6-allnodes\n ff02::2 ip6-allrouters\n\n 192.168.44.35 ipa-server-1.vagrant.example.lan ipa-server-1\n" > /etc/hosts',
        }
        EOS
Scott Barthelemy's avatar
Scott Barthelemy committed
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
      apply_manifest_on(master, pp, catch_failures: true, debug: true)
    end

    ## Preconfigure replica
    hosts_as('replica').each do |replica|
      pp = <<-EOS
         exec { 'set replica /etc/hosts':
           path     => '/bin/',
           command  => 'echo -e "127.0.0.1       ipa-server-2.vagrant.example.lan ipa-server-2\n ::1     ip6-localhost ip6-loopback\n fe00::0 ip6-localnet\n ff00::0 ip6-mcastprefix\n ff02::1 ip6-allnodes\n ff02::2 ip6-allrouters\n\n 192.168.44.36 ipa-server-2.vagrant.example.lan ipa-server-2\n" > /etc/hosts',
         }
         class { 'resolv_conf':
           nameservers => ['192.168.44.35'],
         }
         host {'ipa-server-1.vagrant.example.lan':
           ensure => present,
           ip => '192.168.44.35',
         }
72
      EOS
73 74

      apply_manifest_on(replica, pp, :catch_failures => true, :debug => true)
Scott Barthelemy's avatar
Scott Barthelemy committed
75
    end
76 77 78 79 80 81 82 83

    ## Preconfigure client
    hosts_as('centos7').each do |centos7|
      pp = <<-EOS
        exec { 'set client centos /etc/hosts':
          path     => '/bin/',
          command  => 'echo -e "127.0.0.1       ipa-client-centos.vagrant.example.lan ipa-server-2\n ::1     ip6-localhost ip6-loopback\n fe00::0 ip6-localnet\n ff00::0 ip6-mcastprefix\n ff02::1 ip6-allnodes\n ff02::2 ip6-allrouters\n\n 192.168.44.37 ipa-client-centos.vagrant.example.lan ipa-client-centos\n" > /etc/hosts',
        }
84 85 86 87 88 89 90 91
        class { 'resolv_conf':
          nameservers => ['192.168.44.35'],
        }
        host {'ipa-server-1.vagrant.example.lan':
          ensure => present,
          ip => '192.168.44.35',
        }
      EOS
92 93 94

      apply_manifest_on(centos7, pp, catch_failures: true)
    end
Scott Barthelemy's avatar
Scott Barthelemy committed
95
  end
Scott Barthelemy's avatar
Scott Barthelemy committed
96
end