foreman_ansible 6.0.2 → 6.4.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/ansible_roles_controller.rb +12 -8
- data/app/controllers/ansible_variables_controller.rb +4 -0
- data/app/controllers/api/v2/ansible_inventories_controller.rb +2 -2
- data/app/controllers/api/v2/ansible_roles_controller.rb +32 -11
- data/app/controllers/api/v2/ansible_variables_controller.rb +6 -4
- data/app/controllers/foreman_ansible/concerns/import_controller_helper.rb +3 -3
- data/app/helpers/foreman_ansible/ansible_reports_helper.rb +42 -56
- data/app/helpers/foreman_ansible/ansible_roles_data_preparations.rb +95 -0
- data/app/helpers/foreman_ansible/ansible_roles_helper.rb +20 -1
- data/app/jobs/sync_roles_and_variables.rb +20 -0
- data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +10 -7
- data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +19 -4
- data/app/models/foreman_ansible/ansible_provider.rb +52 -2
- data/app/models/host_ansible_role.rb +1 -0
- data/app/models/hostgroup_ansible_role.rb +1 -0
- data/app/models/setting/ansible.rb +9 -0
- data/app/services/foreman_ansible/ansible_report_importer.rb +4 -0
- data/app/services/foreman_ansible/ansible_report_scanner.rb +15 -1
- data/app/services/foreman_ansible/api_roles_importer.rb +23 -11
- data/app/services/foreman_ansible/fact_parser.rb +21 -1
- data/app/services/foreman_ansible/import_roles_and_variables_error_notification.rb +31 -0
- data/app/services/foreman_ansible/import_roles_and_variables_success_notification.rb +26 -0
- data/app/services/foreman_ansible/inventory_creator.rb +3 -7
- data/app/services/foreman_ansible/operating_system_parser.rb +8 -2
- data/app/services/foreman_ansible/roles_importer.rb +3 -2
- data/app/services/foreman_ansible/ui_roles_importer.rb +2 -2
- data/app/services/foreman_ansible/variables_importer.rb +36 -1
- data/app/views/ansible_roles/import.html.erb +10 -50
- data/app/views/ansible_variables/index.html.erb +1 -2
- data/app/views/api/v2/ansible_roles/sync.json.rabl +5 -0
- data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +8 -17
- data/app/views/foreman_ansible/config_reports/_ansible.html.erb +24 -8
- data/app/views/foreman_ansible/job_templates/ansible_collections_-_install_from_galaxy.erb +28 -0
- data/app/views/foreman_ansible/job_templates/ansible_roles_-_ansible_default.erb +4 -0
- data/app/views/foreman_ansible/job_templates/ansible_roles_-_install_from_galaxy.erb +1 -1
- data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +2 -3
- data/app/views/foreman_ansible/job_templates/convert_to_rhel.erb +44 -0
- data/config/routes.rb +5 -4
- data/db/migrate/20210120150019_add_position_to_ansible_role.rb +27 -0
- data/db/seeds.d/100_common_parameters.rb +7 -0
- data/db/seeds.d/90_notification_blueprints.rb +19 -1
- data/lib/foreman_ansible/engine.rb +1 -1
- data/lib/foreman_ansible/register.rb +7 -5
- data/lib/foreman_ansible/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ca/foreman_ansible.po +1 -1
- data/locale/cs_CZ/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/cs_CZ/foreman_ansible.po +1 -1
- data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/de/foreman_ansible.po +1 -1
- data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en/foreman_ansible.po +1 -1
- data/locale/en_GB/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en_GB/foreman_ansible.po +1 -1
- data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/es/foreman_ansible.po +1 -1
- data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/fr/foreman_ansible.po +1 -1
- data/locale/gl/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/gl/foreman_ansible.po +1 -1
- data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/it/foreman_ansible.po +1 -1
- data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ja/foreman_ansible.po +1 -1
- data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ko/foreman_ansible.po +1 -1
- data/locale/nl_NL/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/nl_NL/foreman_ansible.po +1 -1
- data/locale/pl/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pl/foreman_ansible.po +1 -1
- data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pt_BR/foreman_ansible.po +1 -1
- data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ru/foreman_ansible.po +1 -1
- data/locale/sv_SE/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/sv_SE/foreman_ansible.po +1 -1
- data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_CN/foreman_ansible.po +1 -1
- data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_TW/foreman_ansible.po +1 -1
- data/package.json +13 -42
- data/test/factories/ansible_roles.rb +12 -0
- data/test/factories/host_ansible_enhancements.rb +23 -0
- data/test/foreman_ansible/helpers/ansible_roles_helper_test.rb +45 -0
- data/test/functional/ansible_variables_controller_test.rb +0 -15
- data/test/functional/api/v2/ansible_roles_controller_test.rb +23 -0
- data/test/functional/api/v2/hostgroups_controller_test.rb +5 -4
- data/test/functional/api/v2/hosts_controller_test.rb +9 -8
- data/test/functional/hosts_controller_test.rb +10 -6
- data/test/unit/concerns/host_managed_extensions_test.rb +17 -3
- data/test/unit/concerns/hostgroup_extensions_test.rb +13 -7
- data/test/unit/helpers/ansible_reports_helper_test.rb +4 -30
- data/test/unit/host_ansible_role_test.rb +2 -1
- data/test/unit/hostgroup_ansible_role_test.rb +2 -1
- data/test/unit/ignore_roles_test.rb +43 -0
- data/test/unit/import_roles_and_variables.rb +60 -0
- data/test/unit/services/ansible_variables_importer_test.rb +13 -0
- data/test/unit/services/api_roles_importer_test.rb +22 -5
- data/test/unit/services/fact_parser_test.rb +16 -0
- data/test/unit/services/inventory_creator_test.rb +15 -7
- data/test/unit/services/ui_roles_importer_test.rb +2 -2
- data/webpack/components/AnsibleHostDetail/AnsibleHostDetail.js +35 -0
- data/webpack/components/AnsibleHostDetail/AnsibleHostDetail.scss +6 -0
- data/webpack/components/AnsibleHostDetail/AnsibleHostDetail.test.js +14 -0
- data/webpack/components/AnsibleHostDetail/index.js +6 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.js +178 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.scss +9 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js +39 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesConstants.js +4 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesHelpers.js +11 -0
- data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesHelpers.test.js +50 -0
- data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesImport.test.js +39 -0
- data/webpack/components/AnsibleRolesAndVariables/__test__/__snapshots__/AnsibleRolesAndVariablesImport.test.js.snap +177 -0
- data/webpack/components/AnsibleRolesAndVariables/index.js +31 -0
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js +25 -27
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss +1 -1
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js +20 -14
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherConstants.js +1 -2
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js +13 -8
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherSelectors.js +8 -28
- data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js +1 -0
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcher.test.js +6 -4
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js +1 -9
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js +3 -16
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcher.test.js.snap +4 -8
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherReducer.test.js.snap +8 -97
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherSelectors.test.js.snap +5 -30
- data/webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.test.js +1 -1
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +5 -2
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.test.js +1 -1
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.js +43 -0
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.test.js +19 -0
- data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js +63 -51
- data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js +4 -1
- data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.test.js +1 -1
- data/webpack/components/AnsibleRolesSwitcher/components/OrderedRolesTooltip.js +23 -0
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsiblePermissionDenied.test.js.snap +2 -0
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRoleInputs.test.js.snap +51 -0
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap +28 -28
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AvailableRolesList.test.js.snap +5 -0
- data/webpack/components/AnsibleRolesSwitcher/index.js +4 -8
- data/webpack/global_index.js +12 -0
- data/webpack/index.js +6 -13
- metadata +54 -30
- data/app/views/ansible_variables/import.html.erb +0 -56
- data/test/unit/lib/foreman_ansible_core/ansible_runner_test.rb +0 -51
- data/test/unit/lib/foreman_ansible_core/command_creator_test.rb +0 -64
- data/test/unit/lib/foreman_ansible_core/playbook_runner_test.rb +0 -110
- data/webpack/__mocks__/foremanReact/common/I18n.js +0 -1
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +0 -2
- data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +0 -5
- data/webpack/test_setup.js +0 -12
@@ -7,6 +7,7 @@ module ForemanAnsible
|
|
7
7
|
|
8
8
|
def initialize(proxy = nil)
|
9
9
|
@ansible_proxy = proxy
|
10
|
+
@variables_importer = ForemanAnsible::VariablesImporter.new(@ansible_proxy)
|
10
11
|
end
|
11
12
|
|
12
13
|
def import_role_names
|
@@ -26,8 +27,8 @@ module ForemanAnsible
|
|
26
27
|
|
27
28
|
def detect_changes(imported)
|
28
29
|
changes = {}.with_indifferent_access
|
29
|
-
old, changes[:new] = imported.partition { |role| role.id.present? }
|
30
|
-
changes[:obsolete] = ::AnsibleRole.where.not(:id => old.map(&:id))
|
30
|
+
changes[:old], changes[:new] = imported.partition { |role| role.id.present? }
|
31
|
+
changes[:obsolete] = ::AnsibleRole.where.not(:id => changes[:old].map(&:id))
|
31
32
|
changes
|
32
33
|
end
|
33
34
|
|
@@ -15,13 +15,13 @@ module ForemanAnsible
|
|
15
15
|
|
16
16
|
def create_new_roles(changes)
|
17
17
|
changes.each_pair do |_, new_role|
|
18
|
-
::AnsibleRole.create(
|
18
|
+
::AnsibleRole.create(new_role)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def delete_old_roles(changes)
|
23
23
|
changes.each_pair do |_, old_role|
|
24
|
-
::AnsibleRole.find(
|
24
|
+
::AnsibleRole.find(old_role['id']).destroy
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -26,6 +26,10 @@ module ForemanAnsible
|
|
26
26
|
import_variables(local_variables, new_roles)
|
27
27
|
end
|
28
28
|
|
29
|
+
def get_variables_names(role_name)
|
30
|
+
remote_variables[role_name]
|
31
|
+
end
|
32
|
+
|
29
33
|
def import_variables(role_variables, new_roles)
|
30
34
|
detect_changes(
|
31
35
|
role_variables.map do |role_name, variables|
|
@@ -37,6 +41,34 @@ module ForemanAnsible
|
|
37
41
|
)
|
38
42
|
end
|
39
43
|
|
44
|
+
def import_variables_roles(roles)
|
45
|
+
if roles['new']
|
46
|
+
imported_roles = roles['new'].keys
|
47
|
+
variables_to_import = {}
|
48
|
+
remote_variables.each do |role, variables|
|
49
|
+
next unless imported_roles.include? role
|
50
|
+
role_obj = AnsibleRole.find_by(:name => role)
|
51
|
+
variables_to_import[role] = {}
|
52
|
+
values = initialize_variables(variables, role_obj)
|
53
|
+
values.each do |value|
|
54
|
+
variables_to_import[role][value.key] = value.attributes.to_json
|
55
|
+
end
|
56
|
+
end
|
57
|
+
create_new_variables(variables_to_import)
|
58
|
+
end
|
59
|
+
return if roles['old'].empty?
|
60
|
+
variables_to_update = { 'new' => {}, 'obsolete' => {}, 'update' => {} }
|
61
|
+
import_variable_names([]).each do |kind, variables|
|
62
|
+
variables.each do |variable|
|
63
|
+
next unless roles['old'].values.map { |role| role['id'] }.include?(variable.ansible_role_id)
|
64
|
+
role_name = variable.ansible_role.name
|
65
|
+
variables_to_update[kind][role_name] ||= {}
|
66
|
+
variables_to_update[kind][role_name][variable.key] = variable.attributes.to_json
|
67
|
+
end
|
68
|
+
end
|
69
|
+
finish_import(variables_to_update['new'], variables_to_update['obsolete'], variables_to_update['update'])
|
70
|
+
end
|
71
|
+
|
40
72
|
def import_new_role(role_name, new_roles)
|
41
73
|
role = AnsibleRole.find_by(:name => role_name)
|
42
74
|
if role.blank? && new_roles.map(&:name).include?(role_name)
|
@@ -51,7 +83,8 @@ module ForemanAnsible
|
|
51
83
|
:key => variable_name,
|
52
84
|
:ansible_role_id => role.id
|
53
85
|
)
|
54
|
-
variable.assign_attributes(:
|
86
|
+
variable.assign_attributes(:hidden_value => false,
|
87
|
+
:default_value => variable_default,
|
55
88
|
:key_type => infer_key_type(variable_default))
|
56
89
|
variable.imported = true if variable.new_record?
|
57
90
|
variable.valid? ? variable : nil
|
@@ -80,6 +113,8 @@ module ForemanAnsible
|
|
80
113
|
variable = AnsibleVariable.new(
|
81
114
|
JSON.parse(attrs)
|
82
115
|
)
|
116
|
+
# Make sure, newly created variables are not hidden
|
117
|
+
variable.hidden_value = false
|
83
118
|
variable.ansible_role = ::AnsibleRole.find_by(:name => role)
|
84
119
|
variable.save
|
85
120
|
memo << variable
|
@@ -1,51 +1,11 @@
|
|
1
1
|
<% title _("Changed Ansible roles") %>
|
2
|
-
<%=
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
</h6>
|
13
|
-
<table class="<%= table_css_classes %>">
|
14
|
-
<thead>
|
15
|
-
<tr>
|
16
|
-
<th class="ca">
|
17
|
-
<%= link_to_function(icon_text("check"),
|
18
|
-
"toggleCheckboxesBySelector('.role_select_boxes')",
|
19
|
-
:title => _("Check/Uncheck all")) %>
|
20
|
-
</th>
|
21
|
-
<th><%= _("Name") %></th>
|
22
|
-
<th class="col-md-2"><%= _("Hosts count") %></th>
|
23
|
-
<th class="col-md-2"><%= _("Hostgroups count") %></th>
|
24
|
-
<th><%= _("Operation") %></th>
|
25
|
-
</tr>
|
26
|
-
</thead>
|
27
|
-
<tbody>
|
28
|
-
<% changed.each do |kind, roles| %>
|
29
|
-
<% roles.each do |role| %>
|
30
|
-
<tr>
|
31
|
-
<td>
|
32
|
-
<%= check_box_tag "changed[#{kind}][#{role}]", role.to_json, false, :class => "role_select_boxes role_select_boxes_#{kind} role_select_boxes_role_#{role}" %>
|
33
|
-
</td>
|
34
|
-
<td>
|
35
|
-
<%= link_to_function("#{role}", "toggleCheckboxesBySelector('.role_select_boxes_role_#{role}')", :title => _("Check/Uncheck all %s changes") % role) %>
|
36
|
-
</td>
|
37
|
-
<td><%= role.hosts.count %></td>
|
38
|
-
<td><%= role.hostgroups.count %></td>
|
39
|
-
<td>
|
40
|
-
<%= { "new" => _("Add"), "obsolete" => _("Remove") }[kind] %>
|
41
|
-
</td>
|
42
|
-
</tr>
|
43
|
-
<% end %>
|
44
|
-
<% end %>
|
45
|
-
</tbody>
|
46
|
-
</table>
|
47
|
-
<div>
|
48
|
-
<%= link_to _("Cancel"), ansible_roles_path, :class => "btn btn-default" %>
|
49
|
-
<%= submit_tag _("Update"), :class => "btn btn-primary" %>
|
50
|
-
</div>
|
51
|
-
<% end %>
|
2
|
+
<%= webpacked_plugins_js_for :foreman_ansible %>
|
3
|
+
<%= webpacked_plugins_css_for :foreman_ansible %>
|
4
|
+
|
5
|
+
|
6
|
+
<%= react_component(
|
7
|
+
'WrappedImportRolesAndVariables',
|
8
|
+
:rowsData => @rows,
|
9
|
+
:proxy => @proxy.id
|
10
|
+
) %>
|
11
|
+
|
@@ -1,8 +1,7 @@
|
|
1
1
|
<% title _("Ansible Variables") %>
|
2
2
|
<%= stylesheet 'foreman_ansible/foreman-ansible' %>
|
3
3
|
|
4
|
-
<%= title_actions
|
5
|
-
display_link_if_authorized(_('New Ansible Variable'), hash_for_new_ansible_variable_path, :class => "btn btn-default no-float"),
|
4
|
+
<%= title_actions display_link_if_authorized(_('New Ansible Variable'), hash_for_new_ansible_variable_path, :class => "btn btn-default no-float"),
|
6
5
|
documentation_button('#4.3Variables', :root_url => ansible_doc_url)
|
7
6
|
%>
|
8
7
|
|
@@ -2,22 +2,13 @@
|
|
2
2
|
<%= webpacked_plugins_css_for :foreman_ansible %>
|
3
3
|
|
4
4
|
<div class='tab-pane' id='ansible_roles'>
|
5
|
-
<% roles = f.object.is_a?(Hostgroup) ? roles_attrs(f.object.inherited_and_own_ansible_roles) : roles_attrs(f.object.all_ansible_roles) %>
|
6
5
|
<% class_name = f.object.is_a?(Hostgroup) ? 'Hostgroup' : 'Host' %>
|
7
|
-
<%=
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
:canView => User.current.can?(:view_ansible_roles)
|
16
|
-
}.to_json
|
17
|
-
) %>
|
18
|
-
<% unless request.xhr? %>
|
19
|
-
<script type="text/javascript">
|
20
|
-
tfm.initAnsibleRoleSwitcher();
|
21
|
-
</script>
|
22
|
-
<% end %>
|
6
|
+
<%= react_component('AnsibleRolesSwitcher', {
|
7
|
+
:initialAssignedRoles => role_attributes_for_roles_switcher(f.object),
|
8
|
+
:inheritedRoleIds => f.object.inherited_ansible_roles.map(&:id),
|
9
|
+
:availableRolesUrl => ui_ansible_roles_path,
|
10
|
+
:resourceId => f.object.id,
|
11
|
+
:resourceName => class_name,
|
12
|
+
:canView => User.current.can?(:view_ansible_roles)
|
13
|
+
}) %>
|
23
14
|
</div>
|
@@ -1,23 +1,39 @@
|
|
1
1
|
<%= webpacked_plugins_js_for :foreman_ansible %>
|
2
2
|
<%= stylesheet 'foreman_ansible/foreman-ansible' %>
|
3
|
+
<% if ansible_run_in_check_mode?(logs.first) %>
|
4
|
+
<%= alert :class => 'alert-info',
|
5
|
+
:header => _('Ansible check mode'),
|
6
|
+
:text => _('Notice that ansible roles run in check mode.')%>
|
3
7
|
|
8
|
+
<% end %>
|
4
9
|
<table id='report_log' class="<%= table_css_classes %>">
|
5
10
|
<thead>
|
6
11
|
<tr>
|
7
12
|
<th><%= _("Level") %></th>
|
8
|
-
<th><%= _("
|
9
|
-
<th><%= _("Arguments") %></th>
|
13
|
+
<th><%= _("Task") %></th>
|
10
14
|
<th><%= _("Message") %></th>
|
11
15
|
</tr>
|
12
16
|
</thead>
|
13
17
|
<tbody>
|
14
18
|
<% logs.each do |log| %>
|
15
|
-
|
16
|
-
<
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
<% unless check_mode_log?(log) %>
|
20
|
+
<tr>
|
21
|
+
<td><span <%= report_tag log.level %>><%= h log.level %></span></td>
|
22
|
+
<td><span title=<%= ansible_module_name(log) %>><%= ansible_task_name(log) %></span></td>
|
23
|
+
<td>
|
24
|
+
<% log_message = ansible_module_message(log) %>
|
25
|
+
<% if log_message.is_a? Array %>
|
26
|
+
<ul>
|
27
|
+
<% log_message.each do |message_line| %>
|
28
|
+
<li><%= message_line %></li>
|
29
|
+
<% end %>
|
30
|
+
</ul>
|
31
|
+
<% else %>
|
32
|
+
<%= log_message %>
|
33
|
+
<% end %>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
<% end %>
|
21
37
|
<% end %>
|
22
38
|
<tr id='ntsh' <%= "style='display: none;'".html_safe if logs.size > 0%>><td colspan="3">
|
23
39
|
<%= _("Nothing to show") %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%#
|
2
|
+
name: Ansible Collection - Install from Galaxy
|
3
|
+
job_category: Ansible Galaxy
|
4
|
+
description_format: Install collections '%{ansible_collections_list}' from Galaxy
|
5
|
+
snippet: false
|
6
|
+
template_inputs:
|
7
|
+
- name: ansible_collections_list
|
8
|
+
required: true
|
9
|
+
input_type: user
|
10
|
+
description: "List of collections in Ansible Galaxy to install, separated by commas, e.g:
|
11
|
+
mysql,nginx\r\n\r\nThe default collections_paths is configured in /etc/ansible/ansible.cfg,
|
12
|
+
you may override it by filling the 'collections_path' input.
|
13
|
+
Click on \"Advanced\" to see it."
|
14
|
+
advanced: false
|
15
|
+
- name: collections_path
|
16
|
+
required: false
|
17
|
+
input_type: user
|
18
|
+
description: A particular directory where you want the downloaded collections to be placed.
|
19
|
+
advanced: true
|
20
|
+
provider_type: Ansible
|
21
|
+
kind: job_template
|
22
|
+
model: JobTemplate
|
23
|
+
%>
|
24
|
+
|
25
|
+
---
|
26
|
+
- hosts: all
|
27
|
+
tasks:
|
28
|
+
- command: ansible-galaxy collection install <%= input('ansible_collections_list').split(",").join(' ') %> -p <%= input('collections_path').present? ? input('collections_path') : '/etc/ansible/collections' %>
|
@@ -15,10 +15,14 @@ model: JobTemplate
|
|
15
15
|
- name: Display all parameters known for the Foreman host
|
16
16
|
debug:
|
17
17
|
var: foreman
|
18
|
+
tags:
|
19
|
+
- always
|
18
20
|
tasks:
|
19
21
|
- name: Apply roles
|
20
22
|
include_role:
|
21
23
|
name: "{{ role }}"
|
24
|
+
tags:
|
25
|
+
- always
|
22
26
|
loop: "{{ foreman_ansible_roles }}"
|
23
27
|
loop_control:
|
24
28
|
loop_var: role
|
@@ -25,7 +25,7 @@ model: JobTemplate
|
|
25
25
|
---
|
26
26
|
- hosts: all
|
27
27
|
tasks:
|
28
|
-
- command: ansible-galaxy install {{ item }}
|
28
|
+
- command: ansible-galaxy install {{ item }} -p <%= input('location').present? ? input('location') : '/etc/ansible/roles' %>
|
29
29
|
register: out
|
30
30
|
with_items:
|
31
31
|
- <%= input('ansible_roles_list') %>
|
@@ -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?
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<%#
|
2
|
+
name: Convert to RHEL
|
3
|
+
snippet: false
|
4
|
+
template_inputs:
|
5
|
+
- name: Activation Key
|
6
|
+
required: true
|
7
|
+
input_type: user
|
8
|
+
advanced: false
|
9
|
+
value_type: plain
|
10
|
+
resource_type: Katello::ActivationKey
|
11
|
+
hidden_value: false
|
12
|
+
- name: Restart
|
13
|
+
required: true
|
14
|
+
input_type: user
|
15
|
+
options: "yes\r\nno"
|
16
|
+
advanced: false
|
17
|
+
value_type: plain
|
18
|
+
resource_type: Katello::ActivationKey
|
19
|
+
hidden_value: false
|
20
|
+
model: JobTemplate
|
21
|
+
job_category: Convert 2 RHEL
|
22
|
+
provider_type: Ansible
|
23
|
+
kind: job_template
|
24
|
+
%>
|
25
|
+
---
|
26
|
+
- hosts: all
|
27
|
+
tasks:
|
28
|
+
- name: Install convert2rhel
|
29
|
+
ansible.builtin.package:
|
30
|
+
name: convert2rhel
|
31
|
+
state: present
|
32
|
+
- name: Prepopulate katello-ca-consumer
|
33
|
+
get_url:
|
34
|
+
url: <%= subscription_manager_configuration_url(@host) %>
|
35
|
+
dest: /usr/share/convert2rhel/subscription-manager/katello-ca-consumer-latest.noarch.rpm
|
36
|
+
- name: Start convert2rhel
|
37
|
+
command: convert2rhel -y --activationkey "<%= input('Activation Key') %>" --org "<%= @host.organization.label %>" > /root/convert2rhel.log
|
38
|
+
<%- if input('Restart') == "yes" -%>
|
39
|
+
- name: Reboot the machine
|
40
|
+
reboot:
|
41
|
+
reboot_timeout: 1800
|
42
|
+
<%- end -%>
|
43
|
+
- name: Update system facts
|
44
|
+
command: subscription-manager facts --update
|
data/config/routes.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Rails.application.routes.draw do
|
4
|
-
namespace :api do
|
4
|
+
namespace :api, defaults: { format: 'json' } do
|
5
5
|
scope '(:apiv)',
|
6
6
|
:module => :v2,
|
7
|
-
:defaults => { :
|
8
|
-
:apiv => /
|
9
|
-
:constraints => ApiConstraints.new(:
|
7
|
+
:defaults => { apiv: 'v2' },
|
8
|
+
:apiv => /v2/,
|
9
|
+
:constraints => ApiConstraints.new(version: 2, default: true) do
|
10
10
|
constraints(:id => %r{[^\/]+}) do
|
11
11
|
resources :hosts, :only => [] do
|
12
12
|
member do
|
@@ -76,6 +76,7 @@ Rails.application.routes.draw do
|
|
76
76
|
resources :ansible_roles, :only => [:show, :index, :destroy] do
|
77
77
|
collection do
|
78
78
|
put :import
|
79
|
+
put :sync
|
79
80
|
put :obsolete
|
80
81
|
get :fetch
|
81
82
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class AddPositionToAnsibleRole < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
add_column :host_ansible_roles, :position, :integer
|
4
|
+
add_column :hostgroup_ansible_roles, :position, :integer
|
5
|
+
|
6
|
+
update_hostgroup_ansible_roles
|
7
|
+
update_host_ansible_roles
|
8
|
+
change_column_null :host_ansible_roles, :position, false
|
9
|
+
change_column_null :hostgroup_ansible_roles, :position, false
|
10
|
+
end
|
11
|
+
|
12
|
+
def update_host_ansible_roles
|
13
|
+
HostAnsibleRole.all.pluck(:host_id, :id).group_by(&:first).each do |_host_id, role_ids|
|
14
|
+
role_ids.each_with_index do |(_host_id, host_role_id), idx|
|
15
|
+
HostAnsibleRole.find(host_role_id).update(position: idx + 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_hostgroup_ansible_roles
|
21
|
+
HostgroupAnsibleRole.all.pluck(:hostgroup_id, :id).group_by(&:first).each do |_hostgroup_id, role_ids|
|
22
|
+
role_ids.each_with_index do |(_hostgroup_id, hostgroup_role_id), idx|
|
23
|
+
HostgroupAnsibleRole.find(hostgroup_role_id).update(position: idx + 1)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -13,7 +13,25 @@ blueprints = [
|
|
13
13
|
:title => N_('Job Details')
|
14
14
|
]
|
15
15
|
}
|
16
|
+
},
|
17
|
+
{
|
18
|
+
:group => N_('Roles'),
|
19
|
+
:name => 'Sync_roles_and_variables_successfully',
|
20
|
+
:message => N_('Import roles and variables has finished successfully'),
|
21
|
+
:level => 'success',
|
22
|
+
:actions => {
|
23
|
+
:links => [
|
24
|
+
:path_method => :ansible_roles_path,
|
25
|
+
:title => N_('Roles')
|
26
|
+
]
|
27
|
+
}
|
28
|
+
},
|
29
|
+
{
|
30
|
+
:group => N_('Roles'),
|
31
|
+
:name => 'Sync_roles_and_variables_failed',
|
32
|
+
:message => 'DYNAMIC',
|
33
|
+
:level => 'error'
|
16
34
|
}
|
17
|
-
]
|
18
35
|
|
36
|
+
]
|
19
37
|
blueprints.each { |blueprint| UINotifications::Seed.new(blueprint).configure }
|