kitchen-ansible 0.0.38 → 0.0.39

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: 2f422d75ddb64f559d4e72b3743f804bfd42811a
4
- data.tar.gz: 5e5e37babc96b86a42603cb1c68fe199db6f0dab
3
+ metadata.gz: cc8e839edd7ff2c945b63d651c20c51abd0e7135
4
+ data.tar.gz: a2be99ad62a1cb475f4c4f89e80b5976a79960b2
5
5
  SHA512:
6
- metadata.gz: dc5b43fb8f86636599610b826f8f0ab6e4b957ca16e2ef430a57f5e6caf7450f8fd28d2814e06bd577907b307bd596152794b5166a27ad6a7a2989bb9f24a1d3
7
- data.tar.gz: 25b2b7b372f529bebb63a50f29127edfe7acab14f17a428dbce19afbd679c51716ea0d4494ee8fe37bd850d8eac86479b773187c24f516befe5dae62935338c2
6
+ metadata.gz: 1a66511b709d9a166ae14633d620f7f8d04ff6572308d41d19d991a5ffb1d6faf0abe04f134f01bd109d3ecfb9f94a1dbcc54b22f388ae3c682ad3e88d794697
7
+ data.tar.gz: 63aca35e02d85e9d8b902c01e472d58da63388f672b62cae9465e28bec04b26f45615297775679844d111fc63717e76c359a97bcb4397a3021d0282242715a41
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Kitchen
3
3
  module Ansible
4
- VERSION = '0.0.38'
4
+ VERSION = '0.0.39'
5
5
  end
6
6
  end
@@ -66,6 +66,9 @@ module Kitchen
66
66
  default_config :ansible_playbook_command, nil
67
67
  default_config :ansible_host_key_checking, true
68
68
  default_config :idempotency_test, nil
69
+ default_config :ansible_inventory, nil
70
+ default_config :ansible_inventory_file, nil
71
+ default_config :ansible_limit, nil
69
72
 
70
73
  default_config :playbook do |provisioner|
71
74
  provisioner.calculate_path('default.yml', :file) ||
@@ -117,10 +120,6 @@ module Kitchen
117
120
  provisioner.calculate_path('ansible-vault-password', :file)
118
121
  end
119
122
 
120
- default_config :ansible_inventory_file do |provisioner|
121
- provisioner.calculate_path('hosts', :file)
122
- end
123
-
124
123
  def initialize(config = {})
125
124
  init_config(config)
126
125
  end
@@ -207,7 +207,7 @@ module Kitchen
207
207
  yield if block_given?
208
208
 
209
209
  prepare_playbook
210
- prepare_inventory_file
210
+ prepare_inventory
211
211
  prepare_modules
212
212
  prepare_roles
213
213
  prepare_ansible_cfg
@@ -257,6 +257,27 @@ module Kitchen
257
257
  end
258
258
  end
259
259
 
260
+ if ansible_inventory
261
+ if File.directory?(ansible_inventory)
262
+ Dir.foreach(ansible_inventory) do |f|
263
+ next if f == "." or f == ".."
264
+ contents = File.open("#{ansible_inventory}/#{f}", 'rb') { |g| g.read }
265
+ if contents.start_with?('#!')
266
+ commands << [
267
+ sudo_env('chmod +x'), File.join("#{config[:root_path]}/#{File.basename(ansible_inventory)}", File.basename(f))
268
+ ].join(' ')
269
+ end
270
+ end
271
+ else
272
+ contents = File.open(ansible_inventory, 'rb') { |f| f.read }
273
+ if contents.start_with?('#!')
274
+ commands << [
275
+ sudo_env('chmod +x'), File.join(config[:root_path], File.basename(ansible_inventory))
276
+ ].join(' ')
277
+ end
278
+ end
279
+ end
280
+
260
281
  if galaxy_requirements
261
282
  if config[:require_ansible_source]
262
283
  commands << setup_ansible_env_from_source
@@ -300,6 +321,7 @@ module Kitchen
300
321
  result = [
301
322
  cmd,
302
323
  ansible_inventory_flag,
324
+ ansible_limit_flag,
303
325
  "-c #{config[:ansible_connection]}",
304
326
  "-M #{File.join(config[:root_path], 'modules')}",
305
327
  ansible_verbose_flag,
@@ -436,8 +458,8 @@ module Kitchen
436
458
  File.join(sandbox_path, File.basename(ansible_vault_password_file).reverse.chomp('.').reverse)
437
459
  end
438
460
 
439
- def tmp_inventory_file_path
440
- File.join(sandbox_path, File.basename(ansible_inventory_file))
461
+ def tmp_inventory_path
462
+ File.join(sandbox_path, File.basename(ansible_inventory))
441
463
  end
442
464
 
443
465
  def ansiblefile
@@ -504,8 +526,14 @@ module Kitchen
504
526
  config[:ansible_vault_password_file]
505
527
  end
506
528
 
507
- def ansible_inventory_file
508
- config[:ansible_inventory_file]
529
+ def ansible_inventory
530
+ config[:ansible_inventory] = config[:ansible_inventory_file] if config[:ansible_inventory].nil?
531
+ info('ansible_inventory_file parameter deprecated use ansible_inventory') if config[:ansible_inventory_file]
532
+ config[:ansible_inventory]
533
+ end
534
+
535
+ def ansible_debian_version
536
+ config[:ansible_version] ? "=#{config[:ansible_version]}" : nil
509
537
  end
510
538
 
511
539
  def ansible_verbose_flag
@@ -526,7 +554,11 @@ module Kitchen
526
554
  end
527
555
 
528
556
  def ansible_inventory_flag
529
- config[:ansible_inventory_file] ? "--inventory-file=#{File.join(config[:root_path], File.basename(config[:ansible_inventory_file]))}" : "--inventory-file=#{File.join(config[:root_path], 'hosts')}"
557
+ config[:ansible_inventory] ? "-i #{File.join(config[:root_path], File.basename(config[:ansible_inventory]))}" : "-i #{File.join(config[:root_path], 'hosts')}"
558
+ end
559
+
560
+ def ansible_limit_flag
561
+ config[:ansible_limit] ? "-l #{config[:ansible_limit]}" : ""
530
562
  end
531
563
 
532
564
  def ansible_extra_flags
@@ -693,19 +725,23 @@ module Kitchen
693
725
  end
694
726
  end
695
727
 
696
- def prepare_inventory_file
697
- info('Preparing inventory file')
698
-
699
- return unless ansible_inventory_file
700
- debug("Copying inventory file from #{ansible_inventory_file} to #{tmp_inventory_file_path}")
701
- FileUtils.cp_r(ansible_inventory_file, tmp_inventory_file_path)
728
+ def prepare_inventory
729
+ info('Preparing inventory')
730
+ return unless ansible_inventory
731
+ if File.directory?(ansible_inventory)
732
+ debug("Copying inventory directory from #{ansible_inventory} to #{tmp_inventory_path}")
733
+ FileUtils.cp_r(ansible_inventory, sandbox_path)
734
+ else
735
+ debug("Copying inventory file from #{ansible_inventory} to #{tmp_inventory_path}")
736
+ FileUtils.cp_r(ansible_inventory, tmp_inventory_path)
737
+ end
702
738
  end
703
739
 
704
740
  # localhost ansible_connection=local
705
741
  # [example_servers]
706
742
  # localhost
707
743
  def prepare_hosts
708
- return if ansible_inventory_file
744
+ return if ansible_inventory
709
745
  info('Preparing hosts file')
710
746
 
711
747
  if config[:hosts].nil?
@@ -39,8 +39,10 @@ ansiblefile_path | | Path to Ansiblefile
39
39
  requirements_path | | Path to ansible-galaxy requirements
40
40
  ansible_vault_password_file| | Path of Ansible Vault Password File
41
41
  ansible_connection | local | use 'ssh' if host not localhost
42
- ansible_inventory_file | hosts | Custom inventory file
43
- ansible_extra_flags | '' | Additional options to pass to `ansible-playbook` -- e.g.: `'--skip-tags=redis'`
42
+ hosts | | create ansible hosts file for localhost with this server group
43
+ ansible_inventory | | Static or dynamic inventory file or directory.
44
+ ansible_limit | | Further limits the selected host/group patterns.
45
+ ansible_extra_flags | | Additional options to pass to `ansible-playbook` -- e.g.: `'--skip-tags=redis'`
44
46
  ansible_playbook_command | | Override the ansible playbook command
45
47
  require_ruby_for_busser|false|install ruby to run busser for tests
46
48
  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.
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.38
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neill Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen