foreman_ansible 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of foreman_ansible might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/images/{Ansible.png → foreman_ansible/Ansible.png} +0 -0
- data/app/models/foreman_ansible/fact_name.rb +1 -1
- data/app/services/foreman_ansible/roles_importer.rb +2 -4
- data/lib/foreman_ansible/engine.rb +12 -0
- data/lib/foreman_ansible/version.rb +1 -1
- data/test/functional/api/v2/hostgroups_controller_test.rb +1 -0
- data/test/unit/lib/foreman_ansible_core/roles_reader_test.rb +57 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4f9d4b535eba5a64364c983e66d655b71219145
|
4
|
+
data.tar.gz: bba604f472080caeff3417e6ff78fc573c49d35e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae73863ce2320c5a289f53a536f9844d72fcab62bd8f15468f4c790dc9d98e89a86cc1bf27d8bf07014a1c882367e36a4a2fb10b042a2f56a6e3c3fb43333371
|
7
|
+
data.tar.gz: 0adbe038a252a11fd4be2e36cea3ac2d08a2444fb0a9551c6add71df96fe21201bdecf1f9bb3a0350d3ccd1df09d7621ded843a609ca24e7a40286273e42e3b7
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ForemanAnsible
|
2
|
-
#
|
2
|
+
# Imports roles from smart proxy
|
3
3
|
class RolesImporter
|
4
4
|
attr_reader :ansible_proxy
|
5
5
|
|
@@ -39,9 +39,7 @@ module ForemanAnsible
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def local_roles
|
42
|
-
|
43
|
-
path.split('/').last
|
44
|
-
end
|
42
|
+
::ForemanAnsibleCore::RolesReader.list_roles
|
45
43
|
end
|
46
44
|
|
47
45
|
def remote_roles
|
@@ -95,6 +95,18 @@ module ForemanAnsible
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
initializer 'foreman_ansible.assets.precompile' do |app|
|
99
|
+
app.config.assets.precompile += %w(foreman_ansible/Ansible.png)
|
100
|
+
end
|
101
|
+
|
102
|
+
initializer 'foreman_ansible.configure_assets', :group => :assets do
|
103
|
+
SETTINGS[:foreman_ansible] = {
|
104
|
+
:assets => {
|
105
|
+
:precompile => ['foreman_ansible/Ansible.png']
|
106
|
+
}
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
98
110
|
initializer 'foreman_ansible.apipie' do
|
99
111
|
Apipie.configuration.api_controllers_matcher <<
|
100
112
|
"#{ForemanAnsible::Engine.root}/app/controllers/api/v2/*.rb"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class RolesReaderTest < ActiveSupport::TestCase
|
4
|
+
CONFIG_PATH = '/etc/ansible/ansible.cfg'.freeze
|
5
|
+
ROLES_PATH = '/etc/ansible/roles'.freeze
|
6
|
+
|
7
|
+
describe '#roles_path' do
|
8
|
+
test 'detects commented roles_path' do
|
9
|
+
expect_content_config ['#roles_path = thisiscommented!']
|
10
|
+
assert_equal(ROLES_PATH,
|
11
|
+
ForemanAnsibleCore::RolesReader.roles_path(CONFIG_PATH))
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'returns default path if no roles_path defined' do
|
15
|
+
expect_content_config ['norolepath!']
|
16
|
+
assert_equal(ROLES_PATH,
|
17
|
+
ForemanAnsibleCore::RolesReader.roles_path(CONFIG_PATH))
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'returns roles_path if one is defined' do
|
21
|
+
expect_content_config ['roles_path = /mycustom/ansibleroles/path']
|
22
|
+
assert_equal('/mycustom/ansibleroles/path',
|
23
|
+
ForemanAnsibleCore::RolesReader.roles_path(CONFIG_PATH))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#list_roles' do
|
28
|
+
setup do
|
29
|
+
# Return a path without actually reading the config file to make tests
|
30
|
+
# pass even on hosts without Ansible installed
|
31
|
+
ForemanAnsibleCore::RolesReader.stubs(:roles_path).
|
32
|
+
returns('/etc/ansible/roles')
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'handles "No such file or dir" with exception' do
|
36
|
+
Dir.expects(:glob).with("#{ROLES_PATH}/*").raises(Errno::ENOENT)
|
37
|
+
ex = assert_raises(ForemanAnsibleCore::ReadConfigFileException) do
|
38
|
+
ForemanAnsibleCore::RolesReader.list_roles
|
39
|
+
end
|
40
|
+
assert_match(/Could not read Ansible config file/, ex.message)
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'raises error if the roles path is not readable' do
|
44
|
+
Dir.expects(:glob).with("#{ROLES_PATH}/*").raises(Errno::EACCES)
|
45
|
+
ex = assert_raises(ForemanAnsibleCore::ReadConfigFileException) do
|
46
|
+
ForemanAnsibleCore::RolesReader.list_roles
|
47
|
+
end
|
48
|
+
assert_match(/Could not read Ansible config file/, ex.message)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def expect_content_config(ansible_cfg_content)
|
55
|
+
File.expects(:readlines).with(CONFIG_PATH).returns(ansible_cfg_content)
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_ansible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Lobato Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -90,7 +90,7 @@ files:
|
|
90
90
|
- LICENSE
|
91
91
|
- README.md
|
92
92
|
- Rakefile
|
93
|
-
- app/assets/images/Ansible.png
|
93
|
+
- app/assets/images/foreman_ansible/Ansible.png
|
94
94
|
- app/controllers/ansible_roles_controller.rb
|
95
95
|
- app/controllers/api/v2/ansible_roles_controller.rb
|
96
96
|
- app/controllers/foreman_ansible/api/v2/hostgroups_controller_extensions.rb
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- test/unit/host_ansible_role_test.rb
|
182
182
|
- test/unit/hostgroup_ansible_role_test.rb
|
183
183
|
- test/unit/lib/foreman_ansible_core/playbook_runner_test.rb
|
184
|
+
- test/unit/lib/foreman_ansible_core/roles_reader_test.rb
|
184
185
|
- test/unit/lib/proxy_api/ansible_test.rb
|
185
186
|
- test/unit/services/api_roles_importer_test.rb
|
186
187
|
- test/unit/services/fact_importer_test.rb
|
@@ -242,5 +243,6 @@ test_files:
|
|
242
243
|
- test/unit/ansible_role_test.rb
|
243
244
|
- test/unit/lib/proxy_api/ansible_test.rb
|
244
245
|
- test/unit/lib/foreman_ansible_core/playbook_runner_test.rb
|
246
|
+
- test/unit/lib/foreman_ansible_core/roles_reader_test.rb
|
245
247
|
- test/unit/hostgroup_ansible_role_test.rb
|
246
248
|
- test/unit/helpers/foreman_ansible/ansible_reports_helper_test.rb
|