foreman_ansible 2.2.14 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/app/controllers/ansible_roles_controller.rb +4 -11
- data/app/controllers/ansible_variables_controller.rb +80 -0
- data/app/controllers/api/v2/ansible_roles_controller.rb +2 -0
- data/app/controllers/api/v2/ansible_variables_controller.rb +68 -0
- data/app/controllers/concerns/foreman/controller/parameters/ansible_variable.rb +36 -0
- data/app/controllers/foreman_ansible/api/v2/hostgroups_controller_extensions.rb +2 -0
- data/app/controllers/foreman_ansible/api/v2/hostgroups_param_group_extensions.rb +2 -0
- data/app/controllers/foreman_ansible/api/v2/hosts_controller_extensions.rb +2 -0
- data/app/controllers/foreman_ansible/api/v2/hosts_param_group_extensions.rb +2 -0
- data/app/controllers/foreman_ansible/concerns/hostgroups_controller_extensions.rb +2 -0
- data/app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb +2 -0
- data/app/controllers/foreman_ansible/concerns/import_controller_helper.rb +24 -0
- data/app/controllers/foreman_ansible/concerns/job_invocation_helper.rb +2 -0
- data/app/helpers/foreman_ansible/ansible_plugin_helper.rb +2 -0
- data/app/helpers/foreman_ansible/ansible_reports_helper.rb +6 -4
- data/app/helpers/foreman_ansible/ansible_roles_helper.rb +2 -0
- data/app/helpers/foreman_ansible/hosts_helper_extensions.rb +2 -0
- data/app/lib/actions/foreman_ansible/helpers/host_common.rb +2 -0
- data/app/lib/actions/foreman_ansible/helpers/play_roles_description.rb +2 -0
- data/app/lib/proxy_api/ansible.rb +16 -0
- data/app/models/ansible_role.rb +5 -0
- data/app/models/ansible_variable.rb +23 -0
- data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +3 -1
- data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +2 -0
- data/app/models/foreman_ansible/ansible_provider.rb +2 -0
- data/app/models/foreman_ansible/fact_name.rb +2 -0
- data/app/models/host_ansible_role.rb +2 -0
- data/app/models/hostgroup_ansible_role.rb +2 -0
- data/app/models/setting/ansible.rb +7 -5
- data/app/overrides/ansible_roles_tab.rb +2 -0
- data/app/overrides/ansible_variables_edit.rb +15 -0
- data/app/overrides/hostgroup_ansible_roles_tab.rb +2 -0
- data/app/overrides/hostgroup_play_roles.rb +2 -0
- data/app/overrides/report_output.rb +2 -0
- data/app/services/foreman_ansible/ansible_report_importer.rb +15 -0
- data/app/services/foreman_ansible/ansible_report_scanner.rb +2 -0
- data/app/services/foreman_ansible/api_roles_importer.rb +2 -0
- data/app/services/foreman_ansible/fact_importer.rb +2 -0
- data/app/services/foreman_ansible/fact_parser.rb +13 -1
- data/app/services/foreman_ansible/fact_sparser.rb +2 -0
- data/app/services/foreman_ansible/insights_notification_builder.rb +2 -0
- data/app/services/foreman_ansible/insights_plan_runner.rb +3 -2
- data/app/services/foreman_ansible/inventory_creator.rb +0 -6
- data/app/services/foreman_ansible/operating_system_parser.rb +3 -1
- data/app/services/foreman_ansible/playbook_creator.rb +2 -0
- data/app/services/foreman_ansible/proxy_api.rb +24 -0
- data/app/services/foreman_ansible/renderer_methods.rb +2 -0
- data/app/services/foreman_ansible/roles_importer.rb +4 -17
- data/app/services/foreman_ansible/structured_fact_importer.rb +2 -0
- data/app/services/foreman_ansible/ui_roles_importer.rb +2 -0
- data/app/services/foreman_ansible/variables_importer.rb +100 -0
- data/app/views/ansible_roles/index.html.erb +13 -3
- data/app/views/ansible_variables/_ansible_roles_list.html.erb +15 -0
- data/app/views/ansible_variables/_validator_text.html.erb +5 -0
- data/app/views/ansible_variables/edit.html.erb +17 -0
- data/app/views/ansible_variables/import.html.erb +53 -0
- data/app/views/ansible_variables/index.html.erb +46 -0
- data/app/views/api/v2/ansible_roles/import.json.rabl +2 -0
- data/app/views/api/v2/ansible_roles/index.json.rabl +2 -0
- data/app/views/api/v2/ansible_roles/obsolete.json.rabl +2 -0
- data/app/views/api/v2/ansible_roles/show.json.rabl +2 -0
- data/app/views/api/v2/ansible_variables/import.json.rabl +3 -0
- data/app/views/api/v2/ansible_variables/index.json.rabl +3 -0
- data/app/views/api/v2/ansible_variables/obsolete.json.rabl +3 -0
- data/app/views/api/v2/ansible_variables/show.json.rabl +20 -0
- data/app/views/foreman_ansible/api/v2/ansible_roles/import.json.rabl +2 -0
- data/app/views/foreman_ansible/api/v2/ansible_roles/index.json.rabl +2 -0
- data/app/views/foreman_ansible/api/v2/ansible_roles/obsolete.json.rabl +2 -0
- data/app/views/foreman_ansible/api/v2/ansible_roles/show.json.rabl +2 -0
- data/config/routes.rb +17 -0
- data/db/migrate/20160705082036_create_ansible_role.rb +2 -0
- data/db/migrate/20160706074540_create_join_table_hosts_ansible_roles.rb +2 -0
- data/db/migrate/20160707195442_create_host_ansible_roles.rb +2 -0
- data/db/migrate/20160729094457_add_columns_to_ansible_role.rb +2 -0
- data/db/migrate/20160802153302_create_join_table_hostgroup_ansible_roles.rb +2 -0
- data/db/migrate/20160805094233_add_primary_key_hostgroup_ansible_roles.rb +2 -0
- data/db/migrate/20161122154057_automatically_set_role_timestamps.rb +2 -0
- data/db/migrate/20180410125416_rename_ansible_job_categories.rb +6 -3
- data/db/migrate/20180628125416_add_ansible_role_id_to_lookup_keys.rb +14 -0
- data/db/seeds.d/62_ansible_proxy_feature.rb +2 -0
- data/db/seeds.d/75_job_templates.rb +3 -1
- data/db/seeds.d/90_notification_blueprints.rb +2 -0
- data/lib/foreman_ansible.rb +2 -0
- data/lib/foreman_ansible/engine.rb +2 -0
- data/lib/foreman_ansible/register.rb +28 -1
- data/lib/foreman_ansible/remote_execution.rb +2 -0
- data/lib/foreman_ansible/version.rb +3 -1
- data/locale/action_names.rb +2 -2
- data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/de/foreman_ansible.edit.po +444 -0
- data/locale/de/foreman_ansible.po +56 -17
- data/locale/de/foreman_ansible.po.time_stamp +0 -0
- data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en/foreman_ansible.edit.po +442 -0
- data/locale/en/foreman_ansible.po +56 -17
- data/locale/en/foreman_ansible.po.time_stamp +0 -0
- data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/es/foreman_ansible.edit.po +444 -0
- data/locale/es/foreman_ansible.po +56 -17
- data/locale/es/foreman_ansible.po.time_stamp +0 -0
- data/locale/foreman_ansible.pot +174 -93
- data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/fr/foreman_ansible.edit.po +444 -0
- data/locale/fr/foreman_ansible.po +56 -17
- data/locale/fr/foreman_ansible.po.time_stamp +0 -0
- data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/it/foreman_ansible.edit.po +444 -0
- data/locale/it/foreman_ansible.po +56 -17
- data/locale/it/foreman_ansible.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ja/foreman_ansible.edit.po +444 -0
- data/locale/ja/foreman_ansible.po +56 -17
- data/locale/ja/foreman_ansible.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ko/foreman_ansible.edit.po +444 -0
- data/locale/ko/foreman_ansible.po +56 -17
- data/locale/ko/foreman_ansible.po.time_stamp +0 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pt_BR/foreman_ansible.edit.po +444 -0
- data/locale/pt_BR/foreman_ansible.po +56 -17
- data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
- data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ru/foreman_ansible.edit.po +445 -0
- data/locale/ru/foreman_ansible.po +56 -17
- data/locale/ru/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_CN/foreman_ansible.edit.po +444 -0
- data/locale/zh_CN/foreman_ansible.po +56 -17
- data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_TW/foreman_ansible.edit.po +444 -0
- data/locale/zh_TW/foreman_ansible.po +56 -17
- data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
- data/test/factories/ansible_proxy.rb +2 -0
- data/test/factories/ansible_roles.rb +2 -0
- data/test/factories/ansible_variables.rb +8 -0
- data/test/functional/ansible_roles_controller_test.rb +2 -0
- data/test/functional/ansible_variables_controller_test.rb +36 -0
- data/test/functional/api/v2/ansible_roles_controller_test.rb +21 -9
- data/test/functional/api/v2/ansible_variables_controller_test.rb +41 -0
- data/test/functional/api/v2/hostgroups_controller_test.rb +2 -0
- data/test/functional/api/v2/hosts_controller_test.rb +2 -0
- data/test/functional/hosts_controller_test.rb +2 -0
- data/test/test_plugin_helper.rb +2 -0
- data/test/unit/ansible_provider_test.rb +2 -0
- data/test/unit/ansible_role_test.rb +5 -9
- data/test/unit/ansible_variable_test.rb +14 -0
- data/test/unit/concerns/config_reports_extensions_test.rb +2 -0
- data/test/unit/concerns/host_managed_extensions_test.rb +2 -0
- data/test/unit/concerns/hostgroup_extensions_test.rb +2 -0
- data/test/unit/helpers/ansible_reports_helper_test.rb +2 -0
- data/test/unit/host_ansible_role_test.rb +2 -0
- data/test/unit/hostgroup_ansible_role_test.rb +2 -0
- data/test/unit/lib/foreman_ansible_core/command_creator_test.rb +2 -0
- data/test/unit/lib/foreman_ansible_core/playbook_runner_test.rb +2 -0
- data/test/unit/lib/proxy_api/ansible_test.rb +2 -0
- data/test/unit/services/ansible_report_importer_test.rb +15 -0
- data/test/unit/services/ansible_variables_importer_test.rb +39 -0
- data/test/unit/services/api_roles_importer_test.rb +2 -0
- data/test/unit/services/fact_importer_test.rb +2 -0
- data/test/unit/services/fact_parser_test.rb +47 -0
- data/test/unit/services/fact_sparser_test.rb +2 -0
- data/test/unit/services/insights_plan_runner_test.rb +2 -0
- data/test/unit/services/inventory_creator_test.rb +1 -13
- data/test/unit/services/roles_importer_test.rb +2 -0
- data/test/unit/services/structured_fact_importer_test.rb +2 -0
- data/test/unit/services/ui_roles_importer_test.rb +2 -0
- metadata +101 -42
- data/test/unit/lib/foreman_ansible_core/roles_reader_test.rb +0 -92
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
# functional tests for AnsibleVariablesController
|
5
|
+
class AnsibleVariablesControllerTest < ActionController::TestCase
|
6
|
+
setup do
|
7
|
+
@model = FactoryBot.create(:ansible_variable)
|
8
|
+
end
|
9
|
+
|
10
|
+
basic_index_test
|
11
|
+
basic_edit_test @variable
|
12
|
+
basic_pagination_per_page_test
|
13
|
+
basic_pagination_rendered_test
|
14
|
+
|
15
|
+
test 'should destroy variable' do
|
16
|
+
assert_difference('AnsibleVariable.count', -1) do
|
17
|
+
delete :destroy,
|
18
|
+
:params => { :id => @model.id },
|
19
|
+
:session => set_session_user
|
20
|
+
end
|
21
|
+
assert_redirected_to ansible_variables_url
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'there are no problems when the import hash is empty' do
|
25
|
+
ForemanAnsible::VariablesImporter.any_instance.
|
26
|
+
expects(:import_variable_names).returns({})
|
27
|
+
ForemanAnsible::UiRolesImporter.any_instance.
|
28
|
+
expects(:import_role_names).returns({})
|
29
|
+
|
30
|
+
proxy = FactoryBot.create(:smart_proxy, :with_ansible)
|
31
|
+
get :import,
|
32
|
+
:params => { :proxy => proxy.id },
|
33
|
+
:session => set_session_user
|
34
|
+
assert_response :success
|
35
|
+
end
|
36
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
module Api
|
@@ -23,16 +25,26 @@ module Api
|
|
23
25
|
refute AnsibleRole.exists?(@role.id)
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
context 'proxy API calls' do
|
29
|
+
setup do
|
30
|
+
roles = ['some_role.some_author', 'test_role.test_author']
|
31
|
+
ProxyAPI::Ansible.any_instance.expects(:roles).returns(roles)
|
32
|
+
@proxy = FactoryBot.create(:smart_proxy, :with_ansible)
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
:
|
35
|
-
|
35
|
+
test 'should import' do
|
36
|
+
put :import, :params => {
|
37
|
+
:proxy_id => @proxy.id
|
38
|
+
}, :session => set_session_user
|
39
|
+
assert_response :success
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'should obsolete' do
|
43
|
+
put :obsolete, :params => {
|
44
|
+
:proxy_id => @proxy.id
|
45
|
+
}, :session => set_session_user
|
46
|
+
assert_response :success
|
47
|
+
end
|
36
48
|
end
|
37
49
|
|
38
50
|
test 'should fetch' do
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
module Api
|
6
|
+
module V2
|
7
|
+
# Tests for the controller to CRUD Ansible Variables
|
8
|
+
class AnsibleVariablesControllerTest < ActionController::TestCase
|
9
|
+
setup do
|
10
|
+
@variable = FactoryBot.create(:ansible_variable)
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'should get index' do
|
14
|
+
get :index, :session => set_session_user
|
15
|
+
response = JSON.parse(@response.body)
|
16
|
+
refute_empty response['results']
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should destroy' do
|
21
|
+
delete :destroy,
|
22
|
+
:params => { :id => @variable.id },
|
23
|
+
:session => set_session_user
|
24
|
+
assert_response :ok
|
25
|
+
refute AnsibleVariable.exists?(@variable.id)
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'should import' do
|
29
|
+
put :import,
|
30
|
+
:session => set_session_user
|
31
|
+
assert_response :success
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'should obsolete' do
|
35
|
+
put :obsolete,
|
36
|
+
:session => set_session_user
|
37
|
+
assert_response :success
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
|
-
# Tests for the behavior of Ansible
|
4
|
-
class
|
5
|
-
should
|
6
|
-
should have_many(:hosts).through(:host_ansible_roles).dependent(:destroy)
|
7
|
-
should validate_presence_of(:name)
|
8
|
-
context 'with new role' do
|
9
|
-
subject { AnsibleRole.new(:name => 'foo') }
|
10
|
-
should validate_uniqueness_of(:name)
|
11
|
-
end
|
5
|
+
# Tests for the behavior of Ansible Variable, currently only validations
|
6
|
+
class AnsibleVariableTest < ActiveSupport::TestCase
|
7
|
+
should belong_to(:ansible_role)
|
12
8
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
|
5
|
+
# Tests for the behavior of Ansible Role, currently only validations
|
6
|
+
class AnsibleRoleTest < ActiveSupport::TestCase
|
7
|
+
should have_many(:host_ansible_roles)
|
8
|
+
should have_many(:hosts).through(:host_ansible_roles).dependent(:destroy)
|
9
|
+
should validate_presence_of(:name)
|
10
|
+
context 'with new role' do
|
11
|
+
subject { AnsibleRole.new(:name => 'foo') }
|
12
|
+
should validate_uniqueness_of(:name)
|
13
|
+
end
|
14
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
# Unit tests for AnsibleReportImporter
|
3
5
|
# This class is just meant to capture the config reports coming
|
@@ -18,4 +20,17 @@ class AnsibleReportImporterTest < ActiveSupport::TestCase
|
|
18
20
|
ForemanAnsible::AnsibleReportScanner.expects(:ansible_report?).returns(true)
|
19
21
|
assert @importer.host.new_record?
|
20
22
|
end
|
23
|
+
|
24
|
+
test 'finds host when given partially qualified name' do
|
25
|
+
host = ::FactoryBot.create(:host, :hostname => 'ansible-host.example.com')
|
26
|
+
ForemanAnsible::AnsibleReportScanner.expects(:ansible_report?).returns(true)
|
27
|
+
assert_equal host, ::ConfigReportImporter.new({ 'host' => 'ansible-host' }).host
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'creates a new host when multiple hosts for partially qualified name are found' do
|
31
|
+
::FactoryBot.create(:host, :hostname => 'ansible-host.example.com')
|
32
|
+
::FactoryBot.create(:host, :hostname => 'ansible-host.dummy.org')
|
33
|
+
ForemanAnsible::AnsibleReportScanner.expects(:ansible_report?).returns(true)
|
34
|
+
assert ::ConfigReportImporter.new({ 'host' => 'ansible-host' }).host.new_record?
|
35
|
+
end
|
21
36
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
# Unit tests for importing variables
|
5
|
+
# This service is meant to take in essentially a string coming from
|
6
|
+
# the proxy API, and parse that into AnsibleVariables.
|
7
|
+
class AnsibleVariablesImporterTest < ActiveSupport::TestCase
|
8
|
+
setup do
|
9
|
+
@importer = ForemanAnsible::VariablesImporter.new
|
10
|
+
end
|
11
|
+
test 'does not reimport already existing variables' do
|
12
|
+
already_existing = FactoryBot.create(:ansible_variable)
|
13
|
+
new_role = FactoryBot.create(:ansible_role)
|
14
|
+
api_response = {
|
15
|
+
new_role.name => ['new_var'],
|
16
|
+
already_existing.ansible_role.name => [already_existing.key]
|
17
|
+
}
|
18
|
+
changes = @importer.import_variables(api_response, [new_role.name])
|
19
|
+
assert_not_empty changes['new']
|
20
|
+
assert_equal 'new_var', changes['new'].first.key
|
21
|
+
assert_equal new_role, changes['new'].first.ansible_role
|
22
|
+
end
|
23
|
+
|
24
|
+
test "variables attempts to remove variables that don't exist anymore" do
|
25
|
+
obsolete_variable = FactoryBot.create(:ansible_variable)
|
26
|
+
changes = @importer.import_variables({}, [])
|
27
|
+
assert_not_empty changes['obsolete']
|
28
|
+
assert_equal obsolete_variable.key, changes['obsolete'].first.key
|
29
|
+
assert_equal(
|
30
|
+
obsolete_variable.ansible_role,
|
31
|
+
changes['obsolete'].first.ansible_role
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'does not do anything if response is empty' do
|
36
|
+
changes = @importer.import_variables({}, [])
|
37
|
+
assert_equal({ 'new' => [], 'obsolete' => [] }, changes)
|
38
|
+
end
|
39
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ForemanAnsible
|
2
4
|
# Checks sample Ansible facts to see if it can assign them to
|
3
5
|
# Host properties
|
@@ -58,6 +60,51 @@ module ForemanAnsible
|
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
63
|
+
# Tests for Network parser
|
64
|
+
class NetworkFactParserTest < ActiveSupport::TestCase
|
65
|
+
setup do
|
66
|
+
@facts_parser = ForemanAnsible::FactParser.new(
|
67
|
+
HashWithIndifferentAccess.new(
|
68
|
+
'_type' => 'ansible',
|
69
|
+
'_timestamp' => '2018-10-29 20:01:51 +0100',
|
70
|
+
'ansible_facts' =>
|
71
|
+
{
|
72
|
+
'ansible_interfaces' => [
|
73
|
+
'eth0'
|
74
|
+
],
|
75
|
+
'ansible_eth0' => {
|
76
|
+
'active' => true,
|
77
|
+
'device' => 'eth0',
|
78
|
+
"macaddress" => '52:54:00:04:55:37',
|
79
|
+
'ipv4' => {
|
80
|
+
'address' => '10.10.0.10',
|
81
|
+
'netmask' => '255.255.0.0',
|
82
|
+
'network' => '10.10.0.0'
|
83
|
+
},
|
84
|
+
'ipv6' => [
|
85
|
+
{
|
86
|
+
'address' => 'fd00::5054:00ff:fe04:5537',
|
87
|
+
'prefix' => '64',
|
88
|
+
'scope' => 'host'
|
89
|
+
}
|
90
|
+
],
|
91
|
+
'mtu' => 1500,
|
92
|
+
'promisc' => false,
|
93
|
+
'type' => 'ether'
|
94
|
+
}
|
95
|
+
}
|
96
|
+
)
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
test 'Parses IPv4 & IPv6 addresses correctly' do
|
101
|
+
iut = 'eth0'.dup
|
102
|
+
interface = @facts_parser.get_facts_for_interface(iut)
|
103
|
+
assert_equal '10.10.0.10', interface['ipaddress']
|
104
|
+
assert_equal 'fd00::5054:00ff:fe04:5537', interface['ipaddress6']
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
61
108
|
# Tests for Debian parser
|
62
109
|
class DebianFactParserTest < ActiveSupport::TestCase
|
63
110
|
setup do
|
@@ -10,8 +10,7 @@ module ForemanAnsible
|
|
10
10
|
setup do
|
11
11
|
@host = FactoryBot.build(:host)
|
12
12
|
@template_invocation = OpenStruct.new(
|
13
|
-
:job_invocation => OpenStruct.new(:password => 'foobar',
|
14
|
-
:sudo_password => 'foobar'),
|
13
|
+
:job_invocation => OpenStruct.new(:password => 'foobar'),
|
15
14
|
:effective_user => 'foobar'
|
16
15
|
)
|
17
16
|
end
|
@@ -42,8 +41,6 @@ module ForemanAnsible
|
|
42
41
|
returns('root').at_least_once
|
43
42
|
Setting.expects(:[]).with('remote_execution_ssh_password').
|
44
43
|
returns('asafepassword').at_least_once
|
45
|
-
Setting.expects(:[]).with('remote_execution_sudo_password').
|
46
|
-
returns('foobar').at_least_once
|
47
44
|
Setting.expects(:[]).with('ansible_winrm_server_cert_validation').
|
48
45
|
returns(true).at_least_once
|
49
46
|
Setting.expects(:[]).with('ansible_connection').
|
@@ -72,8 +69,6 @@ module ForemanAnsible
|
|
72
69
|
connection_params['ansible_port']
|
73
70
|
assert_equal Setting['remote_execution_ssh_password'],
|
74
71
|
connection_params['ansible_ssh_pass']
|
75
|
-
assert_equal Setting['remote_execution_sudo_password'],
|
76
|
-
connection_params['ansible_sudo_pass']
|
77
72
|
assert_equal Setting['ansible_winrm_server_cert_validation'],
|
78
73
|
connection_params['ansible_winrm_server_cert_validation']
|
79
74
|
end
|
@@ -85,13 +80,6 @@ module ForemanAnsible
|
|
85
80
|
inventory.rex_ssh_password(@host))
|
86
81
|
end
|
87
82
|
|
88
|
-
test 'job invocation sudo password is passed when available' do
|
89
|
-
inventory = ForemanAnsible::InventoryCreator.new(@host,
|
90
|
-
@template_invocation)
|
91
|
-
assert_equal(@template_invocation.job_invocation.sudo_password,
|
92
|
-
inventory.rex_sudo_password(@host))
|
93
|
-
end
|
94
|
-
|
95
83
|
test 'ssh private key is passed when available' do
|
96
84
|
host = FactoryBot.build(:host)
|
97
85
|
path_to_key = '/path/to/private/key'
|