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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 961b0d96c607da71c4214e237b1a5d1d595c2341
4
- data.tar.gz: 7f277e85dbd6f315901320a7b17f0c2fbad7651f
3
+ metadata.gz: e4f9d4b535eba5a64364c983e66d655b71219145
4
+ data.tar.gz: bba604f472080caeff3417e6ff78fc573c49d35e
5
5
  SHA512:
6
- metadata.gz: 0db1687cfc62fd88d5a2f15e29375588ce22b6a7bf0063c89bd70501167bacdf5d891188bc50746b614bf0e427ead475a75ee6d601a1fa6abbe73951fd16c721
7
- data.tar.gz: 0128248c361e8253f9ef03cdcd39bc4a825cbf1f9f6d3b9b8e3a9954c708ff280ec5dd1510d392510ab45633a8b20a8b6575d2259c52be36cc4b1cd2ebe1500a
6
+ metadata.gz: ae73863ce2320c5a289f53a536f9844d72fcab62bd8f15468f4c790dc9d98e89a86cc1bf27d8bf07014a1c882367e36a4a2fb10b042a2f56a6e3c3fb43333371
7
+ data.tar.gz: 0adbe038a252a11fd4be2e36cea3ac2d08a2444fb0a9551c6add71df96fe21201bdecf1f9bb3a0350d3ccd1df09d7621ded843a609ca24e7a40286273e42e3b7
@@ -4,7 +4,7 @@ module ForemanAnsible
4
4
  # in the fact values table (/fact_values)
5
5
  class FactName < ::FactName
6
6
  def origin
7
- 'Ansible'
7
+ 'foreman_ansible/Ansible'
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  module ForemanAnsible
2
- # imports roles from smart proxy
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
- Dir.glob('/etc/ansible/roles/*').map do |path|
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"
@@ -2,5 +2,5 @@
2
2
  # This way other parts of Foreman can just call ForemanAnsible::VERSION
3
3
  # and detect what version the plugin is running.
4
4
  module ForemanAnsible
5
- VERSION = '1.4.2'.freeze
5
+ VERSION = '1.4.3'.freeze
6
6
  end
@@ -1,4 +1,5 @@
1
1
  require 'test_plugin_helper'
2
+ require 'dynflow/testing'
2
3
 
3
4
  module Api
4
5
  module V2
@@ -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.2
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-01-30 00:00:00.000000000 Z
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