beaker 3.6.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmVmMDI1YTVjZDNjZmM4ODI2MGUzOTBiNDg2YmVlMDMwZGQyY2M2Mg==
4
+ MmUyMTFlZTE2NmY5N2U0NTEzNzc1ZDVmNjBjYzY1OWI5NWRmOTc5Yg==
5
5
  data.tar.gz: !binary |-
6
- OWExZDNiOGU2NmRkNGJjYTM3MjlhZGRlODk3M2NiYzBjYTE3NmZkZA==
6
+ NjllMDQyODRjZjM2YTZiM2ZiMmM5ZTc4NWJkZTliNjliMGI4ZmU0Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmRmNjhhMWYzZTEzZTk3ZDRiNTEzMzkwYjE3NzBmZDgzOGQzY2I0NTI4OGUy
10
- ZjNmN2ZhNjM5ZDI0ZDY3YTRjOGJhMWRmMjViZWM3YzY0Y2QzNTE4ZjIxYzI4
11
- NTQ1ZjU4YzVhMjAwMjUxMjY1Y2VlZmFmZDUzMjU1MGNiZGIwYzY=
9
+ NGNiNTg1MWQzZTIwNmNhMGQwNmNmMzlkNWRlNjU5OTRlMzBmMmYzMGRkMDkz
10
+ NDMzZTRmNzk1ZTdhMmVhZTg5ODIwOTg4NmMwZTJlZDUyOTMxNDcwZmE3MjJi
11
+ YWU1NzVhMjRlZDA3ZTcwYTdkMDJhYTBmM2UzNGI5NjBjODY3ZjM=
12
12
  data.tar.gz: !binary |-
13
- YjA4NjRjYjVjMzEyMzg1ZTk2YWEwMDdhYzU1NTU2NjdlZjY1ZjNlN2EwMzc3
14
- MWJlMzE4MGQ5Mzc1N2QxZDQ3YjU0M2U5Nzk3MjE1YWI5YWZhMmE4MzA5MjI2
15
- ZjhlYTJjNGRiMTc4YTQzOTlmOTE4N2NhYTQwMjFjNzUxMDQwMGE=
13
+ OGVjNmEzMjQ0OWYwM2M0NDk2NWEzY2Q4N2ZhMGUxNmYxOGNhNGVjMmYyYTdj
14
+ Nzg4ZGFjZmRiMTIzYTZlYjVlZmY2ZTdkNTU4NjM2Yjk3Zjc4OTQ0ZTc0YTdl
15
+ NWUwYjc0NTZhNTg4NTdkZTMyNmQ4ZmJlMThmODFhNmIwYWQ3OWM=
data/beaker.gemspec CHANGED
@@ -33,9 +33,6 @@ Gem::Specification.new do |s|
33
33
  # Run time dependencies
34
34
  s.add_runtime_dependency 'minitest', '~> 5.4'
35
35
  s.add_runtime_dependency 'minitar', '~> 0.5.4'
36
- s.add_runtime_dependency 'json', '~> 1.8'
37
- ## json: will stay <2.0 while aws-sdk-v1 is in use
38
- ## aws-sdk-2 doesn't require json, so we can give this up when we move
39
36
 
40
37
  s.add_runtime_dependency 'hocon', '~> 1.0'
41
38
  s.add_runtime_dependency 'net-ssh', '3.3.0.beta1'
@@ -53,6 +50,7 @@ Gem::Specification.new do |s|
53
50
  # Run time dependencies that are Beaker libraries
54
51
  s.add_runtime_dependency 'stringify-hash', '~> 0.0'
55
52
  s.add_runtime_dependency 'beaker-hiera', '~> 0.0'
53
+ s.add_runtime_dependency 'beaker-facter', '~> 0.0'
56
54
  s.add_runtime_dependency 'beaker-hostgenerator'
57
55
 
58
56
  # Optional provisioner specific support
@@ -0,0 +1,43 @@
1
+ # Arch Linux
2
+
3
+ > Arch Linux is an independently developed, i686/x86-64 general-purpose GNU/Linux distribution that strives to provide the latest stable versions of most software by following a rolling-release model. The default installation is a minimal base system, configured by the user to only add what is purposely required.
4
+ **Source: https://wiki.archlinux.org/index.php/Arch_Linux**
5
+
6
+ # Installation
7
+
8
+ ## Specifying a version to install
9
+
10
+ > Arch Linux strives to maintain the latest stable release versions of its software as long as systemic package breakage can be reasonably avoided.
11
+ **Source: https://wiki.archlinux.org/index.php/Arch_Linux**
12
+
13
+ Since Arch is a rolling release, the Puppet version installed by Pacman will always be the latest avaliable release from the upstream.
14
+
15
+ Because of this, it's not possible to specify a specific version with any of the Puppet install helper methods, and a warning will be shown if it is attempted.
16
+
17
+ Because the Arch version will always be latest, it will always be Puppet 4+ with the AIO packaging, so it's advised to specify this in the config:
18
+
19
+ ```
20
+ CONFIG:
21
+ log_level: verbose
22
+ type: aio
23
+ ```
24
+
25
+ ## Versioning
26
+
27
+ Arch doesn't really have the idea of a release version, as it's a rolling update.
28
+
29
+ For coventions sake, it's advised to put the date of creation of your Arch VM in the name of your SUT, so you know roughly when the VM is cut from:
30
+
31
+ ```
32
+ HOSTS:
33
+ archlinux-2016.02.02-amd64:
34
+ roles:
35
+ - master
36
+ platform: archlinux-2016.02.02-amd64
37
+ box: terrywang/archlinux
38
+ box_version: 1.0.0
39
+ hypervisor: vagrant
40
+ CONFIG:
41
+ log_level: verbose
42
+ type: aio
43
+ ```
@@ -0,0 +1,88 @@
1
+ # How To Install Puppet
2
+
3
+ This doc will guide you through the process of installing Puppet Agent using
4
+ beaker's DSL helpers.
5
+
6
+ Note that this is not a complete documentation of the process, but a general
7
+ overview. There will be specific hiccups for particular platforms and special
8
+ cases. These are not all included at this point. The idea is that as we come
9
+ upon them, we will now have a place to document those details, so that we can
10
+ over time bring this to 100% completeness.
11
+
12
+ # First Things First: What Do You Want to Install?
13
+
14
+ If you understand [beaker's roles](https://github.com/puppetlabs/beaker/blob/master/docs/concepts/roles_what_are_they.md)
15
+ and just want the shortcuts to installing Open Source Puppet across your testing
16
+ environment, then you should go to our "High Level Shortcuts" section below.
17
+
18
+ If you'd like to only install Puppet Agents, please checkout our "Puppet Agent
19
+ Installs" section for more information.
20
+
21
+ # High Level Shortcuts
22
+
23
+ The
24
+ [`install_puppet_on`](http://www.rubydoc.info/gems/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet_on-instance_method)
25
+ method is a wrapper on our installing Puppet behavior that allows you to pass in
26
+ which hosts in particular you'd like to install Puppet on as well as specifying
27
+ the options used yourself. Please checkout the Rubydocs linked above for more
28
+ info on this method.
29
+
30
+ The
31
+ [`install_puppet`](http://www.rubydoc.info/gems/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet-instance_method)
32
+ is deprecated. It's a shortcut method that just calls `install_puppet_on`
33
+ passing the entire hosts array and global options hash. You can get the same
34
+ using this code in your pre-suite:
35
+
36
+ ```ruby
37
+ install_puppet_on(hosts, options)
38
+ ```
39
+
40
+ Note that both of the high level methods will call the `install_puppet_agent_on`
41
+ method to install released Puppet Agent versions for your agent Systems Under
42
+ Test (SUTs). Please checkout our "Released Open Source Puppet Agents" section
43
+ below for more information on this method.
44
+
45
+ # Puppet Agent Installs
46
+
47
+ There are a number of Puppet Agents that you could be installing. There aren't
48
+ only an ever-growing number of versions, but you can get Puppet Agent from a
49
+ number of locations.
50
+
51
+ If you'd like to install the Puppet Agent that comes with your particular Puppet
52
+ Enterprise (PE) install, then please skip to our "PE Promoted Agent Installs"
53
+ section below.
54
+
55
+ For our different Open Source variants, check out the sections just below, which
56
+ differentiate between released & development Puppet Agent versions.
57
+
58
+ ### Released Open Source Puppet Agents
59
+
60
+ To install a released version of Puppet Agent, beaker provides the
61
+ [`install_puppet_agent_on`](http://www.rubydoc.info/gems/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet_agent_on-instance_method)
62
+ method. Please checkout the Rubydocs for more info on this method.
63
+
64
+ ### Development Open Source Puppet Agents
65
+
66
+ To install a development build of Puppet Agent, beaker provides the
67
+ [`install_puppet_agent_dev_repo_on`](http://www.rubydoc.info/gems/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet_agent_dev_repo_on-instance_method)
68
+ method. Please checkout the Rubydocs for more info on this method.
69
+
70
+ ### PE Promoted Agent Installs
71
+
72
+ If you're using this method, then you're going to be downloading the installer
73
+ from a URL configured like so:
74
+
75
+ ```ruby
76
+ http://pm.puppetlabs.com/puppet-agent/#{ pe_version }/#{ puppet_agent_version }/repos
77
+ ```
78
+
79
+ `pe_version` is a variable that you can provide using either the host or global
80
+ property `:pe_ver`. This is usually done in the hosts file, and will default to
81
+ `4.0.0-rc1` if nothing is specified.
82
+
83
+ `puppet_agent_version` is a variable you can provide the value of through the
84
+ same methods as `pe_version` above. It will default to `latest`.
85
+
86
+ Beaker's DSL method to install from this location is
87
+ [`install_puppet_agent_pe_promoted_repo_on`](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/InstallUtils/FOSSUtils#install_puppet_agent_pe_promoted_repo_on-instance_method).
88
+ Follow the link to get API-level docs on this method for more info.
@@ -1,9 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
- [ 'facter', 'host', 'puppet', 'test', 'tk', 'web', 'hocon' ].each do |lib|
2
+ [ 'host', 'puppet', 'test', 'tk', 'web', 'hocon' ].each do |lib|
3
3
  require "beaker/dsl/helpers/#{lib}_helpers"
4
4
  end
5
5
 
6
- require "beaker-hiera"
6
+ require 'beaker-hiera'
7
+ require 'beaker-facter'
7
8
  module Beaker
8
9
  module DSL
9
10
 
@@ -23,7 +24,6 @@ module Beaker
23
24
  #
24
25
  #
25
26
  module Helpers
26
- include Beaker::DSL::Helpers::FacterHelpers
27
27
  include Beaker::DSL::Helpers::HostHelpers
28
28
  include Beaker::DSL::Helpers::PuppetHelpers
29
29
  include Beaker::DSL::Helpers::TestHelpers
@@ -31,6 +31,7 @@ module Beaker
31
31
  include Beaker::DSL::Helpers::WebHelpers
32
32
  include Beaker::DSL::Helpers::HoconHelpers
33
33
  include Beaker::DSL::Helpers::Hiera
34
+ include Beaker::DSL::Helpers::Facter
34
35
  end
35
36
  end
36
37
  end
@@ -9,6 +9,23 @@ module Beaker
9
9
  # for these methods to execute correctly
10
10
  module PuppetHelpers
11
11
 
12
+ # Return the regular expression pattern for an IPv4 address
13
+ def ipv4_regex
14
+ return /(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/
15
+ end
16
+
17
+ # Return the IP address that given hostname returns when resolved on
18
+ # the given host.
19
+ #
20
+ # @ param [Host] host One object that acts like a Beaker::Host
21
+ # @ param [String] hostname The hostname to perform a DNS resolution on
22
+ #
23
+ # @return [String, nil] An IP address, or nil.
24
+ def resolve_hostname_on(host, hostname)
25
+ match = curl_on(host, "--verbose #{hostname}", :accept_all_exit_codes => true).stderr.match(ipv4_regex)
26
+ return match ? match[0] : nil
27
+ end
28
+
12
29
  # @!macro [new] common_opts
13
30
  # @param [Hash{Symbol=>String}] opts Options to alter execution.
14
31
  # @option opts [Boolean] :silent (false) Do not produce log output
@@ -606,7 +623,9 @@ module Beaker
606
623
  #use global options hash
607
624
  primary_forge_name = 'forge.puppetlabs.com'
608
625
  forge_host ||= options[:forge_host]
609
- @forge_ip ||= Resolv.getaddress(forge_host)
626
+ forge_ip = resolve_hostname_on(machine, forge_host)
627
+ raise "Failed to resolve forge host '#{forge_host}'" unless forge_ip
628
+ @forge_ip ||= forge_ip
610
629
  block_on machine do | host |
611
630
  stub_hosts_on(host, {primary_forge_name => @forge_ip}, {primary_forge_name => ['forge.puppet.com','forgeapi.puppetlabs.com','forgeapi.puppet.com']})
612
631
  end
@@ -625,7 +644,9 @@ module Beaker
625
644
  #use global options hash
626
645
  primary_forge_name = 'forge.puppetlabs.com'
627
646
  forge_host ||= options[:forge_host]
628
- @forge_ip ||= Resolv.getaddress(forge_host)
647
+ forge_ip = resolve_hostname_on(host, forge_host)
648
+ raise "Failed to resolve forge host '#{forge_host}'" unless forge_ip
649
+ @forge_ip ||= forge_ip
629
650
  with_host_stubbed_on( host, {primary_forge_name => @forge_ip}, {primary_forge_name => ['forge.puppet.com','forgeapi.puppetlabs.com','forgeapi.puppet.com']}, &block )
630
651
  end
631
652
 
@@ -83,6 +83,23 @@ module Beaker
83
83
  'distmoduledir' => '/etc/puppet/modules',
84
84
  'sitemoduledir' => '/usr/share/puppet/modules',
85
85
  },
86
+ 'archlinux' => {
87
+ 'puppetserver-confdir' => '/etc/puppetserver/conf.d',
88
+ 'puppetservice' => 'puppetmaster',
89
+ 'puppetpath' => '/etc/puppetlabs/puppet',
90
+ 'puppetconfdir' => '/etc/puppetlabs/puppet',
91
+ 'puppetvardir' => '/opt/puppetlabs/puppet/cache',
92
+ 'puppetbin' => '/usr/bin/puppet',
93
+ 'puppetbindir' => '/usr/bin',
94
+ 'privatebindir' => '/usr/bin',
95
+ 'hieralibdir' => '/var/lib/hiera',
96
+ 'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
97
+ 'hierabindir' => '/usr/bin',
98
+ 'hieradatadir' => '/etc/puppetlabs/code/hiera',
99
+ 'hieraconf' => '/etc/hiera.yaml',
100
+ 'distmoduledir' => '/etc/puppetlabs/code/modules',
101
+ 'sitemoduledir' => '/usr/share/puppet/modules',
102
+ },
86
103
  'windows' => { #cygwin windows
87
104
  'puppetpath' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
88
105
  'puppetconfdir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc',
@@ -144,6 +161,8 @@ module Beaker
144
161
  platform = 'mac'
145
162
  when /pswindows/
146
163
  platform = 'pswindows'
164
+ when /archlinux/
165
+ platform = 'archlinux'
147
166
  else
148
167
  platform = 'windows'
149
168
  end
@@ -280,6 +280,8 @@ module Beaker
280
280
  install_puppet_from_openbsd_packages_on(host, opts)
281
281
  elsif host['platform'] =~ /freebsd/
282
282
  install_puppet_from_freebsd_ports_on(host, opts)
283
+ elsif host['platform'] =~ /archlinux/
284
+ install_puppet_from_pacman_on(host, opts)
283
285
  else
284
286
  if opts[:default_action] == 'gem_install'
285
287
  opts[:version] ||= '~> 3.x'
@@ -769,6 +771,27 @@ module Beaker
769
771
  end
770
772
  end
771
773
 
774
+ # Installs Puppet and dependencies from Arch Linux Pacman
775
+ #
776
+ # @param [Host, Array<Host>, String, Symbol] hosts The host to install packages on
777
+ # @param [Hash{Symbol=>String}] opts An options hash
778
+ # @option opts [String] :version The version of Puppet to install (shows warning)
779
+ #
780
+ # @return nil
781
+ # @api private
782
+ def install_puppet_from_pacman_on(hosts, opts)
783
+ if (opts[:version])
784
+ # Arch is rolling release, only the latest package versions are supported
785
+ logger.warn "If you wish to choose a specific Puppet version, use `install_puppet_from_gem_on('~> 3.*')`"
786
+ end
787
+
788
+ block_on hosts do |host|
789
+ host.install_package('puppet')
790
+
791
+ configure_type_defaults_on(host)
792
+ end
793
+ end
794
+
772
795
  # Installs Puppet and dependencies from gem on provided host(s)
773
796
  #
774
797
  # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon,
@@ -166,7 +166,7 @@ module Unix::Exec
166
166
  case self['platform']
167
167
  when /debian|ubuntu|cumulus|huaweios/
168
168
  exec(Beaker::Command.new("service ssh restart"))
169
- when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|fedora-(1[4-9]|2[0-9])/
169
+ when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|fedora-(1[4-9]|2[0-9])|archlinux-/
170
170
  exec(Beaker::Command.new("systemctl restart sshd.service"))
171
171
  when /el-|centos|fedora|redhat|oracle|scientific|eos/
172
172
  exec(Beaker::Command.new("/sbin/service sshd restart"))
@@ -188,7 +188,7 @@ module Unix::Exec
188
188
  # (from {#ssh_service_restart}).
189
189
  def ssh_permit_user_environment
190
190
  case self['platform']
191
- when /debian|ubuntu|cumulus|huaweios/
191
+ when /debian|ubuntu|cumulus|huaweios|archlinux/
192
192
  directory = create_tmpdir_on(self)
193
193
  exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
194
194
  exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
@@ -45,6 +45,8 @@ module Unix::Pkg
45
45
  end
46
46
  when /openbsd/
47
47
  result = execute("pkg_info #{name}", opts) { |result| result }
48
+ when /archlinux/
49
+ result = execute("pacman -Q #{name}", opts) { |result| result }
48
50
  else
49
51
  raise "Package #{name} cannot be queried on #{self}"
50
52
  end
@@ -128,6 +130,8 @@ module Unix::Pkg
128
130
  rescue
129
131
  retry
130
132
  end
133
+ when /archlinux/
134
+ execute("pacman -S --noconfirm #{cmdline_args} #{name}", opts)
131
135
  else
132
136
  raise "Package #{name} cannot be installed on #{self}"
133
137
  end
@@ -169,6 +173,8 @@ module Unix::Pkg
169
173
  execute("pkgrm -n #{cmdline_args} #{name}", opts)
170
174
  when /aix/
171
175
  execute("rpm #{cmdline_args} -e #{name}", opts)
176
+ when /archlinux/
177
+ execute("pacman -R --noconfirm #{cmdline_args} #{name}", opts)
172
178
  else
173
179
  raise "Package #{name} cannot be installed on #{self}"
174
180
  end
@@ -394,7 +400,8 @@ module Unix::Pkg
394
400
  when /^(solaris)$/
395
401
  release_path_end, release_file = solaris_puppet_agent_dev_package_info(
396
402
  puppet_collection, puppet_agent_version, opts )
397
- when /^(sles|aix|el)$/
403
+ when /^(sles|aix|el|centos|oracle|redhat|scientific)$/
404
+ variant = 'el' if variant.match(/(?:el|centos|oracle|redhat|scientific)/)
398
405
  arch = 'ppc' if variant == 'aix' && arch == 'power'
399
406
  release_path_end = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
400
407
  release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.rpm"
@@ -15,6 +15,7 @@ module Beaker
15
15
  UNIX_PACKAGES = ['curl', 'ntpdate']
16
16
  FREEBSD_PACKAGES = ['curl', 'perl5|perl']
17
17
  OPENBSD_PACKAGES = ['curl']
18
+ ARCHLINUX_PACKAGES = ['curl', 'ntp']
18
19
  WINDOWS_PACKAGES = ['curl']
19
20
  PSWINDOWS_PACKAGES = []
20
21
  SLES10_PACKAGES = ['curl']
@@ -114,6 +115,8 @@ module Beaker
114
115
  check_and_install_packages_if_needed(host, SOLARIS10_PACKAGES)
115
116
  when host['platform'] =~ /solaris-1[1-9]/
116
117
  check_and_install_packages_if_needed(host, SOLARIS11_PACKAGES)
118
+ when host['platform'] =~ /archlinux/
119
+ check_and_install_packages_if_needed(host, ARCHLINUX_PACKAGES)
117
120
  when host['platform'] !~ /debian|aix|solaris|windows|sles-|osx-|cumulus|f5-|netscaler|cisco_/
118
121
  check_and_install_packages_if_needed(host, UNIX_PACKAGES)
119
122
  end
@@ -269,8 +272,12 @@ module Beaker
269
272
  def get_domain_name(host)
270
273
  domain = nil
271
274
  search = nil
272
- if ((host['platform'] =~ /windows/) and not host.is_cygwin?)
273
- resolv_conf = host.exec(Command.new('type C:\Windows\System32\drivers\etc\hosts')).stdout
275
+ if host['platform'] =~ /windows/
276
+ if host.is_cygwin?
277
+ resolv_conf = host.exec(Command.new("cat /cygdrive/c/Windows/System32/drivers/etc/hosts")).stdout
278
+ else
279
+ resolv_conf = host.exec(Command.new('type C:\Windows\System32\drivers\etc\hosts')).stdout
280
+ end
274
281
  else
275
282
  resolv_conf = host.exec(Command.new("cat /etc/resolv.conf")).stdout
276
283
  end
@@ -406,15 +413,17 @@ module Beaker
406
413
  elsif host['platform'] =~ /solaris-11/
407
414
  host.exec(Command.new("if grep \"root::::type=role\" /etc/user_attr; then sudo rolemod -K type=normal root; else echo \"root user already type=normal\"; fi"), {:pty => true} )
408
415
  host.exec(Command.new("sudo gsed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config"), {:pty => true} )
409
- elsif not host.is_powershell?
410
- host.exec(Command.new("sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""), {:pty => true})
411
- else
416
+ elsif host.is_cygwin?
417
+ host.exec(Command.new("sed -ri 's/^#?PermitRootLogin /PermitRootLogin yes/' /etc/sshd_config"), {:pty => true})
418
+ elsif host.is_powershell?
412
419
  logger.warn("Attempting to enable root login non-supported platform: #{host.name}: #{host['platform']}")
420
+ else
421
+ host.exec(Command.new("sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""), {:pty => true})
413
422
  end
414
423
  #restart sshd
415
424
  if host['platform'] =~ /debian|ubuntu|cumulus/
416
425
  host.exec(Command.new("sudo su -c \"service ssh restart\""), {:pty => true})
417
- elsif host['platform'] =~ /centos-7|el-7|redhat-7|fedora-(1[4-9]|2[0-9])/
426
+ elsif host['platform'] =~ /arch|centos-7|el-7|redhat-7|fedora-(1[4-9]|2[0-9])/
418
427
  host.exec(Command.new("sudo -E systemctl restart sshd.service"), {:pty => true})
419
428
  elsif host['platform'] =~ /centos|el-|redhat|fedora|eos/
420
429
  host.exec(Command.new("sudo -E /sbin/service sshd reload"), {:pty => true})
@@ -188,6 +188,12 @@ module Beaker
188
188
 
189
189
  @logger.debug "configure vagrant boxes (set ssh-config, switch to root user, hack etc/hosts)"
190
190
  @hosts.each do |host|
191
+ if host[:platform] =~ /windows/
192
+ @logger.debug "skip ssh hacks on windows box #{host[:name]}"
193
+ set_ssh_config host, host['user']
194
+ next
195
+ end
196
+
191
197
  default_user = host['user']
192
198
 
193
199
  set_ssh_config host, 'vagrant'
@@ -234,5 +240,30 @@ module Beaker
234
240
  end
235
241
  end
236
242
 
243
+ def self.cpus(host, options)
244
+ case
245
+ when host['vagrant_cpus']
246
+ host['vagrant_cpus']
247
+ when options['vagrant_cpus']
248
+ options['vagrant_cpus']
249
+ else
250
+ '1'
251
+ end
252
+ end
253
+
254
+ def self.memsize(host, options)
255
+ case
256
+ when host['vagrant_memsize']
257
+ host['vagrant_memsize']
258
+ when options['vagrant_memsize']
259
+ options['vagrant_memsize']
260
+ else
261
+ if host['platform'] =~ /windows/
262
+ '2048'
263
+ else
264
+ '1024'
265
+ end
266
+ end
267
+ end
237
268
  end
238
269
  end
@@ -11,7 +11,7 @@ class Beaker::VagrantFusion < Beaker::Vagrant
11
11
 
12
12
  def self.provider_vfile_section(host, options)
13
13
  " v.vm.provider :vmware_fusion do |v|\n" +
14
- " v.vmx['memsize'] = '#{options['vagrant_memsize'] ||= '1024'}'\n" +
14
+ " v.vmx['memsize'] = '#{memsize(host, options)}'\n" +
15
15
  " end\n"
16
16
  end
17
17
  end
@@ -14,36 +14,12 @@ class Beaker::VagrantLibvirt < Beaker::Vagrant
14
14
 
15
15
  def self.provider_vfile_section(host, options)
16
16
  " v.vm.provider :libvirt do |node|\n" +
17
- " node.cpus = #{cpu(host, options)}\n" +
18
- " node.memory = #{memory(host, options)}\n" +
17
+ " node.cpus = #{cpus(host, options)}\n" +
18
+ " node.memory = #{memsize(host, options)}\n" +
19
19
  build_options_str(options) +
20
20
  " end\n"
21
21
  end
22
22
 
23
- def self.cpu(host, options)
24
- return @cpu unless @cpu.nil?
25
- @cpu = case
26
- when host['vagrant_cpus']
27
- host['vagrant_cpus']
28
- when options['vagrant_cpus']
29
- options['vagrant_cpus']
30
- else
31
- '1'
32
- end
33
- end
34
-
35
- def self.memory(host, options)
36
- return @memory unless @memory.nil?
37
- @memory = case
38
- when host['vagrant_memsize']
39
- host['vagrant_memsize']
40
- when options['vagrant_memsize']
41
- options['vagrant_memsize']
42
- else
43
- '512'
44
- end
45
- end
46
-
47
23
  def self.build_options_str(options)
48
24
  other_options_str = ''
49
25
  if options['libvirt']
@@ -9,7 +9,7 @@ class Beaker::VagrantParallels < Beaker::Vagrant
9
9
  provider_section = ""
10
10
  provider_section << " v.vm.provider :parallels do |prl|\n"
11
11
  provider_section << " prl.optimize_power_consumption = false\n"
12
- provider_section << " prl.memory = '#{options['vagrant_memsize'] ||= '1024'}'\n"
12
+ provider_section << " prl.memory = '#{memsize(host,options)}'\n"
13
13
  provider_section << " prl.update_guest_tools = false\n" if options[:prl_update_guest_tools] == 'disable'
14
14
  provider_section << " end\n"
15
15
 
@@ -17,12 +17,9 @@ class Beaker::VagrantVirtualbox < Beaker::Vagrant
17
17
 
18
18
  def self.provider_vfile_section(host, options)
19
19
  # Allow memory and CPUs to be set at a per node level or overall, and take the most specific setting
20
- host_memory = host['vagrant_memsize'] ? host['vagrant_memsize'] : (options['vagrant_memsize'] ? options['vagrant_memsize'] : 1024)
21
- host_cpus = host['vagrant_cpus'] ? host['vagrant_cpus'] : (options['vagrant_cpus'] ? options['vagrant_cpus'] : 1)
22
-
23
20
  provider_section = ""
24
21
  provider_section << " v.vm.provider :virtualbox do |vb|\n"
25
- provider_section << " vb.customize ['modifyvm', :id, '--memory', '#{host_memory}', '--cpus', '#{host_cpus}']\n"
22
+ provider_section << " vb.customize ['modifyvm', :id, '--memory', '#{memsize(host,options)}', '--cpus', '#{cpus(host,options)}']\n"
26
23
  provider_section << " vb.vbguest.auto_update = false" if options[:vbguest_plugin] == 'disable'
27
24
 
28
25
  # Guest volume support
@@ -7,7 +7,7 @@ class Beaker::VagrantWorkstation < Beaker::Vagrant
7
7
 
8
8
  def self.provider_vfile_section(host, options)
9
9
  " v.vm.provider :vmware_workstation do |v|\n" +
10
- " v.vmx['memsize'] = '#{options['vagrant_memsize'] ||= '1024'}'\n" +
10
+ " v.vmx['memsize'] = '#{memsize(host,options)}'\n" +
11
11
  " end\n"
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@ module Beaker
3
3
  # all String methods while adding several platform-specific use cases.
4
4
  class Platform < String
5
5
  # Supported platforms
6
- PLATFORMS = /^(huaweios|cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|scientific|sles|ubuntu|windows|solaris|aix|el|eos|cumulus|f5|netscaler)\-.+\-.+$/
6
+ PLATFORMS = /^(huaweios|cisco_nexus|cisco_ios_xr|(free|open)bsd|osx|centos|fedora|debian|oracle|redhat|scientific|sles|ubuntu|windows|solaris|aix|archlinux|el|eos|cumulus|f5|netscaler)\-.+\-.+$/
7
7
  # Platform version numbers vs. codenames conversion hash
8
8
  PLATFORM_VERSION_CODES =
9
9
  { :debian => { "jessie" => "8",
@@ -65,6 +65,7 @@ module Beaker
65
65
  # * cumulus
66
66
  # * f5
67
67
  # * netscaler
68
+ # * archlinux
68
69
  def initialize(name)
69
70
  if name !~ PLATFORMS
70
71
  raise ArgumentError, "Unsupported platform name #{name}"
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '3.6.0'
3
+ STRING = '3.7.0'
4
4
  end
5
5
  end
@@ -376,10 +376,8 @@ describe ClassMixedWithDSLHelpers do
376
376
 
377
377
  describe '#stub_forge_on' do
378
378
  it 'stubs forge.puppetlabs.com with the value of `forge`' do
379
- allow( subject ).to receive( :hosts ).and_return( hosts )
379
+ allow( subject ).to receive( :resolve_hostname_on ).and_return ( '127.0.0.1' )
380
380
  host = make_host('my_host', {})
381
- expect( Resolv ).to receive( :getaddress ).
382
- with( 'my_forge.example.com' ).and_return( '127.0.0.1' )
383
381
  expect( subject ).to receive( :stub_hosts_on ).
384
382
  with( host, {'forge.puppetlabs.com' => '127.0.0.1'}, {'forge.puppetlabs.com' => ['forge.puppet.com','forgeapi.puppetlabs.com','forgeapi.puppet.com']} )
385
383
 
@@ -466,6 +466,13 @@ describe ClassMixedWithDSLInstallUtils do
466
466
  subject.install_puppet
467
467
  end
468
468
  end
469
+ context 'on archlinux' do
470
+ let(:platform) { Beaker::Platform.new('archlinux-2015.09.01-x86_84') }
471
+ it 'installs' do
472
+ expect(hosts[0]).to receive(:install_package).with('puppet')
473
+ subject.install_puppet
474
+ end
475
+ end
469
476
  context 'on debian' do
470
477
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
471
478
  let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
@@ -97,7 +97,7 @@ module Beaker
97
97
  expect( instance ).to receive(:exec).with('', :accept_all_exit_codes => true).and_return(generate_result("hello", {:exit_code => 0}))
98
98
  expect( instance.check_for_package(pkg) ).to be === true
99
99
  end
100
-
100
+
101
101
  it "checks correctly on fedora" do
102
102
  @opts = {'platform' => 'fedora-is-me'}
103
103
  pkg = 'fedora_package'
@@ -177,6 +177,14 @@ module Beaker
177
177
  expect( instance.check_for_package(pkg) ).to be === true
178
178
  end
179
179
 
180
+ it "checks correctly on archlinux" do
181
+ @opts = {'platform' => 'archlinux-is-me'}
182
+ pkg = 'archlinux_package'
183
+ expect( Beaker::Command ).to receive(:new).with("pacman -Q #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
184
+ expect( instance ).to receive(:exec).with('', :accept_all_exit_codes => true).and_return(generate_result("hello", {:exit_code => 0}))
185
+ expect( instance.check_for_package(pkg) ).to be === true
186
+ end
187
+
180
188
  it "returns false for el-4" do
181
189
  @opts = {'platform' => 'el-4-is-me'}
182
190
  pkg = 'el-4_package'
@@ -233,6 +241,14 @@ module Beaker
233
241
  expect( instance.install_package(pkg) ).to be == "hello"
234
242
  end
235
243
  end
244
+
245
+ it "uses pacman on archlinux" do
246
+ @opts = {'platform' => 'archlinux-is-me'}
247
+ pkg = 'archlinux_package'
248
+ expect( Beaker::Command ).to receive(:new).with("pacman -S --noconfirm #{pkg}", [], {:prepend_cmds=>nil, :cmdexe=>false}).and_return('')
249
+ expect( instance ).to receive(:exec).with('', {}).and_return(generate_result("hello", {:exit_code => 0}))
250
+ expect( instance.install_package(pkg) ).to be == "hello"
251
+ end
236
252
  end
237
253
 
238
254
  describe '#uninstall_package' do
@@ -266,6 +282,29 @@ module Beaker
266
282
  end
267
283
  end
268
284
 
285
+ describe '#puppet_agent_dev_package_info' do
286
+ puppet_collection = 'PC1'
287
+ puppet_agent_version = '1.2.3'
288
+ platforms = { 'solaris-10-x86_64' => ["solaris/10/#{puppet_collection}", "puppet-agent-#{puppet_agent_version}-1.i386.pkg.gz"],
289
+ 'solaris-11-x86_64' => ["solaris/11/#{puppet_collection}", "puppet-agent@#{puppet_agent_version},5.11-1.i386.p5p"],
290
+ 'sles-11-x86_64' => ["sles/11/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.sles11.x86_64.rpm"],
291
+ 'aix-5.3-power' => ["aix/5.3/#{puppet_collection}/ppc", "puppet-agent-#{puppet_agent_version}-1.aix5.3.ppc.rpm"],
292
+ 'el-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
293
+ 'centos-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
294
+ 'oracle-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
295
+ 'redhat-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"],
296
+ 'scientific-7-x86_64' => ["el/7/#{puppet_collection}/x86_64", "puppet-agent-#{puppet_agent_version}-1.el7.x86_64.rpm"]
297
+ }
298
+ platforms.each do |p, v|
299
+ it "accomodates platform #{p} without erroring" do
300
+ platform = Beaker::Platform.new(p)
301
+ @opts = {'platform' => platform}
302
+ allow( instance ).to receive(:link_exists?).and_return(true)
303
+ expect( instance.puppet_agent_dev_package_info( puppet_collection, puppet_agent_version, { :download_url => 'http://trust.me' } )).to eq(v)
304
+ end
305
+ end
306
+ end
307
+
269
308
  describe '#upgrade_package' do
270
309
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
271
310
  it "calls the correct apt-get incantation for #{platform}" do
@@ -43,7 +43,7 @@ describe Beaker do
43
43
 
44
44
  # Non-cygwin Windows
45
45
  it_should_behave_like 'enables_root_login', 'windows', [
46
- "sudo su -c \"sed -ri 's/^#?PermitRootLogin no|^#?PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config\""
46
+ "sed -ri 's/^#?PermitRootLogin /PermitRootLogin yes/' /etc/sshd_config"
47
47
  ], true
48
48
 
49
49
  # FreeBSD
@@ -403,22 +403,69 @@ describe Beaker do
403
403
  context 'get_domain_name' do
404
404
  subject { dummy_class.new }
405
405
 
406
- it "can find the domain for a host" do
407
- host = make_host('name', { :stdout => "domain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" } )
406
+ shared_examples 'find domain name' do
407
+ it "finds the domain name" do
408
+ expect( subject.get_domain_name( host ) ).to be === "labs.lan"
409
+ end
410
+ end
408
411
 
409
- expect( Beaker::Command ).to receive( :new ).with( "cat /etc/resolv.conf" ).once
412
+ context "on windows" do
413
+ let(:host) { make_host( 'name', {
414
+ :platform => 'windows',
415
+ :is_cygwin => cygwin,
416
+ :stdout => "domain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11",
417
+ } ) }
410
418
 
411
- expect( subject.get_domain_name( host ) ).to be === "labs.lan"
419
+ context "with cygwin" do
420
+ let(:cygwin) { true }
421
+ before(:each) do
422
+ expect( Beaker::Command ).to receive( :new ).with( "cat /cygdrive/c/Windows/System32/drivers/etc/hosts" ).once
423
+ end
424
+ include_examples 'find domain name'
425
+ end
412
426
 
427
+ context "without cygwin" do
428
+ let(:cygwin) { false }
429
+ before(:each) do
430
+ expect( Beaker::Command ).to receive( :new ).with( 'type C:\Windows\System32\drivers\etc\hosts' ).once
431
+ end
432
+ include_examples 'find domain name'
433
+ end
413
434
  end
414
435
 
415
- it "can find the search for a host" do
416
- host = make_host('name', { :stdout => "search labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" } )
436
+ context "on other platforms" do
437
+ let(:host) { make_host( 'name', {
438
+ :platform => 'centos',
439
+ :stdout => stdout,
440
+ } ) }
441
+
442
+ before(:each) do
443
+ expect( Beaker::Command ).to receive( :new ).with( "cat /etc/resolv.conf" ).once
444
+ end
445
+
446
+ context "with a domain entry" do
447
+ let(:stdout) { "domain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" }
448
+
449
+ include_examples 'find domain name'
450
+ end
417
451
 
418
- expect( Beaker::Command ).to receive( :new ).with( "cat /etc/resolv.conf" ).once
452
+ context "with a search entry" do
453
+ let(:stdout) { "search labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" }
454
+
455
+ include_examples 'find domain name'
456
+ end
419
457
 
420
- expect( subject.get_domain_name( host ) ).to be === "labs.lan"
458
+ context "with a both a domain and a search entry" do
459
+ let(:stdout) { "domain labs.lan\nsearch d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" }
421
460
 
461
+ include_examples 'find domain name'
462
+ end
463
+
464
+ context "with a both a domain and a search entry, the search entry first" do
465
+ let(:stdout) { "search foo.example.net\ndomain labs.lan d.labs.net dc1.labs.net labs.com\nnameserver 10.16.22.10\nnameserver 10.16.22.11" }
466
+
467
+ include_examples 'find domain name'
468
+ end
422
469
  end
423
470
  end
424
471
 
@@ -41,7 +41,7 @@ describe Beaker::VagrantLibvirt do
41
41
 
42
42
  it "can specify the memory as an integer" do
43
43
  expect( @vagrantfile.split("\n").map(&:strip) )
44
- .to include('node.memory = 512')
44
+ .to include('node.memory = 1024')
45
45
  end
46
46
 
47
47
  it "can specify the number of cpus" do
@@ -147,25 +147,32 @@ EOF
147
147
  expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0"/)
148
148
  end
149
149
 
150
- it "generates a valid windows config" do
151
- path = vagrant.instance_variable_get( :@vagrant_path )
152
- allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
153
- @hosts[0][:platform] = 'windows'
154
-
155
- vagrant.make_vfile( @hosts )
150
+ context "when generating a windows config" do
151
+ before do
152
+ path = vagrant.instance_variable_get( :@vagrant_path )
153
+ allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
154
+ @hosts[0][:platform] = 'windows'
156
155
 
157
- generated_file = File.read( File.expand_path( File.join( path, "Vagrantfile") ) )
156
+ vagrant.make_vfile( @hosts )
158
157
 
159
- match = generated_file.match(/v.vm.network :forwarded_port, guest: 3389, host: 3389, id: 'rdp', auto_correct: true/)
160
- expect( match ).to_not be_nil,'Should have proper port for RDP'
158
+ @generated_file = File.read( File.expand_path( File.join( path, "Vagrantfile") ) )
159
+ end
161
160
 
162
- match = generated_file.match(/v.vm.network :forwarded_port, guest: 5985, host: 5985, id: 'winrm', auto_correct: true/)
163
- expect( match ).to_not be_nil, "Should have proper port for WinRM"
161
+ it 'has the proper port forwarding for RDP' do
162
+ expect( @generated_file ).to match /v.vm.network :forwarded_port, guest: 3389, host: 3389, id: 'rdp', auto_correct: true/
163
+ end
164
164
 
165
- match = generated_file.match(/v.vm.guest = :windows/)
166
- expect( match ).to_not be_nil, 'Should correctly identify guest OS so Vagrant can act accordingly'
165
+ it 'has the proper port forwarding for WinRM' do
166
+ expect( @generated_file ).to match /v.vm.network :forwarded_port, guest: 5985, host: 5985, id: 'winrm', auto_correct: true/
167
+ end
167
168
 
169
+ it 'configures the guest type to windows' do
170
+ expect( @generated_file ).to match /v.vm.guest = :windows/
171
+ end
168
172
 
173
+ it 'sets a non-default memsize' do
174
+ expect( @generated_file ).to match /'--memory', '2048',/
175
+ end
169
176
  end
170
177
 
171
178
  it "uses the memsize defined per vagrant host" do
@@ -382,7 +389,7 @@ EOF
382
389
  it "raises an error if no Vagrantfile is present" do
383
390
  File.delete( vagrant.instance_variable_get( :@vagrant_file ) )
384
391
  @hosts.each do |host|
385
- expect{ vagrant.get_ip_from_vagrant_file(host.name) }.to raise_error
392
+ expect{ vagrant.get_ip_from_vagrant_file(host.name) }.to raise_error RuntimeError, /No vagrant file found/
386
393
  end
387
394
  end
388
395
  end
@@ -424,6 +431,42 @@ EOF
424
431
 
425
432
  end
426
433
 
434
+ describe "provisioning and cleanup on windows" do
435
+ before :each do
436
+ expect( vagrant ).to receive( :vagrant_cmd ).with( "up" ).once
437
+ @hosts.each do |host|
438
+ host_prev_name = host['user']
439
+ expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
440
+ expect( vagrant ).not_to receive( :copy_ssh_to_root ).with( host, options ).once
441
+ expect( vagrant ).not_to receive( :set_ssh_config ).with( host, host_prev_name ).once
442
+ end
443
+ expect( vagrant ).to receive( :hack_etc_hosts ).with( @hosts, options ).once
444
+ end
445
+
446
+ it "can provision a set of hosts" do
447
+ options = vagrant.instance_variable_get( :@options )
448
+ expect( vagrant ).to receive( :make_vfile ).with( @hosts, options ).once
449
+ expect( vagrant ).to receive( :vagrant_cmd ).with( "destroy --force" ).never
450
+ vagrant.provision
451
+ end
452
+
453
+ it "destroys an existing set of hosts before provisioning" do
454
+ vagrant.make_vfile( @hosts )
455
+ expect( vagrant ).to receive( :vagrant_cmd ).with( "destroy --force" ).once
456
+ vagrant.provision
457
+ end
458
+
459
+ it "can cleanup" do
460
+ expect( vagrant ).to receive( :vagrant_cmd ).with( "destroy --force" ).once
461
+ expect( FileUtils ).to receive( :rm_rf ).once
462
+
463
+ vagrant.provision
464
+ vagrant.cleanup
465
+
466
+ end
467
+
468
+ end
469
+
427
470
  end
428
471
 
429
472
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-14 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.5.4
139
- - !ruby/object:Gem::Dependency
140
- name: json
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ~>
144
- - !ruby/object:Gem::Version
145
- version: '1.8'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ~>
151
- - !ruby/object:Gem::Version
152
- version: '1.8'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: hocon
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +262,20 @@ dependencies:
276
262
  - - ~>
277
263
  - !ruby/object:Gem::Version
278
264
  version: '0.0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: beaker-facter
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ~>
270
+ - !ruby/object:Gem::Version
271
+ version: '0.0'
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ~>
277
+ - !ruby/object:Gem::Version
278
+ version: '0.0'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: beaker-hostgenerator
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -534,6 +534,7 @@ files:
534
534
  - docs/how_to/change_terminal_output_coloring.md
535
535
  - docs/how_to/confine.md
536
536
  - docs/how_to/hosts/README.md
537
+ - docs/how_to/hosts/archlinux.md
537
538
  - docs/how_to/hosts/cisco.md
538
539
  - docs/how_to/hosts/eos.md
539
540
  - docs/how_to/hypervisors/README.md
@@ -548,6 +549,7 @@ files:
548
549
  - docs/how_to/hypervisors/vagrant_libvirt.md
549
550
  - docs/how_to/hypervisors/vmware_fusion.md
550
551
  - docs/how_to/hypervisors/vsphere.md
552
+ - docs/how_to/install_puppet.md
551
553
  - docs/how_to/platform_specific_tag_confines.md
552
554
  - docs/how_to/preserve_hosts.md
553
555
  - docs/how_to/rake_tasks.md
@@ -577,7 +579,6 @@ files:
577
579
  - lib/beaker/dsl.rb
578
580
  - lib/beaker/dsl/assertions.rb
579
581
  - lib/beaker/dsl/helpers.rb
580
- - lib/beaker/dsl/helpers/facter_helpers.rb
581
582
  - lib/beaker/dsl/helpers/hocon_helpers.rb
582
583
  - lib/beaker/dsl/helpers/host_helpers.rb
583
584
  - lib/beaker/dsl/helpers/puppet_helpers.rb
@@ -687,7 +688,6 @@ files:
687
688
  - spec/beaker/command_spec.rb
688
689
  - spec/beaker/dsl/assertions_spec.rb
689
690
  - spec/beaker/dsl/ezbake_utils_spec.rb
690
- - spec/beaker/dsl/helpers/facter_helpers_spec.rb
691
691
  - spec/beaker/dsl/helpers/host_helpers_spec.rb
692
692
  - spec/beaker/dsl/helpers/puppet_helpers_spec.rb
693
693
  - spec/beaker/dsl/helpers/test_helpers_spec.rb
@@ -1,57 +0,0 @@
1
- module Beaker
2
- module DSL
3
- module Helpers
4
- # Methods that help you interact with your facter installation, facter must be installed
5
- # for these methods to execute correctly
6
- #
7
- module FacterHelpers
8
-
9
- # @!macro [new] common_opts
10
- # @param [Hash{Symbol=>String}] opts Options to alter execution.
11
- # @option opts [Boolean] :silent (false) Do not produce log output
12
- # @option opts [Array<Fixnum>] :acceptable_exit_codes ([0]) An array
13
- # (or range) of integer exit codes that should be considered
14
- # acceptable. An error will be thrown if the exit code does not
15
- # match one of the values in this list.
16
- # @option opts [Boolean] :accept_all_exit_codes (false) Consider all
17
- # exit codes as passing.
18
- # @option opts [Boolean] :dry_run (false) Do not actually execute any
19
- # commands on the SUT
20
- # @option opts [String] :stdin (nil) Input to be provided during command
21
- # execution on the SUT.
22
- # @option opts [Boolean] :pty (false) Execute this command in a pseudoterminal.
23
- # @option opts [Boolean] :expect_connection_failure (false) Expect this command
24
- # to result in a connection failure, reconnect and continue execution.
25
- # @option opts [Hash{String=>String}] :environment ({}) These will be
26
- # treated as extra environment variables that should be set before
27
- # running the command.
28
- #
29
-
30
- # Get a facter fact from a provided host
31
- #
32
- # @param [Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
33
- # or a role (String or Symbol) that identifies one or more hosts.
34
- # @param [String] name The name of the fact to query for
35
- # @!macro common_opts
36
- #
37
- # @return String The value of the fact 'name' on the provided host
38
- # @raise [FailTest] Raises an exception if call to facter fails
39
- def fact_on(host, name, opts = {})
40
- result = on host, facter(name, opts)
41
- if result.kind_of?(Array)
42
- result.map { |res| res.stdout.chomp }
43
- else
44
- result.stdout.chomp
45
- end
46
- end
47
-
48
- # Get a facter fact from the default host
49
- # @see #fact_on
50
- def fact(name, opts = {})
51
- fact_on(default, name, opts)
52
- end
53
-
54
- end
55
- end
56
- end
57
- end
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class ClassMixedWithDSLHelpers
4
- include Beaker::DSL::Helpers
5
- include Beaker::DSL::Wrappers
6
- include Beaker::DSL::Roles
7
- include Beaker::DSL::Patterns
8
-
9
- def logger
10
- RSpec::Mocks::Double.new('logger').as_null_object
11
- end
12
-
13
- end
14
-
15
- describe ClassMixedWithDSLHelpers do
16
- let( :command ){ 'ls' }
17
- let( :host ) { double.as_null_object }
18
- let( :result ) { Beaker::Result.new( host, command ) }
19
-
20
- let( :master ) { make_host( 'master', :roles => %w( master agent default) ) }
21
- let( :agent ) { make_host( 'agent', :roles => %w( agent ) ) }
22
- let( :custom ) { make_host( 'custom', :roles => %w( custom agent ) ) }
23
- let( :dash ) { make_host( 'console', :roles => %w( dashboard agent ) ) }
24
- let( :db ) { make_host( 'db', :roles => %w( database agent ) ) }
25
- let( :hosts ) { [ master, agent, dash, db, custom ] }
26
-
27
-
28
- describe '#fact_on' do
29
- it 'retrieves a fact on a single host' do
30
- result.stdout = "family\n"
31
- expect( subject ).to receive(:facter).with('osfamily',{}).once
32
- expect( subject ).to receive(:on).and_return(result)
33
-
34
- expect( subject.fact_on('host','osfamily') ).to be === result.stdout.chomp
35
- end
36
-
37
- it 'retrieves an array of facts from multiple hosts' do
38
- allow( subject ).to receive( :hosts ).and_return( hosts )
39
- times = hosts.length
40
- result.stdout = "family\n"
41
- hosts.each do |host|
42
- expect( host ).to receive(:exec).and_return(result)
43
- end
44
-
45
- expect( subject.fact_on(hosts,'osfamily') ).to be === [result.stdout.chomp] * hosts.length
46
-
47
- end
48
- end
49
-
50
- describe '#fact' do
51
- it 'delegates to #fact_on with the default host' do
52
- allow( subject ).to receive(:hosts).and_return(hosts)
53
- expect( subject ).to receive(:fact_on).with(master,"osfamily",{}).once
54
-
55
- subject.fact('osfamily')
56
- end
57
- end
58
-
59
- end