|
3 | 3 | require 'beaker/puppet_install_helper' |
4 | 4 | require 'beaker/module_install_helper' |
5 | 5 |
|
| 6 | +def install_bolt_on(hosts) |
| 7 | + on(hosts, "/opt/puppetlabs/puppet/bin/gem install --source http://rubygems.delivery.puppetlabs.net bolt -v '> 0.0.1'", acceptable_exit_codes: [0, 1]).stdout |
| 8 | +end |
| 9 | + |
| 10 | +def pe_install? |
| 11 | + ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i |
| 12 | +end |
| 13 | + |
| 14 | +def puppet_version |
| 15 | + (on default, puppet('--version')).output.chomp |
| 16 | +end |
| 17 | + |
6 | 18 | run_puppet_install_helper |
7 | 19 | install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i |
8 | 20 |
|
@@ -35,10 +47,48 @@ def module_dependencies_from_metadata |
35 | 47 | end |
36 | 48 | end |
37 | 49 |
|
| 50 | + |
| 51 | +install_bolt_on(hosts) unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i |
38 | 52 | install_module_on(hosts) |
39 | 53 | install_module_dependencies_on(hosts) |
40 | 54 | install_module_from_forge_on(hosts,'puppetlabs/apt','< 4.2.0') |
41 | 55 |
|
| 56 | +DEFAULT_PASSWORD = if default[:hypervisor] == 'vagrant' |
| 57 | + 'vagrant' |
| 58 | + elsif default[:hypervisor] == 'vcloud' |
| 59 | + 'Qu@lity!' |
| 60 | + end |
| 61 | + |
| 62 | +def run_puppet_access_login(user:, password: '~!@#$%^*-/ aZ', lifetime: '5y') |
| 63 | + on(master, puppet('access', 'login', '--username', user, '--lifetime', lifetime), stdin: password) |
| 64 | +end |
| 65 | + |
| 66 | +def pe_install? |
| 67 | + ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i |
| 68 | +end |
| 69 | + |
| 70 | +def run_task(task_name:, params: nil, password: DEFAULT_PASSWORD) |
| 71 | + if pe_install? |
| 72 | + run_puppet_task(task_name: task_name, params: params) |
| 73 | + else |
| 74 | + run_bolt_task(task_name: task_name, params: params, password: password) |
| 75 | + end |
| 76 | +end |
| 77 | + |
| 78 | +def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD) |
| 79 | + on(master, "/opt/puppetlabs/puppet/bin/bolt task run #{task_name} --modules /etc/puppetlabs/code/modules/service --nodes localhost --password #{password} #{params}", acceptable_exit_codes: [0, 1]).stdout # rubocop:disable Metrics/LineLength |
| 80 | +end |
| 81 | + |
| 82 | +def run_puppet_task(task_name:, params: nil) |
| 83 | + on(master, puppet('task', 'run', task_name, '--nodes', fact_on(master, 'fqdn'), params.to_s), acceptable_exit_codes: [0, 1]).stdout |
| 84 | +end |
| 85 | + |
| 86 | +def expect_multiple_regexes(result:, regexes:) |
| 87 | + regexes.each do |regex| |
| 88 | + expect(result).to match(regex) |
| 89 | + end |
| 90 | +end |
| 91 | + |
42 | 92 | class String |
43 | 93 | # Provide ability to remove indentation from strings, for the purpose of |
44 | 94 | # left justifying heredoc blocks. |
@@ -78,6 +128,7 @@ def psql(psql_cmd, user = 'postgres', exit_codes = [0,1], &block) |
78 | 128 |
|
79 | 129 | # Configure all nodes in nodeset |
80 | 130 | c.before :suite do |
| 131 | + run_puppet_access_login(user: 'admin') if pe_install? |
81 | 132 | # Set up selinux if appropriate. |
82 | 133 | if fact('osfamily') == 'RedHat' && fact('selinux') == 'true' |
83 | 134 | pp = <<-EOS |
|
0 commit comments