foreman_ansible_core 3.0.1 → 3.0.2
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d2701f33f04f30fc268f07f895f402ae8d87b7a
|
4
|
+
data.tar.gz: 569411abe75f0ecdb5f5f45df35be14c9e9c3dd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51ee5269d539e37feedff2df13b82822c0f09ce5be4adba3be8ff63297b71fbe4cf51a6ca93ebfd6390cfd8f1725b1fbedb21f305e94cc3325b8f50c0cac1d98
|
7
|
+
data.tar.gz: 4b6c461a3883d4b7ece4072dc537d42c0a367063185778baae53bf1fa2687d4a794f909aca604b84ceddd7cf4a28dd621b856405e9343551245ff085d6ef4d55
|
@@ -5,7 +5,7 @@ module ForemanAnsibleCore
|
|
5
5
|
|
6
6
|
def initialize(input, suspended_action:)
|
7
7
|
super input, :suspended_action => suspended_action
|
8
|
-
@inventory = rebuild_inventory(input)
|
8
|
+
@inventory = rebuild_secrets(rebuild_inventory(input), input)
|
9
9
|
@playbook = input.values.first[:input][:action_input][:script]
|
10
10
|
@root = working_dir
|
11
11
|
end
|
@@ -41,7 +41,7 @@ module ForemanAnsibleCore
|
|
41
41
|
logger.debug("[foreman_ansible] - parsing event file #{event_file}")
|
42
42
|
begin
|
43
43
|
event = JSON.parse(File.read(event_file))
|
44
|
-
if (hostname = event
|
44
|
+
if (hostname = event.dig('event_data', 'host'))
|
45
45
|
handle_host_event(hostname, event)
|
46
46
|
else
|
47
47
|
handle_broadcast_data(event)
|
@@ -62,7 +62,7 @@ module ForemanAnsibleCore
|
|
62
62
|
when 'runner_on_unreachable'
|
63
63
|
publish_exit_status_for(hostname, 1)
|
64
64
|
when 'runner_on_failed'
|
65
|
-
publish_exit_status_for(hostname, 2) if event
|
65
|
+
publish_exit_status_for(hostname, 2) if event.dig('event_data', 'ignore_errors').nil?
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -120,7 +120,7 @@ module ForemanAnsibleCore
|
|
120
120
|
def rebuild_inventory(input)
|
121
121
|
action_inputs = input.values.map { |hash| hash[:input][:action_input] }
|
122
122
|
hostnames = action_inputs.map { |hash| hash[:name] }
|
123
|
-
inventories = action_inputs.map { |hash|
|
123
|
+
inventories = action_inputs.map { |hash| hash[:ansible_inventory] }
|
124
124
|
host_vars = inventories.map { |i| i['_meta']['hostvars'] }.reduce(&:merge)
|
125
125
|
|
126
126
|
{ '_meta' => { 'hostvars' => host_vars },
|
@@ -138,6 +138,21 @@ module ForemanAnsibleCore
|
|
138
138
|
Dir.mktmpdir(nil, File.expand_path(dir))
|
139
139
|
end
|
140
140
|
end
|
141
|
+
|
142
|
+
def rebuild_secrets(inventory, input)
|
143
|
+
input.each do |host, host_input|
|
144
|
+
secrets = host_input['input']['action_input']['secrets']
|
145
|
+
per_host = secrets['per-host'][host]
|
146
|
+
|
147
|
+
new_secrets = {
|
148
|
+
'ansible_ssh_pass' => inventory['ssh_password'] || per_host['ansible_ssh_pass'],
|
149
|
+
'ansible_sudo_pass' => inventory['sudo_password'] || per_host['ansible_sudo_pass']
|
150
|
+
}
|
151
|
+
inventory['_meta']['hostvars'][host].update(new_secrets)
|
152
|
+
end
|
153
|
+
|
154
|
+
inventory
|
155
|
+
end
|
141
156
|
end
|
142
157
|
end
|
143
158
|
end
|
@@ -14,7 +14,7 @@ module ForemanAnsibleCore
|
|
14
14
|
|
15
15
|
def initialize(inventory, playbook, options = {}, suspended_action:)
|
16
16
|
super :suspended_action => suspended_action
|
17
|
-
@inventory = inventory
|
17
|
+
@inventory = rebuild_secrets(inventory, options[:secrets])
|
18
18
|
unknown_hosts.each do |host|
|
19
19
|
add_to_known_hosts(host)
|
20
20
|
end
|
@@ -52,7 +52,7 @@ module ForemanAnsibleCore
|
|
52
52
|
|
53
53
|
def write_inventory
|
54
54
|
ensure_directory(File.dirname(inventory_file))
|
55
|
-
File.write(inventory_file, @inventory)
|
55
|
+
File.write(inventory_file, JSON.dump(@inventory))
|
56
56
|
end
|
57
57
|
|
58
58
|
def write_playbook
|
@@ -103,7 +103,7 @@ module ForemanAnsibleCore
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def unknown_hosts
|
106
|
-
|
106
|
+
@inventory['all']['hosts'].select do |host|
|
107
107
|
Net::SSH::KnownHosts.search_for(host).empty?
|
108
108
|
end
|
109
109
|
end
|
@@ -118,6 +118,20 @@ module ForemanAnsibleCore
|
|
118
118
|
logger.error('[foreman_ansible] - Failed to save host key for '\
|
119
119
|
"#{host}: #{e}")
|
120
120
|
end
|
121
|
+
|
122
|
+
def rebuild_secrets(inventory, secrets)
|
123
|
+
inventory['all']['hosts'].each do |name|
|
124
|
+
per_host = secrets['per-host'][name]
|
125
|
+
|
126
|
+
new_secrets = {
|
127
|
+
'ansible_ssh_pass' => inventory['ssh_password'] || per_host['ansible_ssh_pass'],
|
128
|
+
'ansible_sudo_pass' => inventory['sudo_password'] || per_host['ansible_sudo_pass']
|
129
|
+
}
|
130
|
+
inventory['_meta']['hostvars'][name].update(new_secrets)
|
131
|
+
end
|
132
|
+
|
133
|
+
inventory
|
134
|
+
end
|
121
135
|
end
|
122
136
|
end
|
123
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_ansible_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Lobato Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -106,7 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.6.14
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
113
|
summary: 'Ansible integration with Foreman (theforeman.org): core bits'
|