foreman_ansible_core 4.0.0 → 4.1.0

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
  SHA256:
3
- metadata.gz: 6427ec31aba5a41a3ffa93168c761218f0aff53f97d08681c9d2cba431b50a9f
4
- data.tar.gz: cc0a584af7801a24e3d66b679b840c968ab7851f38901abf37e5d26923d1eea9
3
+ metadata.gz: cc5b524830b6cf92b7715fdc19d9bc65e9e863b247ecb3dbe2f35aa7c8ee4e46
4
+ data.tar.gz: e3c669c0942e9d128d24ba4ffcf8896c9602d69058e286d1398dd531edd73ebf
5
5
  SHA512:
6
- metadata.gz: 1f4db115d787db1dc78d3eaa468b2972514005aa8d068fc0b98d73f7a07e159a5646a9cff4e5f9a19ed6de1ee4043f9f04379f69e82bdceb6a1b9ab5d8257f60
7
- data.tar.gz: bb6bb793c4ea5d2f43af3ac1c3e545f39b574f32041cd141cd06e4c115e519c3e221449a7af0b4956627acf593792b63376d54dc922bd0ff69ba13ecd76924aa
6
+ metadata.gz: c037f11562f8a20db823fefec5d9ffbc1aef49aa3a445fe78555acbc2ded7a84fea2863cfb1e88cb04ef8d11e93ad51b9700e6f81dedec1987e63e7677134125
7
+ data.tar.gz: dc1dce5cc48e298bee1708f9bfef4f20d86423860ac7761ea440b179ce3e4a44f70ef65aabee9299a95bae4e0a99640602e007035fcbca53ed62900951a17f37
@@ -8,9 +8,12 @@ module ForemanAnsibleCore
8
8
  def initialize(input, suspended_action:)
9
9
  super input, :suspended_action => suspended_action
10
10
  @inventory = rebuild_secrets(rebuild_inventory(input), input)
11
- @playbook = input.values.first[:input][:action_input][:script]
11
+ action_input = input.values.first[:input][:action_input]
12
+ @playbook = action_input[:script]
12
13
  @root = working_dir
13
- @verbosity_level = input.values.first[:input][:action_input][:verbosity_level]
14
+ @verbosity_level = action_input[:verbosity_level]
15
+ @rex_command = action_input[:remote_execution_command]
16
+ @check_mode = action_input[:check_mode]
14
17
  end
15
18
 
16
19
  def start
@@ -104,7 +107,10 @@ module ForemanAnsibleCore
104
107
  end
105
108
 
106
109
  def start_ansible_runner
107
- command = ['ansible-runner', 'run', @root, '-p', 'playbook.yml']
110
+ env = {}
111
+ env['FOREMAN_CALLBACK_DISABLE'] = '1' if @rex_command
112
+ command = [env, 'ansible-runner', 'run', @root, '-p', 'playbook.yml']
113
+ command << '--cmdline' << '"--check"' if check_mode?
108
114
  command << verbosity if verbose?
109
115
  initialize_command(*command)
110
116
  logger.debug("[foreman_ansible] - Running command '#{command.join(' ')}'")
@@ -118,6 +124,10 @@ module ForemanAnsibleCore
118
124
  @verbosity_level.to_i.positive?
119
125
  end
120
126
 
127
+ def check_mode?
128
+ @check_mode == true
129
+ end
130
+
121
131
  def prepare_directory_structure
122
132
  inner = %w[inventory project].map { |part| File.join(@root, part) }
123
133
  ([@root] + inner).each do |path|
@@ -138,7 +148,12 @@ module ForemanAnsibleCore
138
148
  action_inputs = input.values.map { |hash| hash[:input][:action_input] }
139
149
  hostnames = action_inputs.map { |hash| hash[:name] }
140
150
  inventories = action_inputs.map { |hash| hash[:ansible_inventory] }
141
- host_vars = inventories.map { |i| i['_meta']['hostvars'] }.reduce(&:merge)
151
+ host_vars = inventories.map { |i| i['_meta']['hostvars'] }.reduce({}) do |acc, hosts|
152
+ hosts.reduce(acc) do |inner_acc, (hostname, vars)|
153
+ vars[:ansible_ssh_private_key_file] ||= ForemanRemoteExecutionCore.settings[:ssh_identity_key_file]
154
+ inner_acc.merge(hostname => vars)
155
+ end
156
+ end
142
157
 
143
158
  { '_meta' => { 'hostvars' => host_vars },
144
159
  'all' => { 'hosts' => hostnames,
@@ -17,6 +17,12 @@ module ForemanAnsibleCore
17
17
  Runner::AnsibleRunner
18
18
  end
19
19
 
20
+ # Discard everything apart from hostname to be able to tell the actions
21
+ # apart when debugging
22
+ def transform_input(input)
23
+ { 'action_input' => input['action_input'].slice('name') }
24
+ end
25
+
20
26
  # def self.input_format
21
27
  # {
22
28
  # $UUID => {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanAnsibleCore
4
- VERSION = '4.0.0'
4
+ VERSION = '4.1.0'
5
5
  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: 4.0.0
4
+ version: 4.1.0
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: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2021-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman_remote_execution_core