kitchen-ansible 0.50.1 → 0.55.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: 12f00ffe0cf6ec8436074b5fffcfbf108a8b382a6f5b0ea916214bbc139a8994
4
- data.tar.gz: 5ccb79c952524c5dc2388a89459b8c3c0b2265a9cf4f0fc4b534b3e1008efb4c
3
+ metadata.gz: 3b1b9ed5296c5ccc0a6c0de5ed5dffda713e3cdfd36c835d6911591a89d92c40
4
+ data.tar.gz: 39ee501a044573823c5b1bf321d15d81ce9a557446ff664c917216f54723b21f
5
5
  SHA512:
6
- metadata.gz: 8d8b98e8cc45cf4f18c4b291af31e8dea39748ef0a1110af663508eb9714f82e0f4f7c14cdad2d60bed6e2600b84da51a2b57c43fa12187c090dccf4fefd7f6f
7
- data.tar.gz: 4c9cfc4c83fe4a99bbf86cca8c0a1cd69dfea00838b9a5df2bbe056e3f6c22c3dcea3daaa7babf885c8fd5b09eb1372e666b1bba9938f868b92078313df362ee
6
+ metadata.gz: 5c51f85d84585dbb8c888be34d11b877ec954de08230816767ac9754360798655b4a69f3414aebc6f415ed034dc21715ac35364ee1c0f74ad2a30343a90ab982
7
+ data.tar.gz: beecbbc16b179865e4e7123860462101857151105f8697821618f8feb21406ff241fe9dd61b4e737d64d4d4d6af7cb0471804ec0ef81eb5fdd2986df7ce8ecce
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Kitchen
3
3
  module Ansible
4
- VERSION = '0.50.1'.freeze
4
+ VERSION = '0.55.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
@@ -57,13 +57,17 @@ module Kitchen
57
57
  ## 10.04, 12.04 include add-apt-repository in
58
58
  if [apt-cache pkgnames | grep -q 'python-software-properties']; then
59
59
  #{sudo_env('apt-get')} -y install python-software-properties
60
- fi
60
+ fi
61
61
 
62
62
  ## 10.04 version of add-apt-repository doesn't accept --yes
63
63
  ## later versions require interaction from user, so we must specify --yes
64
64
  ## First try with -y flag, else if it fails, try without.
65
65
  ## "add-apt-repository: error: no such option: -y" is returned but is ok to ignore, we just retry
66
- #{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
67
71
  fi
68
72
  #{sudo_env('apt-get')} update
69
73
  #{sudo_env('apt-get')} -y install ansible#{ansible_debian_version}
@@ -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(' ')
@@ -835,7 +888,16 @@ module Kitchen
835
888
 
836
889
  def extra_vars_file
837
890
  return nil if config[:extra_vars_file].nil?
838
- bash_extra_vars = "-e '\@#{config[:extra_vars_file]}'"
891
+ bash_extra_vars = ''
892
+ if config[:extra_vars_file].is_a?(String)
893
+ bash_extra_vars = "-e '\@#{config[:extra_vars_file]}'"
894
+ elsif config[:extra_vars_file].is_a?(Array)
895
+ config[:extra_vars_file].each { |x|
896
+ info("Adding -e '\@#{x}'")
897
+ bash_extra_vars += " -e '\@#{x}'"
898
+ }
899
+ end
900
+
839
901
  debug(bash_extra_vars)
840
902
  bash_extra_vars
841
903
  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.
@@ -66,7 +72,7 @@ custom_post_play_command | nil | Custom shell command to be used after the ansib
66
72
  enable_yum_epel | false | Enable the `yum` EPEL repo
67
73
  env_vars | Hash.new | Hash to set environment variable to use with `ansible-playbook` command
68
74
  extra_vars | Hash.new | Hash to set the `extra_vars` passed to `ansible-playbook` command
69
- extra_vars_file | nil | file containing environment variables e.g. `private_vars/production.yml site.yml` Don't prefix with a @ sign.
75
+ extra_vars_file | nil | String containing a filename or an Array of filenames containing environment variables e.g. `private_vars/production.yml` or `[file1.yml, file2.yml]` Don't prefix with a @ sign.
70
76
  filter_plugins_path | filter_plugins | Ansible repo `filter_plugins` directory
71
77
  galaxy_ignore_certs | false | Ignore certificate errors when installing roles with ansible-galaxy.
72
78
  group_vars_path | group_vars | Ansible repo group_vars directory
@@ -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.1
4
+ version: 0.55.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-07-23 00:00:00.000000000 Z
11
+ date: 2021-04-03 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.1
134
+ rubygems_version: 3.1.4
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: ansible provisioner for test-kitchen