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
@@ -25,7 +25,7 @@ Foreman::Plugin.register :foreman_ansible do
|
|
25
25
|
:resource_type => 'AnsibleRole'
|
26
26
|
permission :import_ansible_roles,
|
27
27
|
{ :ansible_roles => [:import, :confirm_import],
|
28
|
-
:'api/v2/ansible_roles' => [:import] },
|
28
|
+
:'api/v2/ansible_roles' => [:import, :sync] },
|
29
29
|
:resource_type => 'AnsibleRole'
|
30
30
|
permission :view_ansible_variables,
|
31
31
|
{
|
@@ -91,10 +91,12 @@ Foreman::Plugin.register :foreman_ansible do
|
|
91
91
|
extend_template_helpers ForemanAnsible::RendererMethods
|
92
92
|
allowed_template_helpers :insights_remediation
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
parameter_filter Host::Managed,
|
97
|
-
parameter_filter Hostgroup,
|
94
|
+
base_role_assignment_params = { :ansible_role_ids => [],
|
95
|
+
:ansible_roles => [] }
|
96
|
+
parameter_filter Host::Managed, base_role_assignment_params.merge(:host_ansible_roles_attributes => {})
|
97
|
+
parameter_filter Hostgroup, base_role_assignment_params.merge(:hostgroup_ansible_roles_attributes => {})
|
98
|
+
|
99
|
+
register_global_js_file 'global'
|
98
100
|
|
99
101
|
divider :top_menu, :caption => N_('Ansible'), :parent => :configure_menu
|
100
102
|
menu :top_menu, :ansible_roles,
|
Binary file
|
@@ -8,7 +8,7 @@
|
|
8
8
|
#
|
9
9
|
msgid ""
|
10
10
|
msgstr ""
|
11
|
-
"Project-Id-Version: foreman_ansible
|
11
|
+
"Project-Id-Version: foreman_ansible 3.0.2\n"
|
12
12
|
"Report-Msgid-Bugs-To: \n"
|
13
13
|
"PO-Revision-Date: 2018-11-14 21:36+0000\n"
|
14
14
|
"Last-Translator: Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>, 2019\n"
|
Binary file
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#
|
10
10
|
msgid ""
|
11
11
|
msgstr ""
|
12
|
-
"Project-Id-Version: foreman_ansible
|
12
|
+
"Project-Id-Version: foreman_ansible 3.0.2\n"
|
13
13
|
"Report-Msgid-Bugs-To: \n"
|
14
14
|
"PO-Revision-Date: 2018-11-14 21:36+0000\n"
|
15
15
|
"Last-Translator: Pavel Borecki <pavel.borecki@gmail.com>, 2020\n"
|
Binary file
|
Binary file
|
Binary file
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#
|
10
10
|
msgid ""
|
11
11
|
msgstr ""
|
12
|
-
"Project-Id-Version: foreman_ansible
|
12
|
+
"Project-Id-Version: foreman_ansible 3.0.2\n"
|
13
13
|
"Report-Msgid-Bugs-To: \n"
|
14
14
|
"PO-Revision-Date: 2018-11-14 21:36+0000\n"
|
15
15
|
"Last-Translator: Andi Chandler <andi@gowling.com>, 2019\n"
|
Binary file
|
Binary file
|
Binary file
|
@@ -8,7 +8,7 @@
|
|
8
8
|
#
|
9
9
|
msgid ""
|
10
10
|
msgstr ""
|
11
|
-
"Project-Id-Version: foreman_ansible
|
11
|
+
"Project-Id-Version: foreman_ansible 3.0.2\n"
|
12
12
|
"Report-Msgid-Bugs-To: \n"
|
13
13
|
"PO-Revision-Date: 2018-11-14 21:36+0000\n"
|
14
14
|
"Last-Translator: Carmela Rubiños <carmela.rubinos@gmail.com>, 2019\n"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -13,7 +13,7 @@
|
|
13
13
|
#
|
14
14
|
msgid ""
|
15
15
|
msgstr ""
|
16
|
-
"Project-Id-Version: foreman_ansible
|
16
|
+
"Project-Id-Version: foreman_ansible 3.0.2\n"
|
17
17
|
"Report-Msgid-Bugs-To: \n"
|
18
18
|
"PO-Revision-Date: 2018-11-14 21:36+0000\n"
|
19
19
|
"Last-Translator: dschutterop <daniel@schutterop.nl>, 2019\n"
|
Binary file
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#
|
10
10
|
msgid ""
|
11
11
|
msgstr ""
|
12
|
-
"Project-Id-Version: foreman_ansible
|
12
|
+
"Project-Id-Version: foreman_ansible 3.0.2\n"
|
13
13
|
"Report-Msgid-Bugs-To: \n"
|
14
14
|
"PO-Revision-Date: 2018-11-14 21:36+0000\n"
|
15
15
|
"Last-Translator: Michał Foryt <michal.foryt@gmail.com>, 2019\n"
|
Binary file
|
Binary file
|
Binary file
|
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
msgid ""
|
12
12
|
msgstr ""
|
13
|
-
"Project-Id-Version: foreman_ansible
|
13
|
+
"Project-Id-Version: foreman_ansible 3.0.2\n"
|
14
14
|
"Report-Msgid-Bugs-To: \n"
|
15
15
|
"PO-Revision-Date: 2018-11-14 21:36+0000\n"
|
16
16
|
"Last-Translator: johnny.westerlund <johnny.westerlund@gmail.com>, 2019\n"
|
Binary file
|
Binary file
|
data/package.json
CHANGED
@@ -7,33 +7,26 @@
|
|
7
7
|
"test": "test"
|
8
8
|
},
|
9
9
|
"peerDependencies": {
|
10
|
-
"@theforeman/vendor": ">=
|
10
|
+
"@theforeman/vendor": ">= 6.0.0"
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
13
|
"react-json-tree": "^0.11.0"
|
14
14
|
},
|
15
15
|
"devDependencies": {
|
16
16
|
"@babel/core": "^7.7.0",
|
17
|
-
"@theforeman/builder": "^4.
|
18
|
-
"@theforeman/
|
19
|
-
"
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"eslint": "^6.
|
25
|
-
"
|
26
|
-
"identity-obj-proxy": "^3.0.0",
|
27
|
-
"jest": "^24.9.0",
|
28
|
-
"prettier": "^1.19.0",
|
29
|
-
"react-redux": "^5.0.7",
|
30
|
-
"react-redux-test-utils": "^0.1.1",
|
31
|
-
"redux": "^3.7.2",
|
32
|
-
"redux-thunk": "^2.3.0"
|
17
|
+
"@theforeman/builder": "^8.4.1",
|
18
|
+
"@theforeman/eslint-plugin-foreman": "^8.4.1",
|
19
|
+
"@theforeman/find-foreman": "^8.4.1",
|
20
|
+
"@theforeman/stories": "^8.4.1",
|
21
|
+
"@theforeman/test": "^8.4.1",
|
22
|
+
"@theforeman/vendor-dev": "^8.4.1",
|
23
|
+
"babel-eslint": "^10.0.3",
|
24
|
+
"eslint": "^6.7.2",
|
25
|
+
"prettier": "^1.13.5"
|
33
26
|
},
|
34
27
|
"scripts": {
|
35
|
-
"test": "
|
36
|
-
"lint": "
|
28
|
+
"test": "tfm-test --plugin --config jest.config.js",
|
29
|
+
"lint": "tfm-lint --plugin -d webpack"
|
37
30
|
},
|
38
31
|
"repository": {
|
39
32
|
"type": "git",
|
@@ -44,27 +37,5 @@
|
|
44
37
|
"bugs": {
|
45
38
|
"url": "https://projects.theforeman.org/projects/ansible"
|
46
39
|
},
|
47
|
-
"homepage": "https://theforeman.org/plugins/foreman_ansible/"
|
48
|
-
"jest": {
|
49
|
-
"verbose": true,
|
50
|
-
"moduleDirectories": [
|
51
|
-
"node_modules/@theforeman/vendor-core/node_modules",
|
52
|
-
"node_modules",
|
53
|
-
"webpack"
|
54
|
-
],
|
55
|
-
"transform": {
|
56
|
-
"^.+\\.js$": "babel-jest"
|
57
|
-
},
|
58
|
-
"setupFiles": [
|
59
|
-
"raf/polyfill",
|
60
|
-
"./webpack/test_setup.js"
|
61
|
-
],
|
62
|
-
"testPathIgnorePatterns": [
|
63
|
-
"/node_modules/",
|
64
|
-
"<rootDir>/foreman/"
|
65
|
-
],
|
66
|
-
"moduleNameMapper": {
|
67
|
-
"^.+\\.(css|scss)$": "identity-obj-proxy"
|
68
|
-
}
|
69
|
-
}
|
40
|
+
"homepage": "https://theforeman.org/plugins/foreman_ansible/"
|
70
41
|
}
|
@@ -4,4 +4,16 @@ FactoryBot.define do
|
|
4
4
|
factory :ansible_role do
|
5
5
|
sequence(:name) { |n| "ansible_role_#{n}" }
|
6
6
|
end
|
7
|
+
|
8
|
+
factory :host_ansible_role do
|
9
|
+
position { nil }
|
10
|
+
host
|
11
|
+
ansible_role
|
12
|
+
end
|
13
|
+
|
14
|
+
factory :hostgroup_ansible_role do
|
15
|
+
position { nil }
|
16
|
+
hostgroup
|
17
|
+
ansible_role
|
18
|
+
end
|
7
19
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
FactoryBot.modify do
|
2
|
+
factory :host do
|
3
|
+
trait :with_ansible_roles do
|
4
|
+
transient do
|
5
|
+
roles_count { 2 }
|
6
|
+
end
|
7
|
+
after(:build) do |host, evaluator|
|
8
|
+
host.host_ansible_roles = FactoryBot.build_list(:host_ansible_role, evaluator.roles_count, host: host)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
factory :hostgroup do
|
14
|
+
trait :with_ansible_roles do
|
15
|
+
transient do
|
16
|
+
roles_count { 2 }
|
17
|
+
end
|
18
|
+
after(:build) do |hostgroup, evaluator|
|
19
|
+
hostgroup.hostgroup_ansible_roles = FactoryBot.build_list(:hostgroup_ansible_role, evaluator.roles_count, hostgroup: hostgroup)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
class AnsibleRolesHelperTest < ActiveSupport::TestCase
|
6
|
+
include ForemanAnsible::AnsibleRolesHelper
|
7
|
+
|
8
|
+
describe '#role_attributes_for_roles_switcher' do
|
9
|
+
let(:hg_with_roles) { FactoryBot.create(:hostgroup, :with_ansible_roles) }
|
10
|
+
|
11
|
+
context 'with hostgroup' do
|
12
|
+
let(:child) { FactoryBot.build(:hostgroup, :with_ansible_roles, parent: hg_with_roles) }
|
13
|
+
|
14
|
+
it 'show inherited and positioned own roles' do
|
15
|
+
role_attributes = role_attributes_for_roles_switcher(child)
|
16
|
+
expected_ids = hg_with_roles.ansible_roles.pluck(:id) + child.hostgroup_ansible_roles.map(&:ansible_role_id)
|
17
|
+
assert_equal(expected_ids, role_attributes.map { |ra| ra[:id] })
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'includes inherited roles just once' do
|
21
|
+
child.host_ansible_roles << FactoryBot.build(:hostgroup_ansible_role, hostgroup: child, ansible_role: hg_with_roles.ansible_roles.first)
|
22
|
+
role_attributes = role_attributes_for_roles_switcher(child)
|
23
|
+
expected_ids = hg_with_roles.ansible_roles.pluck(:id) + child.hostgroup_ansible_roles.map(&:ansible_role_id)
|
24
|
+
assert_equal(expected_ids.uniq, role_attributes.map { |ra| ra[:id] })
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with host' do
|
29
|
+
let(:host_new) { FactoryBot.build(:host, :with_ansible_roles, hostgroup: hg_with_roles) }
|
30
|
+
|
31
|
+
it 'show inherited and positioned own roles' do
|
32
|
+
role_attributes = role_attributes_for_roles_switcher(host_new)
|
33
|
+
expected_ids = hg_with_roles.ansible_roles.pluck(:id) + host_new.host_ansible_roles.map(&:ansible_role_id)
|
34
|
+
assert_equal(expected_ids, role_attributes.map { |ra| ra[:id] })
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'includes inherited roles just once' do
|
38
|
+
host_new.host_ansible_roles << FactoryBot.build(:host_ansible_role, host: host_new, ansible_role: hg_with_roles.ansible_roles.first)
|
39
|
+
role_attributes = role_attributes_for_roles_switcher(host_new)
|
40
|
+
expected_ids = hg_with_roles.ansible_roles.pluck(:id) + host_new.host_ansible_roles.map(&:ansible_role_id)
|
41
|
+
assert_equal(expected_ids.uniq, role_attributes.map { |ra| ra[:id] })
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -34,21 +34,6 @@ class AnsibleVariablesControllerTest < ActionController::TestCase
|
|
34
34
|
assert_redirected_to ansible_variables_url
|
35
35
|
end
|
36
36
|
|
37
|
-
test 'should show import page' do
|
38
|
-
ForemanAnsible::UiRolesImporter.any_instance.
|
39
|
-
expects(:import_role_names).returns({})
|
40
|
-
|
41
|
-
ForemanAnsible::VariablesImporter.any_instance.
|
42
|
-
expects(:import_variable_names).returns({
|
43
|
-
:obsolete => [@model]
|
44
|
-
})
|
45
|
-
|
46
|
-
get :import,
|
47
|
-
:params => { :proxy => @proxy.id },
|
48
|
-
:session => set_session_user
|
49
|
-
assert_response :success
|
50
|
-
end
|
51
|
-
|
52
37
|
test 'should create ansible variable' do
|
53
38
|
params = { :ansible_variable => { :key => 'great name', :ansible_role_id => FactoryBot.create(:ansible_role).id } }
|
54
39
|
assert_difference('AnsibleVariable.count', 1) do
|