foreman_ansible_core 4.1.3 → 4.2.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: 1ca3b309e4ee2869e3eeca882b6e296a68728ec7f6722ff294dcba365c912ffc
4
- data.tar.gz: 6215aa8ddb560b6d140873c7c390af83cca70af62a0a8571cf51f1d6b6db0bae
3
+ metadata.gz: e4ff48b6e2aec734e0eda53fe020e2ce1aa4d6abd92b42ed2d9089931d4b7097
4
+ data.tar.gz: 373035eea1363c5441cef6b566818d882c362232d263effa78a7b36aa683b611
5
5
  SHA512:
6
- metadata.gz: 8d507685ceb4cc8278ae333d4edc12fabd45a998123dd3c69158b88b0c7bd987ec792bd76b59b75f43e77a2b2db066595c3582895f6d9cf1be69bd6b36ac9ae7
7
- data.tar.gz: 8968f788db24c21d1222d9c0729f88371d7469910c3429335290d6fd72cfbad4a9084373a227b27a4d72188de6abce473d7e3121838efdf7afaeb35b5c947e8b
6
+ metadata.gz: c1fbf6b61ee93b5699c72b6f1cc221d2943c54eac1e0b52f325528f801c54c40a562a2ddc9624c1628eb7317d136e012cf339d4abc7db739868055b98b47bf51
7
+ data.tar.gz: 33ef3f280d7f16460573dee1e69095ac1ea26e79eb327f7f06ccd249deca24e30454a74ba253a3e43b301594d90d6dccb5661607ad4dadc27ed4026c4a70aa19
@@ -1,4 +1,5 @@
1
1
  require 'shellwords'
2
+ require 'yaml'
2
3
 
3
4
  module ForemanAnsibleCore
4
5
  module Runner
@@ -14,12 +15,14 @@ module ForemanAnsibleCore
14
15
  @verbosity_level = action_input[:verbosity_level]
15
16
  @rex_command = action_input[:remote_execution_command]
16
17
  @check_mode = action_input[:check_mode]
18
+ @passphrase = action_input['secrets']['key_passphrase']
17
19
  end
18
20
 
19
21
  def start
20
22
  prepare_directory_structure
21
23
  write_inventory
22
24
  write_playbook
25
+ write_ssh_key if !@passphrase.nil? && !@passphrase.empty?
23
26
  start_ansible_runner
24
27
  end
25
28
 
@@ -113,6 +116,19 @@ module ForemanAnsibleCore
113
116
  File.write(File.join(@root, 'project', 'playbook.yml'), @playbook)
114
117
  end
115
118
 
119
+ def write_ssh_key
120
+ key_path = File.join(@root, 'env', 'ssh_key')
121
+ File.symlink(File.expand_path(ForemanRemoteExecutionCore.settings[:ssh_identity_key_file]), key_path)
122
+
123
+ passwords_path = File.join(@root, 'env', 'passwords')
124
+ # here we create a secrets file for ansible-runner, which uses the key as regexp
125
+ # to match line asking for password, given the limitation to match only first 100 chars
126
+ # and the fact the line contains dynamically created temp directory, the regexp
127
+ # mentions only things that are always there, such as artifacts directory and the key name
128
+ secrets = YAML.dump({ "for.*/artifacts/.*/ssh_key_data:" => @passphrase })
129
+ File.write(passwords_path, secrets, perm: 0o600)
130
+ end
131
+
116
132
  def start_ansible_runner
117
133
  env = {}
118
134
  env['FOREMAN_CALLBACK_DISABLE'] = '1' if @rex_command
@@ -136,7 +152,7 @@ module ForemanAnsibleCore
136
152
  end
137
153
 
138
154
  def prepare_directory_structure
139
- inner = %w[inventory project].map { |part| File.join(@root, part) }
155
+ inner = %w[inventory project env].map { |part| File.join(@root, part) }
140
156
  ([@root] + inner).each do |path|
141
157
  FileUtils.mkdir_p path
142
158
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanAnsibleCore
4
- VERSION = '4.1.3'
4
+ VERSION = '4.2.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.1.3
4
+ version: 4.2.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: 2021-09-22 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman_remote_execution_core