foreman_ansible_core 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 44d77dc2797ce73069b122c3632898d2216ba97ddb474c1f6f08e6bb18746829
4
- data.tar.gz: 3926d312b5e13d8b38931ff4cf2657158aecbfdd3afd17b0f33b433a0287ff18
2
+ SHA1:
3
+ metadata.gz: e195d6690093de003b7ddaf9b807ac0d79ad775a
4
+ data.tar.gz: 4286d8f97ffca80c17be58c302fb2aeffbf1d02f
5
5
  SHA512:
6
- metadata.gz: d84b0cb0fda48488505d7f46820adfd6dc5149ffe8514f2a790acf5f2af8be84e6c7e42a450c2b8eaeb027ee40693e8d324bb939fc4c3d6608ec9cee61536f83
7
- data.tar.gz: '08f71e6e969dae793369aa09ddf930dab78185ce039ce8539fee2210aeec41689980a8aed81ee23dc3ed8cc1700ae5f7134fecf2737a2f8d0f4697b5702c4687'
6
+ metadata.gz: b1555fd4cb45577b25aa1f6b6ff4ba0ac02d354fa3c74e33790dc63e3454de9d70c1a01b4cc929b1096437395dfbdbb519e82e22f333710da2a5b5cf0d12331b
7
+ data.tar.gz: 23e7b36347e64370135f75e18165d424ba6ee7bc429335be4e83a1778e05d6fd17c38c2ba1f76e8a0515cd424b4cf644c0b7995b876aa3f4055e4ccb5bcaf53c
@@ -1,39 +1,29 @@
1
- begin
2
- require 'foreman_tasks_core'
3
- require 'foreman_remote_execution_core'
4
- # rubocop:disable Lint/HandleExceptions
5
- rescue LoadError
6
- # These gems are not available in a proxy SCLed context
7
- # puts 'Running Foreman Ansible Core in non-SCL context'
8
- end
9
- # rubocop:enable Lint/HandleExceptions
1
+ # frozen_string_literal: true
2
+
3
+ require 'foreman_tasks_core'
4
+ require 'foreman_remote_execution_core'
10
5
 
11
6
  # Core actions for Foreman Ansible, used by both Foreman and Foreman proxy
12
7
  # This comprises running playbooks for the moment
13
8
  module ForemanAnsibleCore
14
9
  require 'foreman_ansible_core/exception'
15
- require 'foreman_ansible_core/roles_reader'
16
10
  require 'foreman_ansible_core/version'
17
11
 
18
- if defined? ForemanTasksCore
19
- extend ForemanTasksCore::SettingsLoader
20
- register_settings(:ansible, :ansible_dir => Dir.home,
21
- :working_dir => nil)
12
+ extend ForemanTasksCore::SettingsLoader
13
+ register_settings(:ansible, :ansible_dir => Dir.home,
14
+ :working_dir => nil)
22
15
 
23
- if ForemanTasksCore.dynflow_present?
24
- require 'foreman_tasks_core/runner'
25
- require 'foreman_ansible_core/playbook_runner'
26
- require 'foreman_ansible_core/actions'
27
- end
16
+ if ForemanTasksCore.dynflow_present?
17
+ require 'foreman_tasks_core/runner'
18
+ require 'foreman_ansible_core/playbook_runner'
19
+ require 'foreman_ansible_core/actions'
28
20
  end
29
21
 
30
- if defined? ForemanTasksCore
31
- require 'foreman_remote_execution_core/actions'
32
- require 'foreman_ansible_core/remote_execution_core/ansible_runner'
33
- require 'foreman_ansible_core/remote_execution_core/settings_override'
34
- ForemanRemoteExecutionCore::Actions::RunScript.send(
35
- :prepend,
36
- ForemanAnsibleCore::RemoteExecutionCore::SettingsOverride
37
- )
38
- end
22
+ require 'foreman_remote_execution_core/actions'
23
+ require 'foreman_ansible_core/remote_execution_core/ansible_runner'
24
+ require 'foreman_ansible_core/remote_execution_core/settings_override'
25
+ ForemanRemoteExecutionCore::Actions::RunScript.send(
26
+ :prepend,
27
+ ForemanAnsibleCore::RemoteExecutionCore::SettingsOverride
28
+ )
39
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'foreman_tasks_core/shareable_action'
2
4
 
3
5
  module ForemanAnsibleCore
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanAnsibleCore
2
4
  # Creates the actual command to be passed to foreman_tasks_core to run
3
5
  class CommandCreator
@@ -48,7 +50,7 @@ module ForemanAnsibleCore
48
50
  verbosity_level = @options[:verbosity_level]
49
51
  # rubocop:disable Rails/Present
50
52
  !verbosity_level.nil? && !verbosity_level.empty? &&
51
- verbosity_level.to_i > 0
53
+ verbosity_level.to_i.positive?
52
54
  # rubocop:enable Rails/Present
53
55
  end
54
56
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanAnsibleCore
2
4
  # Taken from Foreman core, this class creates an error code for any exception
3
5
  class Exception < ::StandardError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'foreman_tasks_core/runner/command_runner'
2
4
  require_relative 'command_creator'
3
5
  require 'tmpdir'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanAnsibleCore
2
4
  module RemoteExecutionCore
3
5
  # Takes an inventory and runs it through REXCore CommandRunner
@@ -14,6 +16,7 @@ module ForemanAnsibleCore
14
16
  end
15
17
 
16
18
  def start
19
+ @playbook_runner.logger = logger
17
20
  @playbook_runner.start
18
21
  rescue StandardError => e
19
22
  logger.error(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanAnsibleCore
2
4
  module RemoteExecutionCore
3
5
  # Ensure the Ansible provider is used whenever a JobTemplate using this
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanAnsibleCore
2
- VERSION = '2.1.2'.freeze
4
+ VERSION = '2.2.0'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_ansible_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
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: 2018-08-14 00:00:00.000000000 Z
11
+ date: 2018-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -84,7 +84,6 @@ files:
84
84
  - lib/foreman_ansible_core/playbook_runner.rb
85
85
  - lib/foreman_ansible_core/remote_execution_core/ansible_runner.rb
86
86
  - lib/foreman_ansible_core/remote_execution_core/settings_override.rb
87
- - lib/foreman_ansible_core/roles_reader.rb
88
87
  - lib/foreman_ansible_core/version.rb
89
88
  homepage: https://github.com/theforeman/foreman_ansible
90
89
  licenses:
@@ -106,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
105
  version: '0'
107
106
  requirements: []
108
107
  rubyforge_project:
109
- rubygems_version: 2.7.6
108
+ rubygems_version: 2.6.8
110
109
  signing_key:
111
110
  specification_version: 4
112
111
  summary: 'Ansible integration with Foreman (theforeman.org): core bits'
@@ -1,61 +0,0 @@
1
- module ForemanAnsibleCore
2
- # Implements the logic needed to read the roles and associated information
3
- class RolesReader
4
- class << self
5
- DEFAULT_CONFIG_FILE = '/etc/ansible/ansible.cfg'.freeze
6
- DEFAULT_ROLES_PATH = '/etc/ansible/roles'.freeze
7
-
8
- def list_roles
9
- roles_path.split(':').map { |path| read_roles(path) }.flatten
10
- end
11
-
12
- def roles_path(roles_line = roles_path_from_config)
13
- # Default to /etc/ansible/roles if none found
14
- return DEFAULT_ROLES_PATH if roles_line.empty?
15
- roles_path_key = roles_line.first.split('=').first.strip
16
- # In case of commented roles_path key "#roles_path", return default
17
- return DEFAULT_ROLES_PATH unless roles_path_key == 'roles_path'
18
- roles_line.first.split('=').last.strip
19
- end
20
-
21
- def logger
22
- # Return a different logger depending on where ForemanAnsibleCore is
23
- # running from
24
- if defined?(::Foreman::Logging)
25
- ::Foreman::Logging.logger('foreman_ansible')
26
- else
27
- ::Proxy::LogBuffer::Decorator.instance
28
- end
29
- end
30
-
31
- private
32
-
33
- def read_roles(roles_path)
34
- rescue_and_raise_file_exception ReadRolesException,
35
- roles_path, 'roles' do
36
- Dir.glob("#{roles_path}/*").map do |path|
37
- path.split('/').last
38
- end
39
- end
40
- end
41
-
42
- def roles_path_from_config
43
- rescue_and_raise_file_exception ReadConfigFileException,
44
- DEFAULT_CONFIG_FILE, 'config file' do
45
- File.readlines(DEFAULT_CONFIG_FILE).select do |line|
46
- line =~ /roles_path/
47
- end
48
- end
49
- end
50
-
51
- def rescue_and_raise_file_exception(exception, path, type)
52
- yield
53
- rescue Errno::ENOENT, Errno::EACCES => e
54
- logger.debug(e.backtrace)
55
- exception_message = "Could not read Ansible #{type} "\
56
- "#{path} - #{e.message}"
57
- raise exception.new(exception_message)
58
- end
59
- end
60
- end
61
- end