kitchen-ansible 0.50.0 → 0.54.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7ad611fbb31e8722a7867348c3ed91580a66b85f1458ae44217396dac67509c
4
- data.tar.gz: da95ffe993c35e40964c8c8eb4a367309c937b0b705c9145823766d528f13746
3
+ metadata.gz: 14915690b90c67925cde829c63de6b9198162986fc2637283f075ea7b37dc4c0
4
+ data.tar.gz: 86eca88881b0d5c2deb47a877576cc00ccf22e7cbf03cbd67782886bda64b54f
5
5
  SHA512:
6
- metadata.gz: fb4fc3b33307eeacf64eae37da8ae10f8b9604256db742a662345bb8727efc9c7f6cdd67af73ec783bb3a198595203952d8c07ec13226ecb67cd1656791e6c9d
7
- data.tar.gz: 8c651db78e32cf1cdbb655961f8ce86119ec2182f32863b8a2348820713c78288aa35225dbaf1be37395cdf70c3a0923e419effdcfd8a3e3e97af0309f259d5f
6
+ metadata.gz: 5952847769f6d7bca3b015d6b9853d29726d1a47d0d24390ffd1ab52ac1cb663efd9abd97bdb2c0f7863683ea7c30287e80804a7f5cdf9dc770cf838330a34b6
7
+ data.tar.gz: d9c508902611e6716e14e07813dd9ed1057db8d2e09306134d1d39afd06bd574461e82fef3afb20b2d5b2b807dee33182e7f8dff1fa830a00f730905c40e1ab8
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Kitchen
3
3
  module Ansible
4
- VERSION = '0.50.0'.freeze
4
+ VERSION = '0.54.0'.freeze
5
5
  end
6
6
  end
@@ -54,7 +54,9 @@ module Kitchen
54
54
  default_config :require_ruby_for_busser, false
55
55
  default_config :require_windows_support, false
56
56
  default_config :require_pip, false
57
+ default_config :require_pip3, false
57
58
  default_config :requirements_path, false
59
+ default_config :requirements_collection_path, false
58
60
  default_config :ssh_known_hosts, nil
59
61
  default_config :additional_ssh_private_keys, nil
60
62
  default_config :ansible_verbose, false
@@ -103,6 +105,12 @@ module Kitchen
103
105
  fail('No roles_path detected. Please specify one in .kitchen.yml')
104
106
  end
105
107
 
108
+ default_config :ansible_binary_path do |provisioner|
109
+ if provisioner[:require_pip3]
110
+ fail('No ansible_binary_path detected. Please specify one in .kitchen.yml')
111
+ end
112
+ end
113
+
106
114
  default_config :group_vars_path do |provisioner|
107
115
  provisioner.calculate_path('group_vars', :directory)
108
116
  end
@@ -28,10 +28,18 @@ module Kitchen
28
28
  if [ ! $(which ansible) ]; then
29
29
  #{install_epel_repo}
30
30
  #{sudo_env('yum-config-manager')} --enable epel/x86_64
31
- #{sudo_env('yum')} -y install #{ansible_package_name} git
32
- #{sudo_env('alternatives')} --set python /usr/bin/python2.6
33
- #{sudo_env('yum')} clean all
34
- #{sudo_env('yum')} install yum-python26 -y
31
+ #{sudo_env('yum')} -y install git
32
+
33
+ if `grep -q "Amazon Linux AMI" /etc/os-release`; then
34
+ ## Amazon Linux 1
35
+ #{sudo_env('yum')} -y install #{ansible_package_name}
36
+ #{sudo_env('alternatives')} --set python /usr/bin/python2.6
37
+ #{sudo_env('yum')} clean all
38
+ #{sudo_env('yum')} install yum-python26 -y
39
+ else
40
+ ## Amazon Linux 2
41
+ #{sudo_env('amazon-linux-extras')} install -y ansible2
42
+ fi
35
43
  fi
36
44
  INSTALL
37
45
  end
@@ -55,13 +55,19 @@ module Kitchen
55
55
  #{sudo_env('apt-get')} -y install software-properties-common
56
56
 
57
57
  ## 10.04, 12.04 include add-apt-repository in
58
- #{sudo_env('apt-get')} -y install python-software-properties
58
+ if [apt-cache pkgnames | grep -q 'python-software-properties']; then
59
+ #{sudo_env('apt-get')} -y install python-software-properties
60
+ fi
59
61
 
60
62
  ## 10.04 version of add-apt-repository doesn't accept --yes
61
63
  ## later versions require interaction from user, so we must specify --yes
62
64
  ## First try with -y flag, else if it fails, try without.
63
65
  ## "add-apt-repository: error: no such option: -y" is returned but is ok to ignore, we just retry
64
- #{sudo_env('add-apt-repository')} -y #{@config[:ansible_apt_repo]} || #{sudo_env('add-apt-repository')} #{@config[:ansible_apt_repo]}
66
+ ## There is no official Ubuntu 20.04 ansible release in the ppa, but Ubuntu has a package with the latest 2.9 Ansible
67
+ ## This "fixes" issue #321 for now
68
+ if ! `grep -q 'VERSION_ID=\"20.04\"' /etc/os-release`; then
69
+ #{sudo_env('add-apt-repository')} -y #{@config[:ansible_apt_repo]} || #{sudo_env('add-apt-repository')} #{@config[:ansible_apt_repo]}
70
+ fi
65
71
  fi
66
72
  #{sudo_env('apt-get')} update
67
73
  #{sudo_env('apt-get')} -y install ansible#{ansible_debian_version}
@@ -29,7 +29,13 @@ module Kitchen
29
29
  if [ ! $(which ansible) ]; then
30
30
  #{redhat_yum_repo}
31
31
  #{update_packages_command}
32
- #{sudo_env('dnf')} -y install #{ansible_package_name} libselinux-python git python2-dnf
32
+ FEDORA_RELEASE=$(rpm --query --queryformat="%{VERSION}" --file /etc/fedora-release)
33
+
34
+ if [ ${FEDORA_RELEASE} -le 28 ]; then
35
+ #{sudo_env('dnf')} -y install #{ansible_package_name} libselinux-python git python2-dnf
36
+ else
37
+ #{sudo_env('dnf')} -y install #{ansible_package_name} python3-libselinux git python3-dnf
38
+ fi
33
39
  fi
34
40
  INSTALL
35
41
  end
@@ -29,7 +29,13 @@ module Kitchen
29
29
  #{install_epel_repo}
30
30
  #{redhat_yum_repo}
31
31
  #{update_packages_command}
32
- #{sudo_env('yum')} -y install #{ansible_package_name} libselinux-python git
32
+ EL_RELEASE=$(rpm -E %{rhel})
33
+
34
+ if [ "${EL_RELEASE}" -lt 8 ]; then
35
+ #{sudo_env('yum')} -y install #{ansible_package_name} libselinux-python git
36
+ else
37
+ #{sudo_env('yum')} -y install #{ansible_package_name} python3-libselinux git
38
+ fi
33
39
  fi
34
40
  INSTALL
35
41
  end
@@ -76,6 +76,9 @@ module Kitchen
76
76
  elsif config[:require_pip]
77
77
  info('Installing ansible through pip')
78
78
  cmd = install_ansible_from_pip_command
79
+ elsif config[:require_pip3]
80
+ info('Installing ansible through pip3')
81
+ cmd = install_ansible_from_pip3_command
79
82
  elsif config[:require_ansible_repo]
80
83
  if !@os.nil?
81
84
  info("Installing ansible on #{@os.name}")
@@ -87,7 +90,7 @@ module Kitchen
87
90
  if [ ! $(which ansible) ]; then
88
91
  if [ -f /etc/fedora-release ]; then
89
92
  #{Kitchen::Provisioner::Ansible::Os::Fedora.new('fedora', config).install_command}
90
- elif [ -f /etc/system-release ] && [ `grep -q 'Amazon Linux' /etc/system-release` ]; then
93
+ elif [ -f /etc/system-release ] && `grep -q 'Amazon Linux' /etc/system-release`; then
91
94
  #{Kitchen::Provisioner::Ansible::Os::Amazon.new('amazon', config).install_command}
92
95
  elif [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then
93
96
  #{Kitchen::Provisioner::Ansible::Os::Redhat.new('redhat', config).install_command}
@@ -264,7 +267,7 @@ module Kitchen
264
267
  end
265
268
 
266
269
  def init_command
267
- dirs = %w(modules roles group_vars host_vars)
270
+ dirs = %w(modules roles group_vars host_vars collections)
268
271
  .map { |dir| File.join(config[:root_path], dir) }.join(' ')
269
272
  cmd = "#{sudo_env('rm')} -rf #{dirs};"
270
273
  cmd += " mkdir -p #{config[:root_path]}"
@@ -308,7 +311,7 @@ module Kitchen
308
311
  commands = []
309
312
 
310
313
  commands << [
311
- "if [ $(uname -s) == 'FreeBSD' ]; then ETC_ANSIBLE='/usr/local/etc/ansible'; else ETC_ANSIBLE='/etc/ansible'; fi"
314
+ "if [ $(uname -s) = 'FreeBSD' ]; then ETC_ANSIBLE='/usr/local/etc/ansible'; else ETC_ANSIBLE='/etc/ansible'; fi"
312
315
  ]
313
316
  # Prevent failure when ansible package installation doesn't contain /etc/ansible
314
317
  commands << [
@@ -373,6 +376,10 @@ module Kitchen
373
376
  commands << ansible_galaxy_command
374
377
  end
375
378
 
379
+ if galaxy_requirements_collections
380
+ commands << ansible_galacy_collection_command
381
+ end
382
+
376
383
  if kerberos_conf_file
377
384
  commands << [
378
385
  sudo_env('cp -f'), File.join(config[:root_path], 'krb5.conf'), '/etc'
@@ -473,6 +480,18 @@ module Kitchen
473
480
  cmd
474
481
  end
475
482
 
483
+ def ansible_galacy_collection_command
484
+ cmd = [
485
+ 'ansible-galaxy', 'collection', 'install', '--force',
486
+ '-p', File.join(config[:root_path], 'collections'),
487
+ '-r', File.join(config[:root_path], galaxy_requirements_collections)
488
+ ].join(' ')
489
+ cmd = "https_proxy=#{https_proxy} #{cmd}" if https_proxy
490
+ cmd = "http_proxy=#{http_proxy} #{cmd}" if http_proxy
491
+ cmd = "no_proxy=#{no_proxy} #{cmd}" if no_proxy
492
+ cmd
493
+ end
494
+
476
495
  def cd_ansible
477
496
  # this is not working so just return nil for now
478
497
  # File.exist?('ansible.cfg') ? "cd #{config[:root_path]};" : nil
@@ -546,6 +565,36 @@ module Kitchen
546
565
  INSTALL
547
566
  end
548
567
 
568
+ def install_ansible_from_pip3_command
569
+ if config[:ansible_version]=='latest' or config[:ansible_version].nil?
570
+ ansible_version = ''
571
+ else
572
+ ansible_version = "==#{config[:ansible_version]}"
573
+ end
574
+ <<-INSTALL
575
+ if [ ! $(which ansible) ]; then
576
+ if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then
577
+ #{Kitchen::Provisioner::Ansible::Os::Redhat.new('redhat', config).install_epel_repo}
578
+ #{update_packages_redhat_cmd} > #{detect_debug}
579
+ #{sudo_env('yum')} -y install python3-libselinux python3-devel python3-pip git libffi-devel openssl-devel gcc > #{detect_debug}
580
+ else
581
+ if [ -f /etc/SUSE-brand ] || [ -f /etc/SuSE-release ]; then
582
+ #{sudo_env('zypper')} ar #{python_sles_repo} > #{detect_debug}
583
+ #{update_packages_suse_cmd} > #{detect_debug}
584
+ #{sudo_env('zypper')} --non-interactive install python python-devel git python-setuptools python-pip python-six libyaml-devel libffi-devel libopenssl-devel > #{detect_debug}
585
+ else
586
+ #{update_packages_debian_cmd} > #{detect_debug}
587
+ #{sudo_env('apt-get')} -y install git python python-pip python-setuptools build-essential python-dev libffi-dev libssl-dev > #{detect_debug}
588
+ fi
589
+ fi
590
+
591
+ #{export_http_proxy}
592
+ #{sudo_env('pip3')} install -U setuptools > #{detect_debug}
593
+ #{sudo_env('pip3')} install ansible#{ansible_version} > #{detect_debug}
594
+ fi
595
+ INSTALL
596
+ end
597
+
549
598
  def install_omnibus_command
550
599
  info('Installing ansible using ansible omnibus')
551
600
 
@@ -629,6 +678,10 @@ module Kitchen
629
678
  config[:requirements_path] || nil
630
679
  end
631
680
 
681
+ def galaxy_requirements_collections
682
+ config[:requirements_collection_path] || nil
683
+ end
684
+
632
685
  def env_vars
633
686
  return nil if config[:env_vars].none?
634
687
  config[:env_vars].map { |k, v| "#{k}=#{v}" }.join(' ')
@@ -921,10 +974,10 @@ module Kitchen
921
974
  roles_paths << File.join(config[:root_path], 'roles') unless config[:roles_path].nil?
922
975
  if config[:additional_copy_role_path]
923
976
  if config[:additional_copy_role_path].is_a? String
924
- roles_paths << File.join(config[:root_path], File.basename(config[:additional_copy_role_path]))
977
+ roles_paths << File.join(config[:root_path], 'roles', File.basename(config[:additional_copy_role_path]))
925
978
  else
926
979
  config[:additional_copy_role_path].each do |path|
927
- roles_paths << File.join(config[:root_path], File.basename(File.expand_path(path)))
980
+ roles_paths << File.join(config[:root_path], 'roles', File.basename(File.expand_path(path)))
928
981
  end
929
982
  end
930
983
  end
@@ -952,12 +1005,12 @@ module Kitchen
952
1005
  if config[:additional_copy_role_path]
953
1006
  if config[:additional_copy_role_path].is_a? String
954
1007
  debug("Using additional roles copy from #{File.expand_path(config[:additional_copy_role_path])}")
955
- dest = File.join(sandbox_path, File.basename(File.expand_path(config[:additional_copy_role_path])))
1008
+ dest = File.join(sandbox_path, 'roles', File.basename(File.expand_path(config[:additional_copy_role_path])))
956
1009
  FileUtils.mkdir_p(File.dirname(dest))
957
1010
  FileUtils.cp_r(File.expand_path(config[:additional_copy_role_path]), dest)
958
1011
  else
959
1012
  config[:additional_copy_role_path].each do |path|
960
- dest = File.join(sandbox_path, File.basename(File.expand_path(path)))
1013
+ dest = File.join(sandbox_path, 'roles', File.basename(File.expand_path(path)))
961
1014
  FileUtils.mkdir_p(File.dirname(dest))
962
1015
  FileUtils.cp_r(File.expand_path(path), dest)
963
1016
  end
@@ -16,6 +16,12 @@ It installs it in the following order:
16
16
 
17
17
  Install require packages and then installs ansible using the python pip command and ansible version must be specified. This allows a specific version of ansible to be installed.
18
18
 
19
+ * if require_pip3 is set to true
20
+
21
+ Install require packages and then installs ansible using the python pip3 command and ansible version must be specified. This allows a specific version of ansible to be installed.
22
+
23
+ Currently only works for Redhat/Centos.
24
+
19
25
  * if require_ansible_repo is set to true (the default)
20
26
 
21
27
  Installs from the operation system repository only with the ansible version that is in the particular repository and will use the ansible_version in the package name where appropriate.
@@ -95,9 +101,11 @@ require_ansible_repo | true | Set if installing Ansible from a `yum` or `apt` re
95
101
  require_ansible_source | false | Install Ansible from source using method described [here](http://docs.ansible.com/intro_installation.html#running-from-source). Only works on Debian/Ubuntu at present
96
102
  require_chef_for_busser | true | Install Chef to run Busser for tests. NOTE: kitchen 1.4 only requires Ruby to run Busser so this is not required.
97
103
  require_pip | false | Set to `true` if Ansible is to be installed through `pip`).
104
+ require_pip3 | false | Set to `true` if Ansible is to be installed through `pip3`).
98
105
  require_ruby_for_busser | false | Install Ruby to run Busser for tests
99
106
  require_windows_support | false | Install [Windows support](http://docs.ansible.com/ansible/intro_windows.html)
100
107
  requirements_path | | Path to Ansible Galaxy requirements
108
+ requirements_collection_path | | Path to Ansible Galaxy requirements
101
109
  retry_on_exit_code | [] | Array of exit codes to retry converge command against
102
110
  role_name | | use when the repo name does not match the name the role is published as.
103
111
  roles_path | roles | Ansible repo roles directory
@@ -109,6 +117,19 @@ update_package_repos | true | Update OS repository metadata
109
117
  wait_for_retry | 30 | number of seconds to wait before retrying converge command
110
118
  ignore_ansible_cfg | false | If true, values from ansible.cfg file will not be loaded.
111
119
 
120
+ ## require_pip3
121
+
122
+ if using python 3 and wish to install via pip specify
123
+ ```yaml
124
+ ansible_binary_path: /usr/local/bin
125
+ require_pip3: true
126
+ ```
127
+
128
+
129
+ you must specify ansible_binary_path as well.
130
+
131
+ Currently this only works for Centos and Redhat
132
+
112
133
  ## Ansible Inventory
113
134
 
114
135
  Ansible has the concept of an [inventory](http://docs.ansible.com/ansible/latest/intro_inventory.html).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.50.0
4
+ version: 0.54.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neill Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-12 00:00:00.000000000 Z
11
+ date: 2020-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.0.3
134
+ rubygems_version: 3.1.4
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: ansible provisioner for test-kitchen