smart_proxy_ansible 3.5.3 → 3.5.5

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
  SHA256:
3
- metadata.gz: dbbc81bb91b3c508c66bf0b2a609d1875638a4fa3263c3a029294c731f19dfca
4
- data.tar.gz: f106c29bca9feb9971a6d3ea9ab880ddd3fe15f39abb19d7a1bb8ab98c8ca232
3
+ metadata.gz: 2a6565b96c81502c1db79c10db9199cf3bb537fd03ed4ba1e9382bb8ca8dc2ad
4
+ data.tar.gz: c4859eac213669d85ec3a2e0bb23ca137c2d91ac947c3496252f2f0de6e7089c
5
5
  SHA512:
6
- metadata.gz: a6453b0c14b8b70b036fe7948c3de5c1d9151b6db0b2806e566a82d8a87c6aaeb05106a2eed2e4dc5a3184687c6c27f1abc0ca64b83d26e1141eda37ad055476
7
- data.tar.gz: aa09094674c71ae7c2f7b542f2e1173e1f3c682d35edc18e8a408ca40f5f31de3057572a4c20a1d9253efcdb10efe0fca1d6e6cc29291470a1557deed702634d
6
+ metadata.gz: 5ccf99444a7c7cb1cd7bca0be70e27d6402b25ac52f26a6f96103b5f3b3621bc456a911c88c65cc472c6fdf37f3330394fcc3e2e77177b0a4c02e5a5b1137a21
7
+ data.tar.gz: f099953775bb621e2219a63ac76c20d1794f6bfbf3b83241e3b5fb33d43e138d90e8f52e3a6024a9cf303cd44b6627b79f92c24a0983414a4da07ec92c7f0b5e
@@ -143,13 +143,14 @@ module Proxy::Ansible
143
143
  if event['event'] == 'playbook_on_stats'
144
144
  failures = event.dig('event_data', 'failures') || {}
145
145
  unreachable = event.dig('event_data', 'dark') || {}
146
+ rescued = event.dig('event_data', 'rescued') || {}
146
147
  header, *rows = event['stdout'].strip.lines.map(&:chomp)
147
148
  @outputs.keys.select { |key| key.is_a? String }.each do |host|
148
149
  line = rows.find { |row| row =~ /#{host}/ }
149
150
  publish_data_for(host, [header, line].join("\n"), 'stdout')
150
151
 
151
152
  # If the task has been rescued, it won't consider a failure
152
- if @exit_statuses[host].to_i != 0 && failures[host].to_i <= 0 && unreachable[host].to_i <= 0
153
+ if @exit_statuses[host].to_i != 0 && failures[host].to_i <= 0 && unreachable[host].to_i <= 0 && rescued[host].to_i > 0
153
154
  publish_exit_status_for(host, 0)
154
155
  end
155
156
  end
@@ -166,15 +167,10 @@ module Proxy::Ansible
166
167
  end
167
168
 
168
169
  def write_inventory
169
- path = File.join(@root, 'inventory', 'hosts')
170
- data_path = File.join(@root, 'data')
171
- inventory_script = <<~INVENTORY_SCRIPT
172
- #!/bin/sh
173
- cat #{::Shellwords.escape data_path}
174
- INVENTORY_SCRIPT
175
- File.write(path, inventory_script)
176
- File.write(data_path, JSON.dump(@inventory))
177
- File.chmod(0o0755, path)
170
+ File.open(File.join(@root, 'inventory', 'hosts.json'), 'w') do |file|
171
+ file.chmod(0o0640)
172
+ file.write(JSON.dump(@inventory))
173
+ end
178
174
  end
179
175
 
180
176
  def write_playbook
@@ -251,7 +247,6 @@ module Proxy::Ansible
251
247
  # containing all the hosts.
252
248
  def rebuild_inventory(input)
253
249
  action_inputs = input.values.map { |hash| hash[:input][:action_input] }
254
- hostnames = action_inputs.map { |hash| hash[:name] }
255
250
  inventories = action_inputs.map { |hash| hash[:ansible_inventory] }
256
251
  host_vars = inventories.map { |i| i['_meta']['hostvars'] }.reduce({}) do |acc, hosts|
257
252
  hosts.reduce(acc) do |inner_acc, (hostname, vars)|
@@ -260,8 +255,7 @@ module Proxy::Ansible
260
255
  end
261
256
  end
262
257
 
263
- { '_meta' => { 'hostvars' => host_vars },
264
- 'all' => { 'hosts' => hostnames,
258
+ { 'all' => { 'hosts' => host_vars,
265
259
  'vars' => inventories.first['all']['vars'] } }
266
260
  end
267
261
 
@@ -285,7 +279,7 @@ module Proxy::Ansible
285
279
  'ansible_password' => inventory['ssh_password'] || per_host['ansible_password'],
286
280
  'ansible_become_password' => inventory['effective_user_password'] || per_host['ansible_become_password']
287
281
  }
288
- inventory['_meta']['hostvars'][host].update(new_secrets)
282
+ inventory['all']['hosts'][host].update(new_secrets)
289
283
  end
290
284
 
291
285
  inventory
@@ -2,6 +2,6 @@ module Proxy
2
2
  # Version, this allows the proxy and other plugins know
3
3
  # what version of the Ansible plugin is running
4
4
  module Ansible
5
- VERSION = '3.5.3'
5
+ VERSION = '3.5.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.3
4
+ version: 3.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-07 00:00:00.000000000 Z
12
+ date: 2023-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake