foreman_ansible 6.0.2 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/ansible_inventories_controller.rb +2 -2
- data/app/helpers/foreman_ansible/ansible_reports_helper.rb +1 -1
- data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +3 -3
- data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +12 -0
- data/app/models/foreman_ansible/ansible_provider.rb +1 -1
- data/app/services/foreman_ansible/operating_system_parser.rb +8 -2
- data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +2 -3
- data/lib/foreman_ansible/version.rb +1 -1
- data/test/unit/ansible_provider_test.rb +1 -1
- data/test/unit/lib/foreman_ansible_core/ansible_runner_test.rb +3 -3
- data/test/unit/lib/foreman_ansible_core/playbook_runner_test.rb +3 -3
- data/test/unit/services/inventory_creator_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f0adadc325dd31954f306695e4f6be32b13d6388db0893cfc2685a2bbb53df3
|
4
|
+
data.tar.gz: 7a3e2bf970e9ebff66219696b5bc4714853b109344d943e8d89d02f45b4b50c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0ae153aa823b601fccf70886d3e6f036585010467c5df1233bb84c3851ca4fc2b5d83e7f3f4a89c796a38f0e1497c58c550d33777c480b058d5e8eafc9f9195
|
7
|
+
data.tar.gz: 83f7f0c912b9db4dda3a363690aaf49117581680a1638718410efe9f0c937ba9caae35599c04130ddcc10540a586af57215d279f959abda41aec4a4dd814a76b
|
@@ -72,8 +72,8 @@ module Api
|
|
72
72
|
process_resource_error(:resource => @ansible_inventory)
|
73
73
|
end
|
74
74
|
rescue StandardError => e
|
75
|
-
render_error
|
76
|
-
|
75
|
+
render_error :custom_error, :status => :unprocessable_entity,
|
76
|
+
:locals => { :message => _("Scheduling Report template failed for: #{e.message}") }
|
77
77
|
end
|
78
78
|
|
79
79
|
def action_permission
|
@@ -68,7 +68,7 @@ module ForemanAnsible
|
|
68
68
|
prettyp.gsub!(/^(\[|\])/, '')
|
69
69
|
prettyp.gsub!(/^[\s]*$\n/, '')
|
70
70
|
paragraph_style = 'white-space:pre;padding: 2em 0'
|
71
|
-
|
71
|
+
tag(:p, prettyp, :style => paragraph_style)
|
72
72
|
end
|
73
73
|
|
74
74
|
def hash_with_keys_removed(hash)
|
@@ -68,9 +68,9 @@ end
|
|
68
68
|
module Host
|
69
69
|
class Managed
|
70
70
|
apipie :class do
|
71
|
-
property :all_ansible_roles, array_of: 'AnsibleRole', desc: 'Returns all ansible roles assigned to the host, both its own and inherited'
|
72
|
-
property :ansible_roles, array_of: 'AnsibleRole', desc: 'Returns ansible roles assigned to the host'
|
73
|
-
property :inherited_ansible_roles, array_of: 'AnsibleRole', desc: 'Returns
|
71
|
+
property :all_ansible_roles, array_of: 'AnsibleRole', desc: 'Returns all ansible roles assigned to the host, both its own and inherited from the host group and its parents'
|
72
|
+
property :ansible_roles, array_of: 'AnsibleRole', desc: 'Returns ansible roles directly assigned to the host'
|
73
|
+
property :inherited_ansible_roles, array_of: 'AnsibleRole', desc: 'Returns only ansible roles assigned to the host\'s host group and its parents'
|
74
74
|
end
|
75
75
|
# Methods to be allowed in any template with safemode enabled
|
76
76
|
class Jail < Safemode::Jail
|
@@ -36,3 +36,15 @@ module ForemanAnsible
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
class Hostgroup
|
41
|
+
apipie :class do
|
42
|
+
property :all_ansible_roles, array_of: 'AnsibleRole', desc: 'Returns all ansible roles assigned to the host group, both its own and inherited from parent host groups'
|
43
|
+
property :ansible_roles, array_of: 'AnsibleRole', desc: 'Returns ansible roles directly assigned to the host group'
|
44
|
+
property :inherited_ansible_roles, array_of: 'AnsibleRole', desc: 'Returns only the inherited ansible roles assigned to the host group\'s parents'
|
45
|
+
end
|
46
|
+
# Methods to be allowed in any template with safemode enabled
|
47
|
+
class Jail < Safemode::Jail
|
48
|
+
allow :all_ansible_roles, :ansible_roles, :inherited_ansible_roles
|
49
|
+
end
|
50
|
+
end
|
@@ -80,8 +80,14 @@ module ForemanAnsible
|
|
80
80
|
facts[:ansible_os_name].tr(" \n\t", '') ||
|
81
81
|
facts[:ansible_distribution].tr(" \n\t", '')
|
82
82
|
else
|
83
|
-
facts[:ansible_distribution] ||
|
84
|
-
|
83
|
+
distribution = facts[:ansible_distribution] || facts[:ansible_lsb].try(:[], 'id')
|
84
|
+
|
85
|
+
if distribution == 'RedHat' &&
|
86
|
+
facts[:ansible_lsb].try(:[], 'id') == 'RedHatEnterpriseWorkstation'
|
87
|
+
distribution += '_Workstation'
|
88
|
+
end
|
89
|
+
|
90
|
+
distribution
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
@@ -34,11 +34,10 @@ feature: ansible_run_capsule_upgrade
|
|
34
34
|
msg: "This playbook cannot be executed on a Satellite server. Use only on a Capsule server."
|
35
35
|
when: "'satellite' in ansible_facts.packages"
|
36
36
|
|
37
|
-
- name: Install satellite-maintain if not present
|
37
|
+
- name: Install|Update satellite-maintain if not present
|
38
38
|
package:
|
39
39
|
name: rubygem-foreman_maintain
|
40
|
-
state:
|
41
|
-
when: "'rubygem-foreman_maintain' not in ansible_facts.packages"
|
40
|
+
state: latest
|
42
41
|
|
43
42
|
- block:
|
44
43
|
<%- whitelist_option = if input('whitelist_options').present?
|
@@ -40,7 +40,7 @@ class AnsibleProviderTest < ActiveSupport::TestCase
|
|
40
40
|
host.expects(:params).twice.returns(params)
|
41
41
|
secrets = ForemanAnsible::AnsibleProvider.secrets(host)
|
42
42
|
host_secrets = secrets['per-host'][host.name]
|
43
|
-
assert_equal host_secrets['
|
43
|
+
assert_equal host_secrets['ansible_ssh_pass'], 'password'
|
44
44
|
assert_equal host_secrets['ansible_become_password'], 'letmein'
|
45
45
|
end
|
46
46
|
end
|
@@ -24,7 +24,7 @@ module ForemanAnsibleCore
|
|
24
24
|
'_meta' => { 'hostvars' => { 'foreman.example.com' => {} } } }
|
25
25
|
end
|
26
26
|
let(:input) do
|
27
|
-
host_secrets = { '
|
27
|
+
host_secrets = { 'ansible_ssh_pass' => 'letmein', 'ansible_become_password' => 'iamroot' }
|
28
28
|
secrets = { 'per-host' => { 'foreman.example.com' => host_secrets } }
|
29
29
|
host_input = { 'input' => { 'action_input' => { 'secrets' => secrets } } }
|
30
30
|
{ 'foreman.example.com' => host_input }
|
@@ -35,14 +35,14 @@ module ForemanAnsibleCore
|
|
35
35
|
test_inventory = inventory.merge('ssh_password' => 'sshpass', 'effective_user_password' => 'mypass')
|
36
36
|
rebuilt = runner.send(:rebuild_secrets, test_inventory, input)
|
37
37
|
host_vars = rebuilt.dig('_meta', 'hostvars', 'foreman.example.com')
|
38
|
-
assert_equal 'sshpass', host_vars['
|
38
|
+
assert_equal 'sshpass', host_vars['ansible_ssh_pass']
|
39
39
|
assert_equal 'mypass', host_vars['ansible_become_password']
|
40
40
|
end
|
41
41
|
|
42
42
|
test 'host secrets are used when not overriden by inventory secrest' do
|
43
43
|
rebuilt = runner.send(:rebuild_secrets, inventory, input)
|
44
44
|
host_vars = rebuilt.dig('_meta', 'hostvars', 'foreman.example.com')
|
45
|
-
assert_equal 'letmein', host_vars['
|
45
|
+
assert_equal 'letmein', host_vars['ansible_ssh_pass']
|
46
46
|
assert_equal 'iamroot', host_vars['ansible_become_password']
|
47
47
|
end
|
48
48
|
end
|
@@ -87,7 +87,7 @@ class PlaybookRunnerTest < ActiveSupport::TestCase
|
|
87
87
|
'_meta' => { 'hostvars' => { 'foreman.example.com' => {} } } }
|
88
88
|
end
|
89
89
|
let(:secrets) do
|
90
|
-
host_secrets = { '
|
90
|
+
host_secrets = { 'ansible_ssh_pass' => 'letmein', 'ansible_become_password' => 'iamroot' }
|
91
91
|
{ 'per-host' => { 'foreman.example.com' => host_secrets } }
|
92
92
|
end
|
93
93
|
let(:runner) { ForemanAnsibleCore::Runner::Playbook.allocate }
|
@@ -96,14 +96,14 @@ class PlaybookRunnerTest < ActiveSupport::TestCase
|
|
96
96
|
test_inventory = inventory.merge('ssh_password' => 'sshpass', 'effective_user_password' => 'mypass')
|
97
97
|
rebuilt = runner.send(:rebuild_secrets, test_inventory, secrets)
|
98
98
|
host_vars = rebuilt.dig('_meta', 'hostvars', 'foreman.example.com')
|
99
|
-
assert_equal 'sshpass', host_vars['
|
99
|
+
assert_equal 'sshpass', host_vars['ansible_ssh_pass']
|
100
100
|
assert_equal 'mypass', host_vars['ansible_become_password']
|
101
101
|
end
|
102
102
|
|
103
103
|
test 'host secrets are used when not overriden by inventory secrest' do
|
104
104
|
rebuilt = runner.send(:rebuild_secrets, inventory, secrets)
|
105
105
|
host_vars = rebuilt.dig('_meta', 'hostvars', 'foreman.example.com')
|
106
|
-
assert_equal 'letmein', host_vars['
|
106
|
+
assert_equal 'letmein', host_vars['ansible_ssh_pass']
|
107
107
|
assert_equal 'iamroot', host_vars['ansible_become_password']
|
108
108
|
end
|
109
109
|
end
|
@@ -69,7 +69,7 @@ module ForemanAnsible
|
|
69
69
|
connection_params['ansible_winrm_server_cert_validation']
|
70
70
|
assert_equal Setting['remote_execution_effective_user_method'],
|
71
71
|
connection_params['ansible_become_method']
|
72
|
-
refute connection_params.key?('
|
72
|
+
refute connection_params.key?('ansible_ssh_pass')
|
73
73
|
refute connection_params.key?('ansible_become_password')
|
74
74
|
end
|
75
75
|
|
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: 6.0
|
4
|
+
version: 6.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: 2021-01-
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman_ansible_core
|