kitchen-ansible 0.0.34 → 0.0.35

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
  SHA1:
3
- metadata.gz: 383772e19dae10c7d068e546b69d07d6953ee1a2
4
- data.tar.gz: 7a40e84ce0e131f6cb6bfefa4798ebea0a5ec637
3
+ metadata.gz: 9c1404af95d22c9d268d6c13d457f491b8017a38
4
+ data.tar.gz: 24763d73aa7e307f4118037180e2afe6310d6ee4
5
5
  SHA512:
6
- metadata.gz: f20a609cbc3b8032e0d04717b8ce2eb87fc341d354db705f16252105ba992cb86c2f71c87b94908f4db3e6d7d3d729878569f6684d7ac6cb2d494b05c1193172
7
- data.tar.gz: 50dbedb9520c1527a94341eecd0f20ffa19417e00b563d98fdec33ded9312a866cd4260e04b561573bc19e8bb02e04a380305731221220c7f6bd44807fdd4153
6
+ metadata.gz: c8b3bb1a6cfa884921d5cd166408751e3e9a8af90a0ef960abe16c983531170ae7273d21c3041f53ad17f280dfcd6faa3c47cd8fcadb4b9472982a2731f64ca6
7
+ data.tar.gz: 58b357b98ca0d506191075260e5eb8f0ed6f2fd1efc15a2d4355a6a29f924a6f5d31b4d6ae64e3892d533f4dcb12df6432f0a58864691f7f5ab1c774c2495520
data/README.md CHANGED
@@ -56,21 +56,21 @@ platforms:
56
56
 
57
57
  ## Ruby install to run serverspec verify
58
58
 
59
- By default test-kitchen installs chef to get a ruby version sutable for run serverspec in the Verify step.
59
+ By default test-kitchen installs chef to get a ruby version suitable to run serverspec in the `verify` step.
60
+ Instead ruby can just be installed by specifying the provisioner option:
60
61
 
61
- Instead ruby can just be installed by specifing the provisioner option:
62
62
  ```
63
- require_ruby_for_busser false
63
+ require_ruby_for_busser: false
64
64
  ```
65
- And set the verifer section:
65
+ And set the verifier section:
66
66
  ```
67
67
  verifier:
68
- name: Busser
68
+ name: busser
69
69
  plugin:
70
70
  - Ansiblespec
71
71
  ruby_bindir: '/usr/bin'
72
72
  ```
73
- and create a Gemfile to add additionl ruby gems in directory test/integration/default/ansiblespec
73
+ Then create a Gemfile in directory `test/integration/default/ansiblespec` to add additional ruby gems:
74
74
  ```
75
75
  source 'https://rubygems.org'
76
76
 
@@ -99,29 +99,26 @@ Serverspec uses ssh to communicate with the server to be tested and reads the an
99
99
  ### Example usage to create tomcat servers:
100
100
 
101
101
  ```
102
- TOMCAT SERVERS
103
- TEST KITCHEN ANSIBLE AND SERVERSPEC
104
- WORKSTATION SERVER +------------------------+
105
- +-----------------------+ | +---------+ |
106
- | | | |Tomcat | |
107
- +-------------------+ | +----------------> | | |
108
- | | | | | | +---------+ |
109
- | Workstation | | | | +-------> |
110
- | test-kitchen | | | | | | |
111
- | kitchen-ansible| | | | | | |
112
- | | create| | | | +------------------------+
113
- | CREATE +---------------> install | | |
114
- | | server| and run | | |
115
- | CONVERGE+-------------------->ANSIBLE +---+ | | +------------------------+
116
- | | | +--------------------> +----------+ |
117
- | | | install and run | | | |Tomcat | |
118
- | VERIFY+------------------>Busser-ansiblespec +-------+ | | | |
119
- +-------------------+ | + | | | +----------+ |
120
- | +--->ServerSpec +---------------> |
121
- | | | |
122
- +-----------------------+ | |
123
- +------------------------+
124
-
102
+ TEST KITCHEN ANSIBLE AND SERVERSPEC TOMCAT SERVER
103
+ WORKSTATION SERVER (built and destroyed (created separately
104
+ (or Jenkins CI) automatically) could be docker container)
105
+ +----------------------------+
106
+ +-------------------+ | | +-----------------------+
107
+ | test kitchen | | | | |
108
+ | kitchen-ansible | create | | | |
109
+ | | ser^er | | | +-----------+ |
110
+ | CREATE +------------> +----------+ | | | tomcat | |
111
+ | | | | | | install | | |
112
+ | | install and run | ansible +---------------> | |
113
+ | CONVERGE +------------+---------------> | | tomcat +-----------+ |
114
+ | | | +----------+ | | |
115
+ | | install| +----------+ +---------+ | test |
116
+ | VERIFY +--------------->busser- |-->serverspec--------+----> |
117
+ | |and run | |ansiblespec | | | | |
118
+ | | | +----------+ +---------+ | +-----------------------+
119
+ | DESTROY +------------> |
120
+ +-------------------+ delete +----------------------------+
121
+ server
125
122
 
126
123
  * All connections over SSH
127
124
 
@@ -184,10 +181,11 @@ require 'net/ssh'
184
181
 
185
182
  RSpec.configure do |config|
186
183
  set :host, ENV['TARGET_HOST']
184
+ # ssh options at http://net-ssh.github.io/ssh/v1/chapter-2.html
187
185
  # ssh via password
188
- set :ssh_options, :user => 'root', :password => ENV['LOGIN_PASSWORD'] if ENV['LOGIN_PASSWORD']
186
+ set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :password => ENV['LOGIN_PASSWORD'] if ENV['LOGIN_PASSWORD']
189
187
  # ssh via ssh key
190
- set :ssh_options, :user => 'root', :host_key => 'ssh-rsa', :keys => [ ENV['SSH_KEY'] ] if ENV['SSH_KEY']
188
+ set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :host_key => 'ssh-rsa', :keys => [ ENV['SSH_KEY'] ] if ENV['SSH_KEY']
191
189
  set :backend, :ssh
192
190
  set :request_pty, true
193
191
  end
@@ -204,6 +202,7 @@ This goes in directory test/integration/default/ansiblespec where default is th
204
202
  inventory: hosts
205
203
  kitchen_path: '/tmp/kitchen'
206
204
  pattern: 'ansiblespec' # or spec or serverspec
205
+ user: root
207
206
  ssh_key: 'spec/my_private_key.pem'
208
207
  login_password: 'myrootpassword'
209
208
  ```
@@ -42,7 +42,7 @@ module Kitchen
42
42
  default_config :extra_vars, {}
43
43
  default_config :tags, []
44
44
  default_config :ansible_apt_repo, 'ppa:ansible/ansible'
45
- default_config :ansible_yum_repo, 'https://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'
45
+ default_config :ansible_yum_repo, nil
46
46
  default_config :ansible_sles_repo, 'http://download.opensuse.org/repositories/systemsmanagement/SLE_12/systemsmanagement.repo'
47
47
  default_config :python_sles_repo, 'http://download.opensuse.org/repositories/devel:/languages:/python/SLE_12/devel:languages:python.repo'
48
48
  default_config :chef_bootstrap_url, 'https://www.getchef.com/chef/install.sh'
@@ -64,8 +64,7 @@ module Kitchen
64
64
  default_config :https_proxy, nil
65
65
  default_config :no_proxy, nil
66
66
  default_config :ansible_playbook_command, nil
67
- default_config :ansible_host_key_checking, false
68
- default_config :set_private_key_permissions, false
67
+ default_config :ansible_host_key_checking, true
69
68
  default_config :idempotency_test, nil
70
69
 
71
70
  default_config :playbook do |provisioner|
@@ -46,18 +46,15 @@ module Kitchen
46
46
  end
47
47
 
48
48
  def redhat_yum_repo
49
- if @config[:ansible_yum_repo] == 'https://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'
49
+ if @config[:ansible_yum_repo]
50
50
  <<-INSTALL
51
- rhelversion6=$(cat /etc/redhat-release | grep 'release 6')
52
- if [ -n "$rhelversion6" ]; then
53
- #{sudo_env('rpm')} -ivh 'https://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'
54
- else
55
- #{sudo_env('rpm')} -ivh 'http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm'
56
- fi
51
+ #{sudo_env('rpm')} -ivh #{@config[:ansible_yum_repo]}
57
52
  INSTALL
58
53
  else
59
54
  <<-INSTALL
60
- #{sudo_env('rpm')} -ivh #{@config[:ansible_yum_repo]}
55
+ if ! yum repolist epel | grep -q epel; then
56
+ #{sudo_env('rpm')} -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm -E %dist | sed -n 's/.*el\\([0-9]\\).*/\\1/p'`.noarch.rpm
57
+ fi
61
58
  INSTALL
62
59
  end
63
60
  end
@@ -288,7 +288,7 @@ module Kitchen
288
288
  cmd = "ANSIBLE_HOST_KEY_CHECKING=false #{cmd}" if !ansible_host_key_checking
289
289
 
290
290
  cmd = "#{cd_ansible} #{cmd}" if !config[:ansible_sudo].nil? && !config[:ansible_sudo]
291
- cmd = "chmod 400 #{private_key_file}; #{cmd}" if config[:private_key] && config[:set_private_key_permissions]
291
+ cmd = "#{copy_private_key_cmd} #{cmd}" if config[:private_key]
292
292
 
293
293
  result = [
294
294
  cmd,
@@ -307,7 +307,7 @@ module Kitchen
307
307
  ].join(' ')
308
308
  info("Going to invoke ansible-playbook with: #{result}")
309
309
  if config[:idempotency_test]
310
- result = "#{result} && echo 'Going to invoke ansible-playbook second time:'; #{result} | tee /tmp/idempotency_test.txt; grep -q 'changed=0.*failed=0' /tmp/idempotency_test.txt && (echo 'Idempotence test: PASS' && exit 0) || (echo 'Idempotence test: FAIL' && exit 1)"
310
+ result = "#{result} && (echo 'Going to invoke ansible-playbook second time:'; #{result} | tee /tmp/idempotency_test.txt; grep -q 'changed=0.*failed=0' /tmp/idempotency_test.txt && (echo 'Idempotence test: PASS' && exit 0) || (echo 'Idempotence test: FAIL' && exit 1))"
311
311
  debug("Full cmd with idempotency test: #{result}")
312
312
  end
313
313
 
@@ -379,7 +379,6 @@ module Kitchen
379
379
  if [ ! -d "#{config[:ansible_omnibus_remote_path]}" ]; then
380
380
  echo "-----> Installing Ansible Omnibus"
381
381
  #{export_http_proxy}
382
- #{install_epel_repo}
383
382
  do_download #{config[:ansible_omnibus_url]} /tmp/ansible_install.sh
384
383
  #{sudo_env('sh')} /tmp/ansible_install.sh #{version}
385
384
  fi
@@ -545,11 +544,19 @@ module Kitchen
545
544
  end
546
545
  end
547
546
 
547
+ def copy_private_key_cmd
548
+ if !config[:private_key].start_with?('/') && !config[:private_key].start_with?('~')
549
+ ssh_private_key = File.join('~/.ssh', File.basename(config[:private_key]))
550
+ tmp_private_key = File.join(config[:root_path], config[:private_key])
551
+ "rm -rf #{ssh_private_key}; cp #{tmp_private_key} #{ssh_private_key}; chmod 400 #{ssh_private_key};"
552
+ end
553
+ end
554
+
548
555
  def private_key_file
549
556
  if config[:private_key].start_with?('/') || config[:private_key].start_with?('~')
550
557
  "#{config[:private_key]}"
551
558
  elsif config[:private_key]
552
- "#{File.join(config[:root_path], config[:private_key])}"
559
+ "#{File.join('~/.ssh', File.basename(config[:private_key]))}"
553
560
  end
554
561
  end
555
562
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Kitchen
3
3
  module Ansible
4
- VERSION = '0.0.34'
4
+ VERSION = '0.0.35'
5
5
  end
6
6
  end
@@ -8,8 +8,7 @@ ansible_sudo | true | drives whether ansible-playbook is executed as root or as
8
8
  ansible_platform | naively tries to determine | OS platform of server
9
9
  require_ansible_repo | true | Set if using a ansible install from yum or apt repo
10
10
  ansible_apt_repo | "ppa:ansible/ansible" | apt repo. see https://launchpad.net /~ansible/+archive/ubuntu/ansible or rquillo/ansible
11
- ansible_yum_repo | https://download.fedoraproject.org /pub/epel/6/i386/ epel-release-6-8.noarch.rpm | yum repo RH/Centos6
12
- _for RH/Centos7 is | http://dl.fedoraproject.org /pub/epel/7/x86_64/e/ epel-release-7-5.noarch.rpm |
11
+ ansible_yum_repo | nil | yum repo RH/Centos6
13
12
  ansible_binary_path | NULL | If specified this will override the location where kitchen tries to run ansible-playbook from. ie: (ansible_binary_path: /usr/local/bin )
14
13
  enable_yum_epel | false | enable yum EPEL repo
15
14
  ansible_sles_repo | http://download.opensuse.org/repositories /systemsmanagement/SLE_12 /systemsmanagement.repo | zypper suse ansible repo
@@ -50,7 +49,6 @@ require_ansible_source | false | Install Ansible from source using method descri
50
49
  ansible_source_rev | | Branch or Tag to install ansible source
51
50
  ansible_host_key_checking | true | strict host key checking in ssh
52
51
  private_key | | ssh private key file for ssh connection
53
- set_private_key_permissions | false | set ssh private key file read only permissions
54
52
  idempotency_test | false | Enable to test ansible playbook idempotency
55
53
 
56
54
  ## Configuring Provisioner Options
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.0.34
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neill Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2015-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen