foreman_ansible 2.2.12 → 2.2.13

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
  SHA1:
3
- metadata.gz: 5a48bafe99b010006c5957a99968aff502c94ec9
4
- data.tar.gz: 88055306424957d6613eaadce8fd4f94bc2b233f
3
+ metadata.gz: a81d01fef4d36b89f0ef6362d9700cb36de3d0fb
4
+ data.tar.gz: dd59fd6803183ebe157ca15c02afdae2799e45e1
5
5
  SHA512:
6
- metadata.gz: 659f90c5b54a7a64d72c98e103a0f92b8050d0c27cd1fd7d8e9685dad2ae201001f4403609b6fb23985d666cfd2e2fda3dc180b866247806c9fac53512f13eac
7
- data.tar.gz: 6be0b66ee9aa48b4d522ed4540c55cbc85b51df721267f15559189b14fc7110dd1ebb97124164415a4e3f1add43893879c4d7616583e8c5f3f6a9391e290af31
6
+ metadata.gz: '098bf3d8db153f6715b5a7190cf1a650672bb398a51850a7051cba75915e4632b9c38137ef6aa27c3d75186fffe0b6c95d6f6cd738cbba4d04b603a8175f9b40'
7
+ data.tar.gz: 98b2f3bb6dc64f683c432dabba2c516fb00211092c5e4d0a3c6f78dddc67b6ff4130ddcfb49483dda80bd5fdfe85866950d83e8bb60a4748e35b4a1dbdc53020
@@ -94,6 +94,7 @@ module ForemanAnsible
94
94
  'ansible_become_user' => @template_invocation.effective_user,
95
95
  'ansible_user' => host_setting(host, 'remote_execution_ssh_user'),
96
96
  'ansible_ssh_pass' => rex_ssh_password(host),
97
+ 'ansible_sudo_pass' => rex_sudo_password(host),
97
98
  'ansible_ssh_private_key_file' => ansible_or_rex_ssh_private_key(host),
98
99
  'ansible_port' => host_setting(host, 'remote_execution_ssh_port')
99
100
  }
@@ -117,6 +118,11 @@ module ForemanAnsible
117
118
  host_setting(host, 'remote_execution_ssh_password')
118
119
  end
119
120
 
121
+ def rex_sudo_password(host)
122
+ @template_invocation.job_invocation.sudo_password ||
123
+ host_setting(host, 'remote_execution_sudo_password')
124
+ end
125
+
120
126
  def ansible_or_rex_ssh_private_key(host)
121
127
  ansible_private_file = host_setting(host, 'ansible_ssh_private_key_file')
122
128
  if !ansible_private_file.empty?
@@ -2,5 +2,5 @@
2
2
  # This way other parts of Foreman can just call ForemanAnsible::VERSION
3
3
  # and detect what version the plugin is running.
4
4
  module ForemanAnsible
5
- VERSION = '2.2.12'.freeze
5
+ VERSION = '2.2.13'.freeze
6
6
  end
@@ -10,7 +10,8 @@ module ForemanAnsible
10
10
  setup do
11
11
  @host = FactoryBot.build(:host)
12
12
  @template_invocation = OpenStruct.new(
13
- :job_invocation => OpenStruct.new(:password => 'foobar'),
13
+ :job_invocation => OpenStruct.new(:password => 'foobar',
14
+ :sudo_password => 'foobar'),
14
15
  :effective_user => 'foobar'
15
16
  )
16
17
  end
@@ -41,6 +42,8 @@ module ForemanAnsible
41
42
  returns('root').at_least_once
42
43
  Setting.expects(:[]).with('remote_execution_ssh_password').
43
44
  returns('asafepassword').at_least_once
45
+ Setting.expects(:[]).with('remote_execution_sudo_password').
46
+ returns('foobar').at_least_once
44
47
  Setting.expects(:[]).with('ansible_winrm_server_cert_validation').
45
48
  returns(true).at_least_once
46
49
  Setting.expects(:[]).with('ansible_connection').
@@ -69,6 +72,8 @@ module ForemanAnsible
69
72
  connection_params['ansible_port']
70
73
  assert_equal Setting['remote_execution_ssh_password'],
71
74
  connection_params['ansible_ssh_pass']
75
+ assert_equal Setting['remote_execution_sudo_password'],
76
+ connection_params['ansible_sudo_pass']
72
77
  assert_equal Setting['ansible_winrm_server_cert_validation'],
73
78
  connection_params['ansible_winrm_server_cert_validation']
74
79
  end
@@ -80,6 +85,13 @@ module ForemanAnsible
80
85
  inventory.rex_ssh_password(@host))
81
86
  end
82
87
 
88
+ test 'job invocation sudo password is passed when available' do
89
+ inventory = ForemanAnsible::InventoryCreator.new(@host,
90
+ @template_invocation)
91
+ assert_equal(@template_invocation.job_invocation.sudo_password,
92
+ inventory.rex_sudo_password(@host))
93
+ end
94
+
83
95
  test 'ssh private key is passed when available' do
84
96
  host = FactoryBot.build(:host)
85
97
  path_to_key = '/path/to/private/key'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.12
4
+ version: 2.2.13
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-03-07 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop