foreman_ansible_core 4.1.4 → 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: 7e9a9d4a9f83b446ed1941f51ce21681afc64cbab85372b53c30bc301759b251
4
- data.tar.gz: 0de9e25099dc2a47969e53806fbc333befa14233be577e9874ed5f71a734a429
3
+ metadata.gz: e4ff48b6e2aec734e0eda53fe020e2ce1aa4d6abd92b42ed2d9089931d4b7097
4
+ data.tar.gz: 373035eea1363c5441cef6b566818d882c362232d263effa78a7b36aa683b611
5
5
  SHA512:
6
- metadata.gz: d64a75aa2438b35ced0c5065d419c8fa992bd366cd6a14e256d411502f47e17ee1963f0ccea94d7797969a871718ccfc4a01e35868cda8e34ba591005cc927c1
7
- data.tar.gz: d78a88b0cb187f9986b35e6cf7bb771762485e7445f86372338c2ef036140ba8fce2c5db429ec812ffd6ac697c9a2199089acbaf89dbe6289418b785c74df624
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
@@ -132,11 +148,11 @@ module ForemanAnsibleCore
132
148
  end
133
149
 
134
150
  def check_mode?
135
- @check_mode == true && @rex_command == false
151
+ @check_mode == true
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.4'
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.4
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-05 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
@@ -77,7 +77,7 @@ homepage: https://github.com/theforeman/foreman_ansible
77
77
  licenses:
78
78
  - GPL-3.0
79
79
  metadata: {}
80
- post_install_message:
80
+ post_install_message:
81
81
  rdoc_options: []
82
82
  require_paths:
83
83
  - lib
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubygems_version: 3.1.2
96
- signing_key:
96
+ signing_key:
97
97
  specification_version: 4
98
98
  summary: 'Ansible integration with Foreman (theforeman.org): core bits'
99
99
  test_files: []