kitchen-ansiblepush 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c2574c5f3a6f5e72041eff1b93bdc9f58b9cdb4
4
- data.tar.gz: 87261f0b8a379618e4b4450bb37a12ab5cf1a7aa
3
+ metadata.gz: 791f46b92aef964ec79f5ad49b1c70dbf9314b91
4
+ data.tar.gz: f1c1fc8f780e5eed9c40347deb9a8c2d7c575408
5
5
  SHA512:
6
- metadata.gz: d203dcf0add9038341bdab6b1edef6e90709d45576e639706697f39513037382066c3a6e7d575c93b7e702a22ddbb445f56c1d857ed73db5208cc29cb1853922
7
- data.tar.gz: b145ccbb8a988f4000b45459d91cd72590190fd0c9e3a4ee4615a96b0ad2078184f01d033d0912c5246b865101e87406f23052693169f013de6f2f14f37dde04
6
+ metadata.gz: 7dc39035080f59926a04488643dc53b57e531d69a31f59e0d7b82210f0b6937cd64fb3a8400482c2f2b8f5a7a028a89bc5cfaf49383474280ed5e3587cbc6f8d
7
+ data.tar.gz: 02645ad04663ed39f10f7e6845186e37b29c32e37258d33c2c175997ab58706a84184ad119c9715f42c16cd889178a2894cb382bb951cc9f2fa28e4defb55e2f
@@ -5,9 +5,12 @@ TEMP_GROUP_FILE = "#{TEMP_INV_DIR}/ansiblepush_groups_inventory.yml"
5
5
 
6
6
  def write_instance_inventory(name, host, mygroup, instance_connection_option)
7
7
  Dir.mkdir TEMP_INV_DIR if !File.exist?(TEMP_INV_DIR)
8
- port = instance_connection_option[:port]
9
- keys = instance_connection_option[:keys]
10
- user = instance_connection_option[:user]
8
+
9
+ unless instance_connection_option.nil?
10
+ port = instance_connection_option[:port]
11
+ keys = instance_connection_option[:keys]
12
+ user = instance_connection_option[:user]
13
+ end
11
14
 
12
15
  temp_hash = Hash.new
13
16
  temp_hash["ansible_ssh_host"] = host
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module AnsiblePush
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.4"
4
4
  end
5
5
  end
@@ -43,6 +43,8 @@ module Kitchen
43
43
  validate_config
44
44
  prepare_inventory if config[:generate_inv]
45
45
  complie_config
46
+ # Place holder so a string is returned. This will execute true on remote host
47
+ return "true"
46
48
  end
47
49
 
48
50
  def install_command
@@ -50,41 +52,42 @@ module Kitchen
50
52
  info("*************** AnsiblePush install_command ***************")
51
53
  omnibus_download_dir = config[:omnibus_cachier] ? "/tmp/vagrant-cache/omnibus_chef" : "/tmp"
52
54
  chef_url = config[:chef_bootstrap_url]
53
- <<-INSTALL
54
- sh -c '
55
- #{Util.shell_helpers}
56
- if [ ! -d "/opt/chef" ]
57
- then
58
- echo "-----> Installing Chef Omnibus"
59
- mkdir -p #{omnibus_download_dir}
60
- if [ ! -x #{omnibus_download_dir}/install.sh ]
55
+ if chef_url
56
+ <<-INSTALL
57
+ sh -c '
58
+ #{Util.shell_helpers}
59
+ if [ ! -d "/opt/chef" ]
61
60
  then
62
- do_download #{chef_url} #{omnibus_download_dir}/install.sh
61
+ echo "-----> Installing Chef Omnibus"
62
+ mkdir -p #{omnibus_download_dir}
63
+ if [ ! -x #{omnibus_download_dir}/install.sh ]
64
+ then
65
+ do_download #{chef_url} #{omnibus_download_dir}/install.sh
66
+ fi
67
+
68
+ sudo sh #{omnibus_download_dir}/install.sh -d #{omnibus_download_dir}
69
+ echo "-----> End Installing Chef Omnibus"
63
70
  fi
64
71
 
65
- sudo sh #{omnibus_download_dir}/install.sh -d #{omnibus_download_dir}
66
- echo "-----> End Installing Chef Omnibus"
67
- fi
68
-
69
- # Fix for https://github.com/test-kitchen/busser/issues/12
70
- if [ -h /usr/bin/ruby ]; then
71
- L=$(readlink -f /usr/bin/ruby)
72
- sudo rm /usr/bin/ruby
73
- sudo ln -s $L /usr/bin/ruby
74
- fi
75
- '
76
- INSTALL
77
-
72
+ # Fix for https://github.com/test-kitchen/busser/issues/12
73
+ if [ -h /usr/bin/ruby ]; then
74
+ L=$(readlink -f /usr/bin/ruby)
75
+ sudo rm /usr/bin/ruby
76
+ sudo ln -s $L /usr/bin/ruby
77
+ fi
78
+ '
79
+ INSTALL
80
+ end
78
81
  end
79
82
 
80
83
  def run_command
81
84
  info("*************** AnsiblePush run ***************")
82
- exec_command(@command_env, @command, "ansible-playbook")
85
+ exec_ansible_command(@command_env, @command, "ansible-playbook")
83
86
  # idempotency test
84
87
  if config[:idempotency_test]
85
88
  info("*************** idempotency test ***************")
86
89
  @command_env["ANSIBLE_CALLBACK_PLUGINS"] = "#{File.dirname(__FILE__)}/../../../callback/"
87
- exec_command(@command_env, @command, "ansible-playbook")
90
+ exec_ansible_command(@command_env, @command, "ansible-playbook")
88
91
  # Check ansible callback if changes has occured in the second run
89
92
  file_path = "/tmp/kitchen_ansible_callback/changes"
90
93
  if File.file?(file_path)
@@ -104,12 +107,13 @@ module Kitchen
104
107
  end
105
108
  info("*************** AnsiblePush end run *******************")
106
109
  debug("[#{name}] Converge completed (#{config[:sleep]}s).")
107
- return nil
110
+ # Place holder so a string is returned. This will execute true on remote host
111
+ return "true"
108
112
  end
109
113
 
110
114
  protected
111
115
 
112
- def exec_command(env, command, desc)
116
+ def exec_ansible_command(env, command, desc)
113
117
  debug("env=%s command=%s" % [env, command] )
114
118
  system(env, "#{command}")
115
119
  exit_code = $?.exitstatus
@@ -121,16 +125,22 @@ module Kitchen
121
125
 
122
126
  def prepare_inventory
123
127
  @machine_name = instance.name.gsub(/[<>]/, '').split("-").drop(1).join("-")
128
+ debug("machine_name=" + @machine_name.to_s)
124
129
  @instance_connection_option = instance.transport.instance_variable_get(:@connection_options)
125
- hostname = @instance_connection_option[:hostname]
126
130
  debug("instance_connection_option=" + @instance_connection_option.to_s)
131
+ hostname = if @instance_connection_option.nil?
132
+ @machine_name
133
+ else
134
+ @instance_connection_option[:hostname]
135
+ end
136
+ debug("hostname=" + hostname)
127
137
  write_instance_inventory(@machine_name, hostname, config[:mygroup], @instance_connection_option)
128
138
  end
129
139
 
130
140
  def complie_config()
131
141
  debug("compile_config")
132
142
  options = []
133
- options << "--extra-vars=#{self.get_extra_vars_argument}" if config[:extra_vars]
143
+ options << "--extra-vars='#{self.get_extra_vars_argument}'" if config[:extra_vars]
134
144
  options << "--sudo" if config[:sudo]
135
145
  options << "--sudo-user=#{config[:sudo_user]}" if config[:sudo_user]
136
146
  options << "--user=#{config[:remote_user]}" if self.get_remote_user
@@ -197,6 +207,7 @@ module Kitchen
197
207
  raise "ansible extra_vars is in valid type: %s value: %s" % [config[:extra_vars].class.to_s, config[:extra_vars].to_s]
198
208
  end
199
209
  end
210
+
200
211
  info("Ansible push config validated")
201
212
  end
202
213
 
@@ -214,11 +225,11 @@ module Kitchen
214
225
  def get_remote_user
215
226
  if config[:remote_user]
216
227
  return config[:remote_user]
217
- elsif @instance_connection_option[:username]
228
+ elsif !@instance_connection_option.nil? and @instance_connection_option[:username]
218
229
  config[:remote_user] = @instance_connection_option[:username]
219
230
  return @instance_connection_option[:username]
220
231
  else
221
- return nil
232
+ return false
222
233
  end
223
234
  end
224
235
 
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.3
4
+ version: 0.3.4
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-06-02 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen