kitchen-ansiblepush 0.3.6 → 0.3.7

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: f868950792eff721e4655c0687470892baa43e53
4
- data.tar.gz: f470fad4ccf0f485d72cb44679d4f552960f7cad
3
+ metadata.gz: 03d8f59a71bbd5d2fb70010c82a1c50298f813d1
4
+ data.tar.gz: 885da6c50f8c699ac1a9194e7ecb1287245c7c10
5
5
  SHA512:
6
- metadata.gz: de09cf33c70ac1bd34c68daee546d01117fbe68a17001bae1067a5800374a31826d6d7ac684aefdbeabe547333fa90f810efaf853b5125dd6cd65424b8a6556e
7
- data.tar.gz: 80a146900bea7fa18356b1280eda4fdc84e0932f691f484bf254fb28b750956e62c4c986cd3bce3395b65752665498bbddd1e7390e26e9be647febde87cf12ae
6
+ metadata.gz: f14fd69023838fc19a25f52f4bb8ed93e4e57e693a43e02b23dcbb538b70d9c212a45b74366e054bc62626d9ea88ecf472f3c26ef6a81094c389a43fabbcee08
7
+ data.tar.gz: 630807fe3647cbfd711e181ef351d4ed1a39318ff50e3e7fc35f4631bbc3ae5d1d208acc714122bb77f4a8521cc89a9146e05fa64750d6e31417ee4164f42abf
data/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  A test-kitchen plugin that adds the support for ansible in push mode
4
4
 
5
- ## TODO
6
- * Tests
7
-
8
5
  ## Intro
9
6
  This kitchen plugin adds ansible as a provisioner in push mode. Ansible will run from your host rather than run from guest machines.
10
7
 
@@ -59,3 +56,8 @@ If you want to check your code is idempotent you can use the idempotency_test. E
59
56
  ```yaml
60
57
  idempotency_test: True
61
58
  ```
59
+
60
+ ## TODO
61
+ - Tests (PRs for tests is highligh appreciated)
62
+
63
+
@@ -2,16 +2,15 @@ import json
2
2
  import os
3
3
  import errno
4
4
 
5
- change_dir = "/tmp/kitchen_ansible_callback"
6
- change_file = change_dir + "/changes"
7
-
8
5
  class CallbackModule(object):
9
6
  def __init__(self):
7
+ self.change_file = os.getenv('PLUGIN_CHANGES_FILE', "/tmp/kitchen_ansible_callback/changes")
8
+ change_dir = os.path.dirname(self.change_file)
10
9
  if not os.path.exists(change_dir):
11
10
  os.makedirs(change_dir)
12
11
 
13
12
  try:
14
- os.remove(change_file)
13
+ os.remove(self.change_file)
15
14
  except OSError as e: # this would be "except OSError, e:" before Python 2.6
16
15
  if e.errno != errno.ENOENT: # errno.ENOENT = no such file or directory
17
16
  raise # re-raise exception if a different error occured
@@ -25,14 +24,14 @@ class CallbackModule(object):
25
24
  changed_data["changed_module_name"] = invocation.get("module_name", "")
26
25
  changed_data["host"] = host
27
26
  if name:
28
- changed_data["task_name"] = name
27
+ changed_data["task_name"] = str(name)
29
28
  changed_data["changed_msg"] = res.get("msg", "")
30
29
 
31
30
  try:
32
- with open(change_file, 'at') as the_file:
31
+ with open(self.change_file, 'at') as the_file:
33
32
  the_file.write(json.dumps(changed_data) + "\n")
34
33
  except Exception, e:
35
- print "Ansible callback idempotency: Write to file failed '%s' error:'%s'" % (change_file, e)
34
+ print "Ansible callback idempotency: Write to file failed '%s' error:'%s'" % (self.change_file, e)
36
35
  exit(1)
37
36
 
38
37
  def on_any(self, *args, **kwargs):
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module AnsiblePush
3
- VERSION = "0.3.6"
3
+ VERSION = "0.3.7"
4
4
  end
5
5
  end
@@ -218,11 +218,12 @@ module Kitchen
218
218
  # idempotency test
219
219
  if conf[:idempotency_test]
220
220
  info("*************** idempotency test ***************")
221
+ file_path = "/tmp/kitchen_ansible_callback/#{SecureRandom.uuid}.changes"
221
222
  exec_ansible_command(command_env().merge({
222
- "ANSIBLE_CALLBACK_PLUGINS" => "#{File.dirname(__FILE__)}/../../../callback/"
223
+ "ANSIBLE_CALLBACK_PLUGINS" => "#{File.dirname(__FILE__)}/../../../callback/",
224
+ "PLUGIN_CHANGES_FILE" => file_path,
223
225
  }), command(), "ansible-playbook")
224
226
  # Check ansible callback if changes has occured in the second run
225
- file_path = "/tmp/kitchen_ansible_callback/changes"
226
227
  if File.file?(file_path)
227
228
  task = 0
228
229
  info("idempotency test [Failed]")
@@ -232,7 +233,7 @@ module Kitchen
232
233
  info(" #{task}> #{line.strip}")
233
234
  end
234
235
  end
235
- raise "idempotency test Failed. Number of non idemptent tasks: #{task}"
236
+ raise "idempotency test Failed. Number of non idempotent tasks: #{task}"
236
237
 
237
238
  else
238
239
  info("idempotency test [passed]")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-ansiblepush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adham Helal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-21 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen