foreman_ansible 5.0.0 → 6.0.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 +9 -4
- data/app/models/ansible_role.rb +6 -0
- data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +5 -0
- data/app/models/foreman_ansible/ansible_provider.rb +15 -3
- data/app/models/setting/ansible.rb +1 -1
- data/app/services/foreman_ansible/ansible_info.rb +1 -1
- data/app/services/foreman_ansible/ansible_report_importer.rb +1 -1
- data/app/services/foreman_ansible/ansible_report_scanner.rb +9 -6
- data/app/services/foreman_ansible/operating_system_parser.rb +1 -1
- data/app/services/foreman_ansible/renderer_methods.rb +11 -0
- data/app/services/foreman_ansible/variables_importer.rb +8 -9
- data/app/views/ansible_variables/_fields.erb +1 -1
- data/app/views/foreman_ansible/job_templates/ansible_roles_-_ansible_default.erb +7 -4
- data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +74 -0
- data/app/views/foreman_ansible/job_templates/configure_cloud_connector_-_ansible_default.erb +36 -0
- data/app/views/foreman_ansible/job_templates/power_action_-_ansible_default.erb +1 -1
- data/app/views/foreman_ansible/job_templates/puppet_run_once_-_ansible_default.erb +5 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20200421201839_update_ansible_inv_template_name.rb +9 -0
- data/db/seeds.d/75_job_templates.rb +1 -1
- data/lib/foreman_ansible/engine.rb +22 -25
- data/lib/foreman_ansible/register.rb +5 -1
- data/lib/foreman_ansible/remote_execution.rb +11 -0
- data/lib/foreman_ansible/version.rb +1 -1
- data/locale/action_names.rb +3 -3
- data/locale/ca/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ca/foreman_ansible.po +556 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/cs_CZ/foreman_ansible.po +556 -0
- data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/de/foreman_ansible.po +38 -33
- data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en/foreman_ansible.po +38 -33
- data/locale/en_GB/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en_GB/foreman_ansible.po +555 -0
- data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/es/foreman_ansible.po +38 -33
- data/locale/foreman_ansible.pot +96 -88
- data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/fr/foreman_ansible.po +38 -33
- data/locale/gl/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/gl/foreman_ansible.po +553 -0
- data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/it/foreman_ansible.po +38 -33
- data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ja/foreman_ansible.po +38 -33
- data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ko/foreman_ansible.po +38 -33
- data/locale/nl_NL/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/nl_NL/foreman_ansible.po +559 -0
- data/locale/pl/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pl/foreman_ansible.po +556 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pt_BR/foreman_ansible.po +38 -33
- data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ru/foreman_ansible.po +38 -33
- data/locale/sv_SE/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/sv_SE/foreman_ansible.po +556 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_CN/foreman_ansible.po +38 -33
- data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_TW/foreman_ansible.po +38 -33
- data/test/factories/ansible_variables.rb +5 -0
- data/test/fixtures/report.json +2 -1
- data/test/unit/ansible_provider_test.rb +2 -2
- data/test/unit/lib/foreman_ansible_core/ansible_runner_test.rb +4 -4
- data/test/unit/lib/foreman_ansible_core/playbook_runner_test.rb +4 -4
- data/test/unit/services/ansible_variables_importer_test.rb +68 -43
- data/test/unit/services/inventory_creator_test.rb +2 -4
- data/webpack/components/ReportJsonViewer.js +1 -1
- metadata +52 -71
- data/locale/de/foreman_ansible.edit.po +0 -825
- data/locale/de/foreman_ansible.po.time_stamp +0 -0
- data/locale/en/foreman_ansible.edit.po +0 -714
- data/locale/en/foreman_ansible.po.time_stamp +0 -0
- data/locale/es/foreman_ansible.edit.po +0 -845
- data/locale/es/foreman_ansible.po.time_stamp +0 -0
- data/locale/fr/foreman_ansible.edit.po +0 -847
- data/locale/fr/foreman_ansible.po.time_stamp +0 -0
- data/locale/it/foreman_ansible.edit.po +0 -818
- data/locale/it/foreman_ansible.po.time_stamp +0 -0
- data/locale/ja/foreman_ansible.edit.po +0 -818
- data/locale/ja/foreman_ansible.po.time_stamp +0 -0
- data/locale/ko/foreman_ansible.edit.po +0 -804
- data/locale/ko/foreman_ansible.po.time_stamp +0 -0
- data/locale/pt_BR/foreman_ansible.edit.po +0 -845
- data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
- data/locale/ru/foreman_ansible.edit.po +0 -819
- data/locale/ru/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_CN/foreman_ansible.edit.po +0 -813
- data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_TW/foreman_ansible.edit.po +0 -804
- data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ee1b4acb26925c919a3d2b3c8b9efe6bd355dc603d896d642a0150d9364f86b
|
4
|
+
data.tar.gz: b5fb045a0cfddf957c238f311b29f97a56b0b5fc91999b56ca25ee3f4c0eeda4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 529107a643fb300fc1755a3efe8bbb1bb94b726c822c93f568e3001d2acc71658499343952bce1191ca2e142d1abc3548525a3fdfbde2c8fe1a2f645923b366c
|
7
|
+
data.tar.gz: 2874526de96c18b4aafd6fcaa29006c1d910ccb0e87b1f3326d64312c510cc496fc4e49fd176fafb3f465bded12a2b9c26768dfc0833b628c1538659279cd6a6
|
@@ -3,6 +3,11 @@ module Api
|
|
3
3
|
class AnsibleInventoriesController < ::Api::V2::BaseController
|
4
4
|
include ::Api::Version2
|
5
5
|
|
6
|
+
resource_description do
|
7
|
+
api_version 'v2'
|
8
|
+
api_base_url '/ansible/api'
|
9
|
+
end
|
10
|
+
|
6
11
|
api :POST, '/ansible_inventories/hosts',
|
7
12
|
N_('Show Ansible inventory for hosts')
|
8
13
|
param :host_ids, Array, N_('IDs of hosts included in inventory'),
|
@@ -13,6 +18,10 @@ module Api
|
|
13
18
|
param :host_ids, Array, N_('IDs of hosts included in inventory'),
|
14
19
|
:required => true
|
15
20
|
|
21
|
+
def hosts
|
22
|
+
show_inventory :host_ids, :id
|
23
|
+
end
|
24
|
+
|
16
25
|
api :POST, '/ansible_inventories/hostgroups',
|
17
26
|
N_('Show Ansible inventory for hostgroups')
|
18
27
|
param :hostgroup_ids, Array, N_('IDs of hostgroups included in inventory'),
|
@@ -23,10 +32,6 @@ module Api
|
|
23
32
|
param :hostgroup_ids, Array, N_('IDs of hostgroups included in inventory'),
|
24
33
|
:required => true
|
25
34
|
|
26
|
-
def hosts
|
27
|
-
show_inventory :host_ids, :id
|
28
|
-
end
|
29
|
-
|
30
35
|
def hostgroups
|
31
36
|
show_inventory :hostgroup_ids, :hostgroup_id
|
32
37
|
end
|
data/app/models/ansible_role.rb
CHANGED
@@ -28,6 +28,12 @@ class AnsibleRole < ApplicationRecord
|
|
28
28
|
scoped_search :relation => :hostgroups,
|
29
29
|
:on => :name, :rename => :hostgroup, :only_explicit => true
|
30
30
|
|
31
|
+
apipie :class, "A class representing #{model_name.human} object" do
|
32
|
+
name 'Ansible role'
|
33
|
+
refs 'AnsibleRole'
|
34
|
+
sections only: %w[all additional]
|
35
|
+
property :name, String, desc: 'Returns name of the ansible role'
|
36
|
+
end
|
31
37
|
# Methods to be allowed in any template with safemode enabled
|
32
38
|
class Jail < Safemode::Jail
|
33
39
|
allow :name
|
@@ -67,6 +67,11 @@ end
|
|
67
67
|
|
68
68
|
module Host
|
69
69
|
class Managed
|
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 inherited ansible roles assigned to the host'
|
74
|
+
end
|
70
75
|
# Methods to be allowed in any template with safemode enabled
|
71
76
|
class Jail < Safemode::Jail
|
72
77
|
allow :all_ansible_roles, :ansible_roles, :inherited_ansible_roles
|
@@ -36,7 +36,7 @@ if defined? ForemanRemoteExecution
|
|
36
36
|
'per-host' => {
|
37
37
|
host.name => {
|
38
38
|
'ansible_ssh_pass' => rex_ssh_password(host),
|
39
|
-
'
|
39
|
+
'ansible_become_password' => rex_effective_user_password(host)
|
40
40
|
}
|
41
41
|
}
|
42
42
|
}
|
@@ -46,8 +46,8 @@ if defined? ForemanRemoteExecution
|
|
46
46
|
host_setting(host, 'remote_execution_ssh_password')
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
50
|
-
host_setting(host, '
|
49
|
+
def rex_effective_user_password(host)
|
50
|
+
host_setting(host, 'remote_execution_effective_user_password')
|
51
51
|
end
|
52
52
|
|
53
53
|
def host_setting(host, setting)
|
@@ -62,6 +62,18 @@ if defined? ForemanRemoteExecution
|
|
62
62
|
'ansible-runner'
|
63
63
|
end
|
64
64
|
|
65
|
+
def proxy_action_class
|
66
|
+
'ForemanAnsibleCore::TaskLauncher::Playbook::PlaybookRunnerAction'
|
67
|
+
end
|
68
|
+
|
69
|
+
def required_proxy_selector_for(template)
|
70
|
+
if template.remote_execution_features.where(:label => 'ansible_run_capsule_upgrade').any?
|
71
|
+
::DefaultProxyProxySelector.new
|
72
|
+
else
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
65
77
|
private
|
66
78
|
|
67
79
|
def ansible_command?(template)
|
@@ -9,7 +9,7 @@ module ForemanAnsible
|
|
9
9
|
included do
|
10
10
|
def host
|
11
11
|
hostname = name.downcase
|
12
|
-
if AnsibleReportScanner.ansible_report?(raw
|
12
|
+
if AnsibleReportScanner.ansible_report?(raw) &&
|
13
13
|
IPAddress.valid?(hostname) &&
|
14
14
|
Nic::Interface.find_by(:ip => hostname)
|
15
15
|
@host = Nic::Interface.find_by(:ip => hostname).host
|
@@ -5,14 +5,17 @@ module ForemanAnsible
|
|
5
5
|
# sets the origin of the report to 'Ansible'
|
6
6
|
class AnsibleReportScanner
|
7
7
|
class << self
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def add_reporter_data(report, raw); end
|
9
|
+
|
10
|
+
def identify_origin(raw)
|
11
|
+
'Ansible' if ansible_report?(raw)
|
12
|
+
end
|
13
|
+
|
14
|
+
def ansible_report?(raw)
|
15
|
+
raw['reporter'] == 'ansible' || ansible_legacy_report?(raw['logs'])
|
13
16
|
end
|
14
17
|
|
15
|
-
def
|
18
|
+
def ansible_legacy_report?(logs)
|
16
19
|
return false if logs.blank?
|
17
20
|
logs.any? do |log|
|
18
21
|
log['log'].fetch('messages', {}).
|
@@ -62,7 +62,7 @@ module ForemanAnsible
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def os_minor
|
65
|
-
_, minor =
|
65
|
+
_, minor = os_release&.split('.', 2) ||
|
66
66
|
(facts[:version].split('R') if os_name == 'junos')
|
67
67
|
# Until Foreman supports os.minor as something that's not a number,
|
68
68
|
# we should remove the extra dots in the version. E.g:
|
@@ -4,7 +4,18 @@ module ForemanAnsible
|
|
4
4
|
# Macro to fetch RH Insights plan playbook
|
5
5
|
module RendererMethods
|
6
6
|
extend ActiveSupport::Concern
|
7
|
+
extend ApipieDSL::Module
|
7
8
|
|
9
|
+
apipie :class, 'Macros related to Ansible playbooks' do
|
10
|
+
name 'Ansible'
|
11
|
+
sections only: %w[all jobs]
|
12
|
+
end
|
13
|
+
|
14
|
+
apipie :method, 'Returns Insights maintenance plan for host' do
|
15
|
+
required :plan_id, String, desc: 'The playbook for the rule coming from insights'
|
16
|
+
optional :organization_id, Integer, desc: 'The Foreman organization associated with the Insights account', default: 'Current organization ID'
|
17
|
+
returns String, desc: 'Insights maintenance plan for host'
|
18
|
+
end
|
8
19
|
def insights_remediation(plan_id, organization_id = Organization.current.id)
|
9
20
|
return "$INSIGHTS_REMEDIATION[#{plan_id}, #{organization_id}]" if preview?
|
10
21
|
|
@@ -48,22 +48,21 @@ module ForemanAnsible
|
|
48
48
|
def initialize_variables(variables, role)
|
49
49
|
variables.map do |variable_name, variable_default|
|
50
50
|
variable = AnsibleVariable.find_or_initialize_by(
|
51
|
-
:key => variable_name
|
51
|
+
:key => variable_name,
|
52
|
+
:ansible_role_id => role.id
|
52
53
|
)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
:imported => true)
|
57
|
-
end
|
58
|
-
variable.ansible_role = role
|
54
|
+
variable.assign_attributes(:default_value => variable_default,
|
55
|
+
:key_type => infer_key_type(variable_default))
|
56
|
+
variable.imported = true if variable.new_record?
|
59
57
|
variable.valid? ? variable : nil
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
63
61
|
def detect_changes(imported)
|
64
62
|
changes = {}.with_indifferent_access
|
65
|
-
persisted, changes[:new] = imported.partition { |
|
66
|
-
|
63
|
+
persisted, changes[:new] = imported.partition { |var| var.id.present? }
|
64
|
+
changed, _old = persisted.partition(&:changed?)
|
65
|
+
_overriden, changes[:update] = changed.partition(&:override?)
|
67
66
|
changes[:obsolete] = AnsibleVariable.where.not(:id => persisted.pluck(:id), :imported => false)
|
68
67
|
changes
|
69
68
|
end
|
@@ -15,7 +15,7 @@
|
|
15
15
|
) %>
|
16
16
|
|
17
17
|
<% version = Foreman::Version.new %>
|
18
|
-
<% if version.major.to_i
|
18
|
+
<% if version.major.to_i > 1 || version.minor.to_i >= 22 %>
|
19
19
|
<%= param_type_selector(f, false, :onchange => 'keyTypeChange(this)', :disabled => !f.object.override) %>
|
20
20
|
<% else %>
|
21
21
|
<%= param_type_selector(f, :onchange => 'keyTypeChange(this)', :disabled => !f.object.override) %>
|
@@ -15,7 +15,10 @@ model: JobTemplate
|
|
15
15
|
- name: Display all parameters known for the Foreman host
|
16
16
|
debug:
|
17
17
|
var: foreman
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
tasks:
|
19
|
+
- name: Apply roles
|
20
|
+
include_role:
|
21
|
+
name: "{{ role }}"
|
22
|
+
loop: "{{ foreman_ansible_roles }}"
|
23
|
+
loop_control:
|
24
|
+
loop_var: role
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<%#
|
2
|
+
name: Capsule Upgrade Playbook
|
3
|
+
snippet: false
|
4
|
+
template_inputs:
|
5
|
+
- name: target_version
|
6
|
+
required: true
|
7
|
+
input_type: user
|
8
|
+
advanced: false
|
9
|
+
value_type: plain
|
10
|
+
hidden_value: false
|
11
|
+
- name: whitelist_options
|
12
|
+
required: false
|
13
|
+
input_type: user
|
14
|
+
advanced: false
|
15
|
+
value_type: plain
|
16
|
+
hidden_value: false
|
17
|
+
model: JobTemplate
|
18
|
+
job_category: Maintenance Operations
|
19
|
+
description_format: "%{template_name}"
|
20
|
+
provider_type: Ansible
|
21
|
+
kind: job_template
|
22
|
+
feature: ansible_run_capsule_upgrade
|
23
|
+
%>
|
24
|
+
|
25
|
+
---
|
26
|
+
- hosts: all
|
27
|
+
tasks:
|
28
|
+
- name: Gather the rpm package facts
|
29
|
+
package_facts:
|
30
|
+
manager: auto
|
31
|
+
|
32
|
+
- name: Fail if the target server is a Satellite server
|
33
|
+
fail:
|
34
|
+
msg: "This playbook cannot be executed on a Satellite server. Use only on a Capsule server."
|
35
|
+
when: "'satellite' in ansible_facts.packages"
|
36
|
+
|
37
|
+
- name: Install satellite-maintain if not present
|
38
|
+
package:
|
39
|
+
name: rubygem-foreman_maintain
|
40
|
+
state: present
|
41
|
+
when: "'rubygem-foreman_maintain' not in ansible_facts.packages"
|
42
|
+
|
43
|
+
- block:
|
44
|
+
<%- whitelist_option = if input('whitelist_options').present?
|
45
|
+
"--whitelist=#{input('whitelist_options')}"
|
46
|
+
end -%>
|
47
|
+
- name: Upgrade Capsule server using satellite-maintain
|
48
|
+
shell: satellite-maintain upgrade run --assumeyes --target-version=<%= input('target_version') %> <%= whitelist_option %>
|
49
|
+
register: result
|
50
|
+
|
51
|
+
- name: Re-Gather the rpm package facts after the upgrade
|
52
|
+
package_facts:
|
53
|
+
manager: auto
|
54
|
+
|
55
|
+
- name: satellite-maintain upgrade return code is zero
|
56
|
+
debug:
|
57
|
+
msg: "Success! Capsule server upgrade completed. Current version of Capsule server server is {{ ansible_facts.packages['satellite-capsule'][0]['version'] }}."
|
58
|
+
|
59
|
+
rescue:
|
60
|
+
- name: Print satellite-maintain output
|
61
|
+
debug:
|
62
|
+
var: result
|
63
|
+
|
64
|
+
- name: Grep top 10 Error messages from /var/log/foreman-installer/capsule.log
|
65
|
+
shell: grep '^\[ERROR' /var/log/foreman-installer/capsule.log | head -n10
|
66
|
+
register: output_grep
|
67
|
+
|
68
|
+
- name: Print grepped Error messages
|
69
|
+
debug:
|
70
|
+
var: output_grep.stdout_lines
|
71
|
+
|
72
|
+
- name: satellite-maintain upgrade return code is non-zero
|
73
|
+
fail:
|
74
|
+
msg: "Failed! Capsule server upgrade failed. See /var/log/foreman-installer/capsule.log in the Capsule server for more information"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%#
|
2
|
+
name: Configure Cloud Connector
|
3
|
+
snippet: false
|
4
|
+
template_inputs:
|
5
|
+
- name: satellite_user
|
6
|
+
required: true
|
7
|
+
input_type: user
|
8
|
+
advanced: false
|
9
|
+
value_type: plain
|
10
|
+
hidden_value: false
|
11
|
+
- name: satellite_password
|
12
|
+
required: true
|
13
|
+
input_type: user
|
14
|
+
advanced: false
|
15
|
+
value_type: plain
|
16
|
+
hidden_value: true
|
17
|
+
- name: http_proxy
|
18
|
+
required: false
|
19
|
+
input_type: user
|
20
|
+
advanced: true
|
21
|
+
value_type: plain
|
22
|
+
hidden_value: false
|
23
|
+
description: You can specify a HTTP proxy address that should be used for Cloud Connector connection to the cloud.redhat.com. Note that it must be HTTP proxy, not HTTPS. The tunelling of SSL (secured web socket connection) in SSL (HTTPS proxy) is currently unsupported.
|
24
|
+
model: JobTemplate
|
25
|
+
job_category: Maintenance Operations
|
26
|
+
description_format: "%{template_name}"
|
27
|
+
provider_type: Ansible
|
28
|
+
kind: job_template
|
29
|
+
%>
|
30
|
+
|
31
|
+
---
|
32
|
+
- hosts: all
|
33
|
+
vars:
|
34
|
+
satellite_url: "<%= foreman_server_url %>"
|
35
|
+
roles:
|
36
|
+
- project-receptor.satellite_receptor_installer
|
@@ -18,4 +18,8 @@ model: JobTemplate
|
|
18
18
|
- hosts: all
|
19
19
|
tasks:
|
20
20
|
- command: |
|
21
|
-
puppet agent --onetime --no-usecacheonfailure --no-daemonize <%= input("puppet_options")
|
21
|
+
puppet agent --onetime --no-usecacheonfailure --no-daemonize <%= input("puppet_options") -%>
|
22
|
+
<% if @host.operatingsystem.family == 'Debian' -%>
|
23
|
+
environment:
|
24
|
+
PATH: "/opt/puppetlabs/bin:{{ (ansible_env|default({})).PATH|default('') }}"
|
25
|
+
<% end -%>
|
data/config/routes.rb
CHANGED
@@ -72,7 +72,7 @@ Rails.application.routes.draw do
|
|
72
72
|
:module => :v2,
|
73
73
|
:defaults => { :apiv => 'v2' },
|
74
74
|
:apiv => /v1|v2/,
|
75
|
-
:constraints => ApiConstraints.new(:version => 2) do
|
75
|
+
:constraints => ApiConstraints.new(:version => 2, :default => true) do
|
76
76
|
resources :ansible_roles, :only => [:show, :index, :destroy] do
|
77
77
|
collection do
|
78
78
|
put :import
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class UpdateAnsibleInvTemplateName < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
Setting.where(:name => 'ansible_inventory_template').update_all(:default => 'Ansible - Ansible Inventory')
|
4
|
+
end
|
5
|
+
|
6
|
+
def down
|
7
|
+
Setting.where(:name => 'ansible_inventory_template').update_all(:default => 'Ansible Inventory')
|
8
|
+
end
|
9
|
+
end
|
@@ -18,7 +18,7 @@ User.as_anonymous_admin do
|
|
18
18
|
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
|
19
19
|
template = JobTemplate.import_raw!(File.read(template),
|
20
20
|
:default => true,
|
21
|
-
:
|
21
|
+
:lock => true,
|
22
22
|
:update => sync)
|
23
23
|
template.organizations = organizations if template.present?
|
24
24
|
template.locations = locations if template.present?
|
@@ -71,32 +71,29 @@ module ForemanAnsible
|
|
71
71
|
end
|
72
72
|
|
73
73
|
config.to_prepare do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
::
|
82
|
-
|
83
|
-
ForemanAnsible::StructuredFactImporter
|
84
|
-
)
|
85
|
-
end
|
86
|
-
::FactParser.register_fact_parser(:ansible, ForemanAnsible::FactParser)
|
87
|
-
::Host::Managed.prepend ForemanAnsible::HostManagedExtensions
|
88
|
-
::Hostgroup.include ForemanAnsible::HostgroupExtensions
|
89
|
-
::HostsHelper.include ForemanAnsible::HostsHelperExtensions
|
90
|
-
::HostsController.include ForemanAnsible::Concerns::HostsControllerExtensions
|
91
|
-
::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsControllerExtensions
|
92
|
-
::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsParamGroupExtensions
|
93
|
-
::HostgroupsController.include ForemanAnsible::Concerns::HostgroupsControllerExtensions
|
94
|
-
::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsControllerExtensions
|
95
|
-
::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsParamGroupExtensions
|
96
|
-
::ConfigReportImporter.include ForemanAnsible::AnsibleReportImporter
|
97
|
-
rescue StandardError => e
|
98
|
-
Rails.logger.warn "Foreman Ansible: skipping engine hook (#{e})"
|
74
|
+
foreman_version = ::Foreman::Version.new
|
75
|
+
if Rails.env.test? ||
|
76
|
+
foreman_version.major.to_i == 1 && foreman_version.minor.to_i < 13
|
77
|
+
::Foreman::Plugin.fact_importer_registry.register(:ansible, ForemanAnsible::FactImporter)
|
78
|
+
else
|
79
|
+
::Foreman::Plugin.fact_importer_registry.register(
|
80
|
+
:ansible,
|
81
|
+
ForemanAnsible::StructuredFactImporter
|
82
|
+
)
|
99
83
|
end
|
84
|
+
::FactParser.register_fact_parser(:ansible, ForemanAnsible::FactParser)
|
85
|
+
::Host::Managed.prepend ForemanAnsible::HostManagedExtensions
|
86
|
+
::Hostgroup.include ForemanAnsible::HostgroupExtensions
|
87
|
+
::HostsHelper.include ForemanAnsible::HostsHelperExtensions
|
88
|
+
::HostsController.include ForemanAnsible::Concerns::HostsControllerExtensions
|
89
|
+
::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsControllerExtensions
|
90
|
+
::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsParamGroupExtensions
|
91
|
+
::HostgroupsController.include ForemanAnsible::Concerns::HostgroupsControllerExtensions
|
92
|
+
::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsControllerExtensions
|
93
|
+
::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsParamGroupExtensions
|
94
|
+
::ConfigReportImporter.include ForemanAnsible::AnsibleReportImporter
|
95
|
+
rescue StandardError => e
|
96
|
+
Rails.logger.warn "Foreman Ansible: skipping engine hook (#{e})"
|
100
97
|
end
|
101
98
|
|
102
99
|
rake_tasks do
|