foreman_ansible 6.3.3 → 7.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 +1 -1
- data/app/graphql/mutations/ansible_variable_overrides/create.rb +26 -0
- data/app/graphql/mutations/ansible_variable_overrides/delete.rb +38 -0
- data/app/graphql/mutations/ansible_variable_overrides/update.rb +26 -0
- data/app/graphql/mutations/hosts/assign_ansible_roles.rb +37 -0
- data/app/graphql/presenters/ansible_role_presenter.rb +12 -0
- data/app/graphql/presenters/overriden_ansible_variable_presenter.rb +19 -0
- data/app/graphql/types/ansible_role.rb +9 -0
- data/app/graphql/types/ansible_variable.rb +23 -0
- data/app/graphql/types/ansible_variable_override.rb +9 -0
- data/app/graphql/types/inherited_ansible_role.rb +13 -0
- data/app/graphql/types/overriden_ansible_variable.rb +27 -0
- data/app/helpers/foreman_ansible/ansible_reports_helper.rb +35 -54
- data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +23 -4
- data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +1 -0
- data/app/models/foreman_ansible/ansible_provider.rb +56 -6
- data/app/services/foreman_ansible/ansible_report_importer.rb +2 -2
- data/app/services/foreman_ansible/inventory_creator.rb +1 -1
- data/app/services/foreman_ansible/override_resolver.rb +22 -0
- data/app/views/api/v2/ansible_override_values/index.json.rabl +3 -0
- data/app/views/api/v2/ansible_variables/show.json.rabl +1 -1
- data/app/views/foreman_ansible/ansible_roles/_hostgroup_ansible_roles_button.erb +3 -0
- data/app/views/foreman_ansible/config_reports/_ansible.html.erb +14 -5
- data/app/views/foreman_ansible/job_templates/ansible_roles_-_ansible_default.erb +4 -0
- data/app/views/foreman_ansible/job_templates/convert_to_rhel.erb +6 -2
- data/app/views/foreman_ansible/job_templates/run_openscap_scans_-_ansible_default.erb +20 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20210818083407_fix_ansible_setting_category_to_dsl.rb +5 -0
- data/lib/foreman_ansible/engine.rb +0 -18
- data/lib/foreman_ansible/register.rb +114 -2
- data/lib/foreman_ansible/version.rb +1 -1
- data/package.json +10 -6
- data/test/functional/api/v2/ansible_inventories_controller_test.rb +1 -2
- data/test/graphql/mutations/hosts/assign_ansible_roles_mutation_test.rb +96 -0
- data/test/graphql/queries/ansible_roles_query_test.rb +35 -0
- data/test/unit/ansible_provider_test.rb +3 -6
- data/test/unit/concerns/host_managed_extensions_test.rb +8 -0
- data/test/unit/concerns/hostgroup_extensions_test.rb +6 -0
- data/test/unit/helpers/ansible_reports_helper_test.rb +4 -30
- data/test/unit/services/override_resolver_test.rb +34 -0
- data/webpack/components/AnsibleHostDetail/AnsibleHostDetail.js +59 -0
- data/webpack/components/AnsibleHostDetail/AnsibleHostDetail.scss +6 -0
- data/webpack/components/AnsibleHostDetail/AnsibleHostDetail.test.js +20 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/AnsibleHostInventory.js +22 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/AnsibleHostInventory.scss +4 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/AnsibleHostInventory.test.js +104 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleHostInventory/index.js +38 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverrides.scss +3 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTable.js +238 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTableHelper.js +111 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableAction.js +161 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableAction.scss +7 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableActionHelper.js +49 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableValue.js +70 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableValueHelper.js +35 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/__test__/AnsibleVariableOverrides.fixtures.js +429 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/__test__/AnsibleVariableOverrides.test.js +71 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/__test__/AnsibleVariableOverridesDelete.test.js +74 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/__test__/AnsibleVariableOverridesUpdate.test.js +188 -0
- data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js +58 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/JobsTabHelper.js +79 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/NewRecurringJobHelper.js +106 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/NewRecurringJobModal.js +129 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/NewRecurringJobModal.scss +7 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/PreviousJobsTable.js +103 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/RecurringJobsTable.js +96 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/__test__/JobsTab.fixtures.js +184 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/__test__/JobsTab.test.js +195 -0
- data/webpack/components/AnsibleHostDetail/components/JobsTab/index.js +88 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/AllRolesModal/AllRolesTable.js +89 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/AllRolesModal/index.js +80 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/EditRolesForm.js +90 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/EditRolesModal.scss +3 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/EditRolesModalHelper.js +40 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/index.js +82 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/RolesTable.js +129 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/EditRoles.test.js +85 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/RolesTab.fixtures.js +180 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/RolesTab.test.js +75 -0
- data/webpack/components/AnsibleHostDetail/components/RolesTab/index.js +51 -0
- data/webpack/components/AnsibleHostDetail/components/SecondaryTabRoutes.js +60 -0
- data/webpack/components/AnsibleHostDetail/components/TabLayout.js +12 -0
- data/webpack/components/AnsibleHostDetail/constants.js +9 -0
- data/webpack/components/AnsibleHostDetail/helpers.js +4 -0
- data/webpack/components/AnsibleHostDetail/index.js +6 -0
- data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesImport.test.js +15 -10
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +29 -0
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.test.js +3 -0
- data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.js +2 -1
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsiblePermissionDenied.test.js.snap +2 -0
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRole.test.js.snap +3 -3
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap +4 -4
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AvailableRolesList.test.js.snap +9 -0
- data/webpack/components/DualList/DualList.scss +3 -0
- data/webpack/components/DualList/ListControls.js +65 -0
- data/webpack/components/DualList/ListHeader.js +16 -0
- data/webpack/components/DualList/ListItem.js +69 -0
- data/webpack/components/DualList/ListPane.js +95 -0
- data/webpack/components/DualList/SelectedStatus.js +21 -0
- data/webpack/components/DualList/index.js +103 -0
- data/webpack/components/ErrorState.js +16 -0
- data/webpack/components/withLoading.js +135 -0
- data/webpack/components/withPagination.js +0 -0
- data/webpack/formHelper.js +131 -0
- data/webpack/globalIdHelper.js +13 -0
- data/webpack/global_index.js +18 -0
- data/webpack/graphql/mutations/assignAnsibleRoles.gql +17 -0
- data/webpack/graphql/mutations/cancelRecurringLogic.gql +12 -0
- data/webpack/graphql/mutations/createAnsibleVariableOverride.gql +28 -0
- data/webpack/graphql/mutations/createJobInvocation.gql +11 -0
- data/webpack/graphql/mutations/deleteAnsibleVariableOverride.gql +17 -0
- data/webpack/graphql/mutations/updateAnsibleVariableOverride.gql +29 -0
- data/webpack/graphql/queries/allAnsibleRoles.gql +13 -0
- data/webpack/graphql/queries/ansibleRoles.gql +13 -0
- data/webpack/graphql/queries/currentUserAttributes.gql +11 -0
- data/webpack/graphql/queries/hostAnsibleRoles.gql +17 -0
- data/webpack/graphql/queries/hostAvailableAnsibleRoles.gql +11 -0
- data/webpack/graphql/queries/hostVariableOverrides.gql +39 -0
- data/webpack/graphql/queries/recurringJobs.gql +28 -0
- data/webpack/helpers/pageParamsHelper.js +40 -0
- data/webpack/helpers/paginationHelper.js +9 -0
- data/webpack/permissionsHelper.js +58 -0
- data/webpack/routes/HostgroupJobs/__test__/HostgroupJobs.fixtures.js +63 -0
- data/webpack/routes/HostgroupJobs/__test__/HostgroupJobs.test.js +112 -0
- data/webpack/routes/HostgroupJobs/index.js +26 -0
- data/webpack/routes/routes.js +10 -0
- data/webpack/testHelper.js +165 -0
- data/webpack/toastHelper.js +4 -0
- metadata +130 -78
- data/app/assets/images/foreman_ansible/Ansible.png +0 -0
- data/app/models/foreman_ansible/fact_name.rb +0 -16
- data/app/models/setting/ansible.rb +0 -106
- data/app/services/foreman_ansible/fact_importer.rb +0 -99
- data/app/services/foreman_ansible/fact_parser.rb +0 -126
- data/app/services/foreman_ansible/fact_sparser.rb +0 -37
- data/app/services/foreman_ansible/operating_system_parser.rb +0 -102
- data/app/services/foreman_ansible/structured_fact_importer.rb +0 -25
- 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/test/unit/services/fact_importer_test.rb +0 -52
- data/test/unit/services/fact_parser_test.rb +0 -281
- data/test/unit/services/fact_sparser_test.rb +0 -24
- data/test/unit/services/structured_fact_importer_test.rb +0 -30
- data/webpack/__mocks__/foremanReact/common/I18n.js +0 -1
- data/webpack/__mocks__/foremanReact/common/helpers.js +0 -13
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +0 -2
- data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +0 -5
- data/webpack/__mocks__/foremanReact/components/common/forms/OrderableSelect/helpers.js +0 -5
- data/webpack/__mocks__/foremanReact/redux/API.js +0 -7
- data/webpack/components/AnsibleRolesAndVariables/__test__/__snapshots__/AnsibleRolesAndVariablesImport.test.js.snap +0 -177
@@ -1,281 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_plugin_helper'
|
4
|
-
|
5
|
-
module ForemanAnsible
|
6
|
-
# Checks sample Ansible facts to see if it can assign them to
|
7
|
-
# Host properties
|
8
|
-
class FactParserTest < ActiveSupport::TestCase
|
9
|
-
setup do
|
10
|
-
@facts_parser = ForemanAnsible::FactParser.new(facts_json)
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'finds facter domain even if ansible_domain is empty' do
|
14
|
-
expect_where(Domain, @facts_parser.facts[:facter_domain])
|
15
|
-
@facts_parser.domain
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'finds model' do
|
19
|
-
expect_where(Model, @facts_parser.facts[:ansible_product_name])
|
20
|
-
@facts_parser.model
|
21
|
-
end
|
22
|
-
|
23
|
-
test 'finds architecture' do
|
24
|
-
expect_where(Architecture, @facts_parser.facts[:ansible_architecture])
|
25
|
-
@facts_parser.architecture
|
26
|
-
end
|
27
|
-
|
28
|
-
test 'does not set environment' do
|
29
|
-
refute @facts_parser.environment
|
30
|
-
end
|
31
|
-
|
32
|
-
test 'calculates virtual reported data' do
|
33
|
-
refute @facts_parser.virtual
|
34
|
-
end
|
35
|
-
|
36
|
-
test 'calculates ram reported data' do
|
37
|
-
assert_equal 7899, @facts_parser.ram
|
38
|
-
end
|
39
|
-
|
40
|
-
test 'calculates sockets reported data' do
|
41
|
-
assert_equal 1, @facts_parser.sockets
|
42
|
-
end
|
43
|
-
|
44
|
-
test 'calculates cores reported data' do
|
45
|
-
assert_equal 2, @facts_parser.cores
|
46
|
-
end
|
47
|
-
|
48
|
-
test 'creates operatingsystem from operating system options' do
|
49
|
-
sample_mock = mock
|
50
|
-
major_fact = @facts_parser.facts['ansible_distribution_major_version']
|
51
|
-
_, minor_fact = @facts_parser.
|
52
|
-
facts['ansible_distribution_version'].split('.')
|
53
|
-
Operatingsystem.expects(:where).
|
54
|
-
with(:name => @facts_parser.facts['ansible_distribution'],
|
55
|
-
:major => major_fact, :minor => minor_fact || '').
|
56
|
-
returns(sample_mock)
|
57
|
-
sample_mock.expects(:first)
|
58
|
-
@facts_parser.operatingsystem
|
59
|
-
end
|
60
|
-
|
61
|
-
test 'does not fail if facts are not enough to create OS' do
|
62
|
-
@facts_parser.expects(:os_name).returns('fakeos').at_least_once
|
63
|
-
@facts_parser.expects(:os_major).returns('').at_least_once
|
64
|
-
@facts_parser.expects(:os_minor).returns('').at_least_once
|
65
|
-
@facts_parser.expects(:os_description).returns('').at_least_once
|
66
|
-
Operatingsystem.any_instance.expects(:valid?).returns(false)
|
67
|
-
assert_nil @facts_parser.operatingsystem
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def expect_where(model, fact_name)
|
73
|
-
sample_mock = mock
|
74
|
-
model.expects(:where).
|
75
|
-
with(:name => fact_name).
|
76
|
-
returns(sample_mock)
|
77
|
-
sample_mock.expects(:first_or_create)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# Tests for Network parser
|
82
|
-
class NetworkFactParserTest < ActiveSupport::TestCase
|
83
|
-
setup do
|
84
|
-
@facts_parser = ForemanAnsible::FactParser.new(
|
85
|
-
HashWithIndifferentAccess.new(
|
86
|
-
'_type' => 'ansible',
|
87
|
-
'_timestamp' => '2018-10-29 20:01:51 +0100',
|
88
|
-
'ansible_facts' =>
|
89
|
-
{
|
90
|
-
'ansible_interfaces' => %w[eth0 eth1 eth2 bond0],
|
91
|
-
'ansible_eth0' => {
|
92
|
-
'active' => true,
|
93
|
-
'device' => 'eth0',
|
94
|
-
'macaddress' => '52:54:00:04:55:37',
|
95
|
-
'perm_macaddress' => '52:54:00:04:55:37',
|
96
|
-
'ipv4' => {
|
97
|
-
'address' => '10.10.0.10',
|
98
|
-
'netmask' => '255.255.0.0',
|
99
|
-
'network' => '10.10.0.0'
|
100
|
-
},
|
101
|
-
'ipv6' => [
|
102
|
-
{
|
103
|
-
'address' => 'fd00::5054:00ff:fe04:5537',
|
104
|
-
'prefix' => '64',
|
105
|
-
'scope' => 'host'
|
106
|
-
}
|
107
|
-
],
|
108
|
-
'mtu' => 1500,
|
109
|
-
'promisc' => false,
|
110
|
-
'type' => 'ether'
|
111
|
-
},
|
112
|
-
'ansible_eth1' => {
|
113
|
-
'active' => true,
|
114
|
-
'device' => 'eth1',
|
115
|
-
'macaddress' => '52:54:00:04:55:38',
|
116
|
-
'perm_macaddress' => '52:54:00:04:55:38',
|
117
|
-
'mtu' => 1500,
|
118
|
-
'promisc' => false,
|
119
|
-
'type' => 'ether'
|
120
|
-
},
|
121
|
-
'ansible_eth2' => {
|
122
|
-
'active' => true,
|
123
|
-
'device' => 'eth2',
|
124
|
-
'macaddress' => '52:54:00:04:55:38',
|
125
|
-
'perm_macaddress' => '52:54:00:04:55:39',
|
126
|
-
'mtu' => 1500,
|
127
|
-
'promisc' => false,
|
128
|
-
'type' => 'ether'
|
129
|
-
},
|
130
|
-
'ansible_bond0' => {
|
131
|
-
'active' => true,
|
132
|
-
'device' => 'bond0',
|
133
|
-
'macaddress' => '52:54:00:04:55:38',
|
134
|
-
'ipv4' => {
|
135
|
-
'address' => '10.10.0.11',
|
136
|
-
'netmask' => '255.255.0.0',
|
137
|
-
'network' => '10.10.0.0'
|
138
|
-
},
|
139
|
-
'ipv6' => [
|
140
|
-
{
|
141
|
-
'address' => 'fd00::5054:00ff:fe04:5538',
|
142
|
-
'prefix' => '64',
|
143
|
-
'scope' => 'host'
|
144
|
-
}
|
145
|
-
],
|
146
|
-
'mtu' => 1500,
|
147
|
-
'promisc' => false,
|
148
|
-
'slaves' => %w[eth1 eth2],
|
149
|
-
'type' => 'bonding'
|
150
|
-
}
|
151
|
-
}
|
152
|
-
)
|
153
|
-
)
|
154
|
-
end
|
155
|
-
|
156
|
-
test 'Parses IPv4 & IPv6 addresses correctly' do
|
157
|
-
iut = 'eth0'.dup
|
158
|
-
interface = @facts_parser.get_facts_for_interface(iut)
|
159
|
-
assert_equal '10.10.0.10', interface['ipaddress']
|
160
|
-
assert_equal 'fd00::5054:00ff:fe04:5537', interface['ipaddress6']
|
161
|
-
end
|
162
|
-
|
163
|
-
test 'Parses MAC address correctly when bonded' do
|
164
|
-
iut0 = 'eth0'.dup
|
165
|
-
iut1 = 'eth1'.dup
|
166
|
-
iut2 = 'eth2'.dup
|
167
|
-
but0 = 'bond0'.dup
|
168
|
-
interface_eth0 = @facts_parser.get_facts_for_interface(iut0)
|
169
|
-
interface_eth1 = @facts_parser.get_facts_for_interface(iut1)
|
170
|
-
interface_eth2 = @facts_parser.get_facts_for_interface(iut2)
|
171
|
-
interface_bond0 = @facts_parser.get_facts_for_interface(but0)
|
172
|
-
assert_equal '52:54:00:04:55:37', interface_eth0['macaddress']
|
173
|
-
assert_equal '52:54:00:04:55:38', interface_eth1['macaddress']
|
174
|
-
assert_equal '52:54:00:04:55:39', interface_eth2['macaddress']
|
175
|
-
assert_equal '52:54:00:04:55:38', interface_bond0['macaddress']
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
# Tests for Debian parser
|
180
|
-
class DebianFactParserTest < ActiveSupport::TestCase
|
181
|
-
setup do
|
182
|
-
@facts_parser = ForemanAnsible::FactParser.new(
|
183
|
-
HashWithIndifferentAccess.new(
|
184
|
-
'_type' => 'ansible',
|
185
|
-
'_timestamp' => '2015-10-29 20:01:51 +0100',
|
186
|
-
'ansible_facts' =>
|
187
|
-
{
|
188
|
-
"ansible_distribution" => "Debian",
|
189
|
-
"ansible_distribution_file_parsed" => true,
|
190
|
-
"ansible_distribution_file_path" => "/etc/os-release",
|
191
|
-
"ansible_distribution_file_variety" => "Debian",
|
192
|
-
"ansible_distribution_major_version" => "8",
|
193
|
-
"ansible_distribution_release" => "jessie",
|
194
|
-
"ansible_distribution_version" => "8.7"
|
195
|
-
}
|
196
|
-
)
|
197
|
-
)
|
198
|
-
end
|
199
|
-
|
200
|
-
test 'Parses debian jessie correctly' do
|
201
|
-
as_admin do
|
202
|
-
os = @facts_parser.operatingsystem
|
203
|
-
|
204
|
-
assert_equal '8', os.major
|
205
|
-
assert_equal 'Debian', os.name
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
# Tests for Windows parser
|
211
|
-
class WindowsFactParserTest < ActiveSupport::TestCase
|
212
|
-
context 'Windows 7' do
|
213
|
-
setup do
|
214
|
-
@facts_parser = ForemanAnsible::FactParser.new(
|
215
|
-
HashWithIndifferentAccess.new(
|
216
|
-
'_type' => 'ansible',
|
217
|
-
'_timestamp' => '2015-10-29 20:01:51 +0100',
|
218
|
-
'ansible_facts' => {
|
219
|
-
'ansible_architecture' => '32-Bit',
|
220
|
-
'ansible_distribution' => 'Microsoft Windows 7 Enterprise ',
|
221
|
-
'ansible_distribution_major_version' => '6',
|
222
|
-
'ansible_distribution_version' => '6.1.7601.65536',
|
223
|
-
'ansible_os_family' => 'Windows',
|
224
|
-
'ansible_os_name' => 'Microsoft Windows 7 Enterprise',
|
225
|
-
'ansible_product_name' => 'DS61',
|
226
|
-
'ansible_product_serial' => 'To be filled by O.E.M.',
|
227
|
-
'ansible_system' => 'Win32NT',
|
228
|
-
'ansible_win_rm_certificate_expires' => '2021-01-23 15:08:48',
|
229
|
-
'ansible_windows_domain' => 'example.com'
|
230
|
-
}
|
231
|
-
)
|
232
|
-
)
|
233
|
-
end
|
234
|
-
|
235
|
-
test 'parses Windows 7 Enterprise correctly' do
|
236
|
-
os = @facts_parser.operatingsystem
|
237
|
-
assert_equal '6', os.major
|
238
|
-
assert_equal '6.1.760165536', os.release
|
239
|
-
assert_equal '1.760165536', os.minor
|
240
|
-
assert_equal 'Windows', os.family
|
241
|
-
assert_equal 'Microsoft Windows 7 Enterprise', os.description
|
242
|
-
assert_equal 'MicrosoftWindows7Enterprise', os.name
|
243
|
-
assert os.valid?
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
context 'Windows Server 2016' do
|
248
|
-
setup do
|
249
|
-
@facts_parser = ForemanAnsible::FactParser.new(
|
250
|
-
HashWithIndifferentAccess.new(
|
251
|
-
'_type' => 'ansible',
|
252
|
-
'_timestamp' => '2015-10-29 20:01:51 +0100',
|
253
|
-
'ansible_facts' => {
|
254
|
-
'ansible_architecture' => '64-Bit',
|
255
|
-
'ansible_distribution' => 'Microsoft Windows Server 2016 '\
|
256
|
-
'Standard',
|
257
|
-
'ansible_distribution_major_version' => '10',
|
258
|
-
'ansible_distribution_version' => '10.0.14393.0',
|
259
|
-
'ansible_os_family' => 'Windows',
|
260
|
-
'ansible_os_name' => 'Microsoft Windows Server 2016 Standard',
|
261
|
-
'ansible_system' => 'Win32NT',
|
262
|
-
'ansible_win_rm_certificate_expires' => '2021-01-23 15:08:48',
|
263
|
-
'ansible_windows_domain' => 'example.com'
|
264
|
-
}
|
265
|
-
)
|
266
|
-
)
|
267
|
-
end
|
268
|
-
|
269
|
-
test 'parses Windows Server correctly' do
|
270
|
-
os = @facts_parser.operatingsystem
|
271
|
-
assert_equal '10', os.major
|
272
|
-
assert_equal '10.0.143930', os.release
|
273
|
-
assert_equal '0.143930', os.minor
|
274
|
-
assert_equal 'Windows', os.family
|
275
|
-
assert_equal 'Microsoft Windows Server 2016 Standard', os.description
|
276
|
-
assert_equal 'MicrosoftWindowsServer2016Standard', os.name
|
277
|
-
assert os.valid?
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ForemanAnsible
|
4
|
-
# Tests for checking if FactSparser can sparse a hash and unsparse it
|
5
|
-
class FactSparserTest < ActiveSupport::TestCase
|
6
|
-
setup do
|
7
|
-
@original_os_facts = { 'operatingsystem' => { 'major' => 20, 'minor' => 1,
|
8
|
-
'name' => 'Fedora' } }
|
9
|
-
@sparsed_os_facts = { 'operatingsystem::major' => 20,
|
10
|
-
'operatingsystem::minor' => 1,
|
11
|
-
'operatingsystem::name' => 'Fedora' }
|
12
|
-
end
|
13
|
-
|
14
|
-
test 'sparses simple hash' do
|
15
|
-
assert_equal @sparsed_os_facts,
|
16
|
-
ForemanAnsible::FactSparser.sparse(@original_os_facts)
|
17
|
-
end
|
18
|
-
|
19
|
-
test 'unsparse simple hash' do
|
20
|
-
assert_equal @original_os_facts,
|
21
|
-
ForemanAnsible::FactSparser.unsparse(@sparsed_os_facts)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_plugin_helper'
|
4
|
-
|
5
|
-
module ForemanAnsible
|
6
|
-
# Test for the structured facts importer - its code mostly lives in Foreman
|
7
|
-
# core, so only details have to be tested here.
|
8
|
-
class StructuredFactImporterTest < ActiveSupport::TestCase
|
9
|
-
test 'if host is not in Foreman, use hostname provided by call' do
|
10
|
-
fake_host = Host.new(:name => 'fake')
|
11
|
-
importer = ForemanAnsible::StructuredFactImporter.new(
|
12
|
-
fake_host,
|
13
|
-
facts_json
|
14
|
-
)
|
15
|
-
assert_equal fake_host, importer.send(:host)
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'if host is in Foreman, use hostname provided by Ansible' do
|
19
|
-
ansible_fqdn_host = FactoryBot.build(:host)
|
20
|
-
ansible_fqdn_host.name = facts_json[:ansible_facts][:ansible_fqdn]
|
21
|
-
ansible_fqdn_host.save
|
22
|
-
importer = ForemanAnsible::StructuredFactImporter.new(
|
23
|
-
Host.new(:name => 'fake'),
|
24
|
-
facts_json
|
25
|
-
)
|
26
|
-
|
27
|
-
assert_equal ansible_fqdn_host, importer.send(:host)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
export const translate = s => s;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { camelCase } from 'lodash';
|
2
|
-
|
3
|
-
export const propsToCamelCase = ob =>
|
4
|
-
propsToCase(camelCase, 'propsToCamelCase only takes objects', ob);
|
5
|
-
|
6
|
-
const propsToCase = (casingFn, errorMsg, ob) => {
|
7
|
-
if (typeof ob !== 'object') throw Error(errorMsg);
|
8
|
-
|
9
|
-
return Object.keys(ob).reduce((memo, key) => {
|
10
|
-
memo[casingFn(key)] = ob[key];
|
11
|
-
return memo;
|
12
|
-
}, {});
|
13
|
-
};
|
@@ -1,177 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`ImportRolesAndVariablesTable should render 1`] = `
|
4
|
-
<div
|
5
|
-
id="import-ansible-roles-variables"
|
6
|
-
>
|
7
|
-
<Toolbar>
|
8
|
-
<ToolbarContent
|
9
|
-
isExpanded={false}
|
10
|
-
showClearFiltersButton={false}
|
11
|
-
>
|
12
|
-
<ForwardRef
|
13
|
-
variant="icon-button-group"
|
14
|
-
>
|
15
|
-
<ToolbarItem>
|
16
|
-
<Checkbox
|
17
|
-
aria-label="select all checkbox"
|
18
|
-
className=""
|
19
|
-
id="select-all"
|
20
|
-
isChecked={false}
|
21
|
-
isDisabled={false}
|
22
|
-
isValid={true}
|
23
|
-
label="Select all"
|
24
|
-
name="select-all"
|
25
|
-
onChange={[Function]}
|
26
|
-
/>
|
27
|
-
</ToolbarItem>
|
28
|
-
</ForwardRef>
|
29
|
-
</ToolbarContent>
|
30
|
-
</Toolbar>
|
31
|
-
<Table
|
32
|
-
aria-label="import roles and variables"
|
33
|
-
borders={true}
|
34
|
-
canSelectAll={false}
|
35
|
-
canSortFavorites={true}
|
36
|
-
cells={
|
37
|
-
Array [
|
38
|
-
Object {
|
39
|
-
"title": "Name",
|
40
|
-
"transforms": Array [
|
41
|
-
[Function],
|
42
|
-
],
|
43
|
-
},
|
44
|
-
Object {
|
45
|
-
"title": "Operation",
|
46
|
-
"transforms": Array [
|
47
|
-
[Function],
|
48
|
-
],
|
49
|
-
},
|
50
|
-
Object {
|
51
|
-
"title": "Variables",
|
52
|
-
"transforms": Array [
|
53
|
-
[Function],
|
54
|
-
],
|
55
|
-
},
|
56
|
-
Object {
|
57
|
-
"title": "Hosts Count",
|
58
|
-
"transforms": Array [
|
59
|
-
[Function],
|
60
|
-
],
|
61
|
-
},
|
62
|
-
Object {
|
63
|
-
"title": "Hostgroups count",
|
64
|
-
"transforms": Array [
|
65
|
-
[Function],
|
66
|
-
],
|
67
|
-
},
|
68
|
-
]
|
69
|
-
}
|
70
|
-
className=""
|
71
|
-
contentId="expanded-content"
|
72
|
-
dropdownDirection="down"
|
73
|
-
dropdownPosition="right"
|
74
|
-
expandId="expandable-toggle"
|
75
|
-
gridBreakPoint="grid-md"
|
76
|
-
isStickyHeader={false}
|
77
|
-
onSelect={[Function]}
|
78
|
-
ouiaSafe={true}
|
79
|
-
role="grid"
|
80
|
-
rowLabeledBy="simple-node"
|
81
|
-
rows={
|
82
|
-
Array [
|
83
|
-
Object {
|
84
|
-
"cells": Array [
|
85
|
-
"bennojoy.ntp",
|
86
|
-
"Update Role Variables",
|
87
|
-
"Add: 1 Remove: 2 ",
|
88
|
-
"",
|
89
|
-
"",
|
90
|
-
],
|
91
|
-
"id": "bennojoy.ntp",
|
92
|
-
"kind": "old",
|
93
|
-
},
|
94
|
-
Object {
|
95
|
-
"cells": Array [
|
96
|
-
"0ta2.git_role",
|
97
|
-
"Import Role ",
|
98
|
-
"Add: 5 ",
|
99
|
-
"",
|
100
|
-
"",
|
101
|
-
],
|
102
|
-
"id": "0ta2.git_role",
|
103
|
-
"kind": "new",
|
104
|
-
},
|
105
|
-
]
|
106
|
-
}
|
107
|
-
selectVariant="checkbox"
|
108
|
-
variant={null}
|
109
|
-
>
|
110
|
-
<TableHeader />
|
111
|
-
<Component />
|
112
|
-
</Table>
|
113
|
-
<Pagination
|
114
|
-
className=""
|
115
|
-
defaultToFullPage={true}
|
116
|
-
firstPage={1}
|
117
|
-
isCompact={true}
|
118
|
-
isDisabled={false}
|
119
|
-
isSticky={false}
|
120
|
-
itemCount={2}
|
121
|
-
itemsEnd={null}
|
122
|
-
itemsStart={null}
|
123
|
-
offset={0}
|
124
|
-
onFirstClick={[Function]}
|
125
|
-
onLastClick={[Function]}
|
126
|
-
onNextClick={[Function]}
|
127
|
-
onPageInput={[Function]}
|
128
|
-
onPerPageSelect={[Function]}
|
129
|
-
onPreviousClick={[Function]}
|
130
|
-
onSetPage={[Function]}
|
131
|
-
ouiaSafe={true}
|
132
|
-
page={0}
|
133
|
-
perPage={5}
|
134
|
-
perPageOptions={
|
135
|
-
Array [
|
136
|
-
Object {
|
137
|
-
"title": "3",
|
138
|
-
"value": 3,
|
139
|
-
},
|
140
|
-
Object {
|
141
|
-
"title": "5",
|
142
|
-
"value": 5,
|
143
|
-
},
|
144
|
-
Object {
|
145
|
-
"title": "10",
|
146
|
-
"value": 10,
|
147
|
-
},
|
148
|
-
]
|
149
|
-
}
|
150
|
-
titles={
|
151
|
-
Object {
|
152
|
-
"paginationTitle": "top pagination",
|
153
|
-
}
|
154
|
-
}
|
155
|
-
toggleTemplate={[Function]}
|
156
|
-
variant="top"
|
157
|
-
widgetId="pagination-options-menu"
|
158
|
-
/>
|
159
|
-
<div
|
160
|
-
className="submit-cancel-btns"
|
161
|
-
>
|
162
|
-
<br />
|
163
|
-
<br />
|
164
|
-
<Button
|
165
|
-
onClick={[Function]}
|
166
|
-
variant="primary"
|
167
|
-
>
|
168
|
-
Submit
|
169
|
-
</Button>
|
170
|
-
<Button
|
171
|
-
variant="secondary"
|
172
|
-
>
|
173
|
-
Cancel
|
174
|
-
</Button>
|
175
|
-
</div>
|
176
|
-
</div>
|
177
|
-
`;
|