foreman_ansible 4.0.3.5 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/ansible_inventories_controller.rb +9 -4
  3. data/app/controllers/api/v2/ansible_roles_controller.rb +2 -2
  4. data/app/controllers/api/v2/ansible_variables_controller.rb +1 -2
  5. data/app/controllers/foreman_ansible/api/v2/hostgroups_controller_extensions.rb +2 -2
  6. data/app/controllers/foreman_ansible/api/v2/hosts_controller_extensions.rb +2 -2
  7. data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +0 -4
  8. data/app/models/foreman_ansible/ansible_provider.rb +8 -0
  9. data/app/models/setting/ansible.rb +1 -5
  10. data/app/services/foreman_ansible/ansible_info.rb +1 -1
  11. data/app/services/foreman_ansible/insights_notification_builder.rb +0 -2
  12. data/app/services/foreman_ansible/operating_system_parser.rb +1 -5
  13. data/app/services/foreman_ansible/variables_importer.rb +9 -9
  14. data/app/views/ansible_variables/_fields.erb +1 -1
  15. data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +71 -0
  16. data/config/routes.rb +1 -3
  17. data/db/migrate/20160802153302_create_join_table_hostgroup_ansible_roles.rb +0 -2
  18. data/db/migrate/20200421201839_update_ansible_inv_template_name.rb +9 -0
  19. data/db/seeds.d/75_job_templates.rb +1 -1
  20. data/lib/foreman_ansible/engine.rb +22 -27
  21. data/lib/foreman_ansible/register.rb +1 -3
  22. data/lib/foreman_ansible/remote_execution.rb +11 -0
  23. data/lib/foreman_ansible/version.rb +1 -1
  24. data/locale/action_names.rb +3 -3
  25. data/locale/ca/LC_MESSAGES/foreman_ansible.mo +0 -0
  26. data/locale/ca/foreman_ansible.po +556 -0
  27. data/locale/cs_CZ/LC_MESSAGES/foreman_ansible.mo +0 -0
  28. data/locale/cs_CZ/foreman_ansible.po +556 -0
  29. data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
  30. data/locale/de/foreman_ansible.po +38 -33
  31. data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
  32. data/locale/en/foreman_ansible.po +38 -33
  33. data/locale/en_GB/LC_MESSAGES/foreman_ansible.mo +0 -0
  34. data/locale/en_GB/foreman_ansible.po +555 -0
  35. data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
  36. data/locale/es/foreman_ansible.po +38 -33
  37. data/locale/foreman_ansible.pot +96 -88
  38. data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
  39. data/locale/fr/foreman_ansible.po +38 -33
  40. data/locale/gl/LC_MESSAGES/foreman_ansible.mo +0 -0
  41. data/locale/gl/foreman_ansible.po +553 -0
  42. data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
  43. data/locale/it/foreman_ansible.po +38 -33
  44. data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
  45. data/locale/ja/foreman_ansible.po +38 -33
  46. data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
  47. data/locale/ko/foreman_ansible.po +38 -33
  48. data/locale/nl_NL/LC_MESSAGES/foreman_ansible.mo +0 -0
  49. data/locale/nl_NL/foreman_ansible.po +559 -0
  50. data/locale/pl/LC_MESSAGES/foreman_ansible.mo +0 -0
  51. data/locale/pl/foreman_ansible.po +556 -0
  52. data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
  53. data/locale/pt_BR/foreman_ansible.po +38 -33
  54. data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
  55. data/locale/ru/foreman_ansible.po +38 -33
  56. data/locale/sv_SE/LC_MESSAGES/foreman_ansible.mo +0 -0
  57. data/locale/sv_SE/foreman_ansible.po +556 -0
  58. data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
  59. data/locale/zh_CN/foreman_ansible.po +38 -33
  60. data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
  61. data/locale/zh_TW/foreman_ansible.po +38 -33
  62. data/package.json +14 -16
  63. data/test/factories/ansible_variables.rb +5 -0
  64. data/test/functional/api/v2/ansible_inventories_controller_test.rb +3 -3
  65. data/test/functional/api/v2/ansible_variables_controller_test.rb +12 -0
  66. data/test/unit/services/ansible_variables_importer_test.rb +68 -43
  67. data/test/unit/services/inventory_creator_test.rb +0 -4
  68. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js +1 -0
  69. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js +5 -1
  70. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js +8 -1
  71. data/webpack/components/AnsibleRolesSwitcher/index.js +1 -4
  72. data/webpack/test_setup.js +2 -1
  73. metadata +54 -80
  74. data/locale/de/foreman_ansible.edit.po +0 -825
  75. data/locale/de/foreman_ansible.po.time_stamp +0 -0
  76. data/locale/en/foreman_ansible.edit.po +0 -714
  77. data/locale/en/foreman_ansible.po.time_stamp +0 -0
  78. data/locale/es/foreman_ansible.edit.po +0 -845
  79. data/locale/es/foreman_ansible.po.time_stamp +0 -0
  80. data/locale/fr/foreman_ansible.edit.po +0 -847
  81. data/locale/fr/foreman_ansible.po.time_stamp +0 -0
  82. data/locale/it/foreman_ansible.edit.po +0 -818
  83. data/locale/it/foreman_ansible.po.time_stamp +0 -0
  84. data/locale/ja/foreman_ansible.edit.po +0 -818
  85. data/locale/ja/foreman_ansible.po.time_stamp +0 -0
  86. data/locale/ko/foreman_ansible.edit.po +0 -804
  87. data/locale/ko/foreman_ansible.po.time_stamp +0 -0
  88. data/locale/pt_BR/foreman_ansible.edit.po +0 -845
  89. data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
  90. data/locale/ru/foreman_ansible.edit.po +0 -819
  91. data/locale/ru/foreman_ansible.po.time_stamp +0 -0
  92. data/locale/zh_CN/foreman_ansible.edit.po +0 -813
  93. data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
  94. data/locale/zh_TW/foreman_ansible.edit.po +0 -804
  95. data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f5cb37ac21d410601d1f871a73f125511574ae218f6a488c865c45e64761c88
4
- data.tar.gz: 4bbb6f29895b798715e7d5915d2370e56feefc3ba0ad67365bb03af40ca2dc93
3
+ metadata.gz: f38e865029b1349a0f9a61bf6cc5a57fc5421d4ea41ef57ed9d45d0d04fe4fd9
4
+ data.tar.gz: a63c7fc0d6e359ecd27283c9815c78ec3f6ff05e774e33c5bcaff5fdfde48ae7
5
5
  SHA512:
6
- metadata.gz: ea3fd4b934442a52ae46cf71ec2931f67159da7df6906ffc99a7c4616e074d25ab3349021deddeef60258f781969979743ea1aa6eb97e0d575b1a9d912e41663
7
- data.tar.gz: 39861b01ad80bac36159c3b6b3b243084f71f4567caa18dc35e9e02e87d92ca53ec27ec31ec467900c8b1aca7979ac0623314c90604bcae370caf3be92148eb6
6
+ metadata.gz: 94ca7682492e8648fd8b23f55cbe2fe1e13da17ff8853d1b196fd778282bf46f9a93f335175490c40be2a20198fdd3a3f6f3abccbb62b615fa9c5464279b0fd9
7
+ data.tar.gz: 9d976f8e4dccd761d9e4568e98a337704321658613aa01dd6d94335db668885c1c8d1c456aa53e56dd88865e2714d90185fc094647e63c28c5d84bac07410a9a
@@ -3,6 +3,11 @@ module Api
3
3
  class AnsibleInventoriesController < ::Api::V2::BaseController
4
4
  include ::Api::Version2
5
5
 
6
+ resource_description do
7
+ api_version 'v2'
8
+ api_base_url '/ansible/api'
9
+ end
10
+
6
11
  api :POST, '/ansible_inventories/hosts',
7
12
  N_('Show Ansible inventory for hosts')
8
13
  param :host_ids, Array, N_('IDs of hosts included in inventory'),
@@ -13,6 +18,10 @@ module Api
13
18
  param :host_ids, Array, N_('IDs of hosts included in inventory'),
14
19
  :required => true
15
20
 
21
+ def hosts
22
+ show_inventory :host_ids, :id
23
+ end
24
+
16
25
  api :POST, '/ansible_inventories/hostgroups',
17
26
  N_('Show Ansible inventory for hostgroups')
18
27
  param :hostgroup_ids, Array, N_('IDs of hostgroups included in inventory'),
@@ -23,10 +32,6 @@ module Api
23
32
  param :hostgroup_ids, Array, N_('IDs of hostgroups included in inventory'),
24
33
  :required => true
25
34
 
26
- def hosts
27
- show_inventory :host_ids, :id
28
- end
29
-
30
35
  def hostgroups
31
36
  show_inventory :hostgroup_ids, :hostgroup_id
32
37
  end
@@ -67,7 +67,7 @@ module Api
67
67
  params.fetch(:role_names, [])
68
68
  end
69
69
 
70
- # rubocop:disable DotPosition
70
+ # rubocop:disable Layout/DotPosition
71
71
  def find_proxy
72
72
  unless params[:proxy_id]
73
73
  msg = _('Smart proxy id is required')
@@ -76,7 +76,7 @@ module Api
76
76
  @proxy = SmartProxy.authorized(:view_smart_proxies)
77
77
  .find(params[:proxy_id])
78
78
  end
79
- # rubocop:enable DotPosition
79
+ # rubocop:enable Layout/DotPosition
80
80
 
81
81
  def create_importer
82
82
  @importer = ForemanAnsible::ApiRolesImporter.new(@proxy)
@@ -5,7 +5,6 @@ module Api
5
5
  # API controller for Ansible Variables
6
6
  class AnsibleVariablesController < ::Api::V2::BaseController
7
7
  include ::Api::Version2
8
- include Foreman::Controller::Parameters::VariableLookupKey
9
8
  include Foreman::Controller::Parameters::AnsibleVariable
10
9
 
11
10
  resource_description do
@@ -65,7 +64,7 @@ module Api
65
64
  param_group :ansible_variable, :as => :update
66
65
 
67
66
  def update
68
- @ansible_variable.update!(variable_lookup_key_params)
67
+ @ansible_variable.update!(ansible_variable_params)
69
68
  render 'api/v2/ansible_variables/show'
70
69
  end
71
70
 
@@ -12,7 +12,7 @@ module ForemanAnsible
12
12
 
13
13
  # Included blocks shouldn't be bound by length, as otherwise concerns
14
14
  # cannot extend the method properly.
15
- # rubocop:disable BlockLength, Rails/LexicallyScopedActionFilter
15
+ # rubocop:disable Rails/LexicallyScopedActionFilter
16
16
  included do
17
17
  before_action :find_ansible_roles, :only => [:assign_ansible_roles]
18
18
 
@@ -61,7 +61,7 @@ module ForemanAnsible
61
61
  process_response @hostgroup.update(:ansible_roles => @ansible_roles)
62
62
  end
63
63
  end
64
- # rubocop:enable BlockLength, Rails/LexicallyScopedActionFilter
64
+ # rubocop:enable Rails/LexicallyScopedActionFilter
65
65
 
66
66
  private
67
67
 
@@ -12,7 +12,7 @@ module ForemanAnsible
12
12
 
13
13
  # Included blocks shouldn't be bound by length, as otherwise concerns
14
14
  # cannot extend the method properly.
15
- # rubocop:disable BlockLength, Rails/LexicallyScopedActionFilter
15
+ # rubocop:disable Rails/LexicallyScopedActionFilter
16
16
  included do
17
17
  before_action :find_ansible_roles, :only => [:assign_ansible_roles]
18
18
 
@@ -63,7 +63,7 @@ module ForemanAnsible
63
63
  process_response @host.update(:ansible_roles => @ansible_roles)
64
64
  end
65
65
  end
66
- # rubocop:enable BlockLength, Rails/LexicallyScopedActionFilter
66
+ # rubocop:enable Rails/LexicallyScopedActionFilter
67
67
 
68
68
  private
69
69
 
@@ -4,7 +4,6 @@ require 'ipaddress'
4
4
  module ForemanAnsible
5
5
  # Relations to make Host::Managed 'have' ansible roles
6
6
  module HostManagedExtensions
7
- # rubocop:disable Metrics/BlockLength
8
7
  def self.prepended(base)
9
8
  base.instance_eval do
10
9
  include ::ForemanAnsible::Concerns::JobInvocationHelper
@@ -30,7 +29,6 @@ module ForemanAnsible
30
29
 
31
30
  # This one should be fixed, disabled for the moment as we're
32
31
  # in a rush to get the release out
33
- # rubocop:disable Metrics/AbcSize
34
32
  def play_ansible_roles
35
33
  return true unless ansible_roles.present? ||
36
34
  inherited_ansible_roles.present?
@@ -47,13 +45,11 @@ module ForemanAnsible
47
45
  logger.info("Error running Ansible roles on #{self} before_provision: "\
48
46
  "#{e.message}")
49
47
  end
50
- # rubocop:enable Metrics/AbcSize
51
48
 
52
49
  def all_ansible_roles
53
50
  (ansible_roles + inherited_ansible_roles).uniq
54
51
  end
55
52
 
56
- # rubocop:enable Metrics/BlockLength
57
53
  # Class methods we may need to override or add
58
54
  module ClassMethods
59
55
  def import_host(*args)
@@ -62,6 +62,14 @@ if defined? ForemanRemoteExecution
62
62
  'ansible-runner'
63
63
  end
64
64
 
65
+ def required_proxy_selector_for(template)
66
+ if template.remote_execution_features.where(:label => 'ansible_run_capsule_upgrade').any?
67
+ ::DefaultProxyProxySelector.new
68
+ else
69
+ super
70
+ end
71
+ end
72
+
65
73
  private
66
74
 
67
75
  def ansible_command?(template)
@@ -7,8 +7,6 @@ class Setting
7
7
  # It would be more disadvantages than advantages to split up
8
8
  # default_settings into multiple methods, this way it's already very
9
9
  # manageable.
10
- # rubocop:disable AbcSize
11
- # rubocop:disable MethodLength
12
10
  def default_settings
13
11
  [
14
12
  set(
@@ -80,13 +78,11 @@ class Setting
80
78
  'ansible_inventory_template',
81
79
  N_('Foreman will use this template to schedule the report '\
82
80
  'with Ansible inventory'),
83
- 'Ansible Inventory',
81
+ 'Ansible - Ansible Inventory',
84
82
  N_('Default Ansible inventory report template')
85
83
  )
86
84
  ]
87
85
  end
88
- # rubocop:enable AbcSize
89
- # rubocop:enable MethodLength
90
86
 
91
87
  def load_defaults
92
88
  Setting::BLANK_ATTRS.push('ansible_ssh_private_key_file')
@@ -10,7 +10,7 @@ module ForemanAnsible
10
10
 
11
11
  variables.each_with_object({}) do |var, memo|
12
12
  value = values[var]
13
- memo[var.key] = value if value
13
+ memo[var.key] = value unless value.nil?
14
14
  memo
15
15
  end
16
16
  end
@@ -3,9 +3,7 @@
3
3
  module ForemanAnsible
4
4
  # A class that builds custom notificaton for REX job if it's insights
5
5
  # remediation feature
6
- # rubocop:disable LineLength
7
6
  class InsightsNotificationBuilder < ::UINotifications::RemoteExecutionJobs::BaseJobFinish
8
- # rubocop:enable LineLength
9
7
  def deliver!
10
8
  ::Notification.create!(
11
9
  :audience => Notification::AUDIENCE_USER,
@@ -45,7 +45,6 @@ module ForemanAnsible
45
45
  facts[:ansible_distribution_release]
46
46
  end
47
47
 
48
- # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
49
48
  def os_major
50
49
  if os_name == 'Debian' &&
51
50
  facts[:ansible_distribution_major_version][%r{\/sid}i]
@@ -56,16 +55,14 @@ module ForemanAnsible
56
55
  (facts[:version].split('R')[0] if os_name == 'junos')
57
56
  end
58
57
  end
59
- # rubocop:enable AbcSize, CyclomaticComplexity, PerceivedComplexity
60
58
 
61
59
  def os_release
62
60
  facts[:ansible_distribution_version] ||
63
61
  facts[:ansible_lsb] && facts[:ansible_lsb]['release']
64
62
  end
65
63
 
66
- # rubocop:disable AbcSize
67
64
  def os_minor
68
- _, minor = (os_release&.split('.', 2)) ||
65
+ _, minor = os_release&.split('.', 2) ||
69
66
  (facts[:version].split('R') if os_name == 'junos')
70
67
  # Until Foreman supports os.minor as something that's not a number,
71
68
  # we should remove the extra dots in the version. E.g:
@@ -87,7 +84,6 @@ module ForemanAnsible
87
84
  facts[:ansible_lsb] && facts[:ansible_lsb]['id']
88
85
  end
89
86
  end
90
- # rubocop:enable AbcSize
91
87
 
92
88
  def os_description
93
89
  if facts[:ansible_os_family] == 'Windows'
@@ -29,6 +29,7 @@ module ForemanAnsible
29
29
  def import_variables(role_variables, new_roles)
30
30
  detect_changes(
31
31
  role_variables.map do |role_name, variables|
32
+ next if variables.blank?
32
33
  role = import_new_role(role_name, new_roles)
33
34
  next if role.blank?
34
35
  initialize_variables(variables, role)
@@ -47,22 +48,21 @@ module ForemanAnsible
47
48
  def initialize_variables(variables, role)
48
49
  variables.map do |variable_name, variable_default|
49
50
  variable = AnsibleVariable.find_or_initialize_by(
50
- :key => variable_name
51
+ :key => variable_name,
52
+ :ansible_role_id => role.id
51
53
  )
52
- if variable.new_record?
53
- variable.assign_attributes(:default_value => variable_default,
54
- :key_type => infer_key_type(variable_default),
55
- :imported => true)
56
- end
57
- variable.ansible_role = role
54
+ variable.assign_attributes(:default_value => variable_default,
55
+ :key_type => infer_key_type(variable_default))
56
+ variable.imported = true if variable.new_record?
58
57
  variable.valid? ? variable : nil
59
58
  end
60
59
  end
61
60
 
62
61
  def detect_changes(imported)
63
62
  changes = {}.with_indifferent_access
64
- persisted, changes[:new] = imported.partition { |role| role.id.present? }
65
- changes[:update], _old = persisted.partition(&:changed?)
63
+ persisted, changes[:new] = imported.partition { |var| var.id.present? }
64
+ changed, _old = persisted.partition(&:changed?)
65
+ _overriden, changes[:update] = changed.partition(&:override?)
66
66
  changes[:obsolete] = AnsibleVariable.where.not(:id => persisted.pluck(:id), :imported => false)
67
67
  changes
68
68
  end
@@ -15,7 +15,7 @@
15
15
  ) %>
16
16
 
17
17
  <% version = Foreman::Version.new %>
18
- <% if version.major.to_i >= 1 && version.minor.to_i >= 22 %>
18
+ <% if version.major.to_i > 1 || version.minor.to_i >= 22 %>
19
19
  <%= param_type_selector(f, false, :onchange => 'keyTypeChange(this)', :disabled => !f.object.override) %>
20
20
  <% else %>
21
21
  <%= param_type_selector(f, :onchange => 'keyTypeChange(this)', :disabled => !f.object.override) %>
@@ -0,0 +1,71 @@
1
+ <%#
2
+ name: Capsule Upgrade Playbook
3
+ snippet: false
4
+ template_inputs:
5
+ - name: target_version
6
+ required: true
7
+ input_type: user
8
+ advanced: false
9
+ value_type: plain
10
+ hidden_value: false
11
+ - name: whitelist_options
12
+ required: false
13
+ input_type: user
14
+ advanced: false
15
+ value_type: plain
16
+ hidden_value: false
17
+ model: JobTemplate
18
+ job_category: Ansible Playbook
19
+ description_format: "%{template_name}"
20
+ provider_type: Ansible
21
+ kind: job_template
22
+ feature: ansible_run_capsule_upgrade
23
+ %>
24
+
25
+ ---
26
+ - hosts: all
27
+ tasks:
28
+ - name: Gather the rpm package facts
29
+ package_facts:
30
+ manager: auto
31
+
32
+ - name: Fail if the target server is a Satellite server
33
+ fail:
34
+ msg: "This playbook cannot be executed on a Satellite server. Use only on a Capsule server."
35
+ when: "'satellite' in ansible_facts.packages"
36
+
37
+ - name: Install satellite-maintain if not present
38
+ package:
39
+ name: rubygem-foreman_maintain
40
+ state: present
41
+ when: "'rubygem-foreman_maintain' not in ansible_facts.packages"
42
+
43
+ - block:
44
+ - name: Upgrade Capsule server using satellite-maintain
45
+ shell: satellite-maintain upgrade run --assumeyes --target-version=<%= input('target_version') %> --whitelist="<%= input('whitelist_options') %>"
46
+ register: result
47
+
48
+ - name: Re-Gather the rpm package facts after the upgrade
49
+ package_facts:
50
+ manager: auto
51
+
52
+ - name: satellite-maintain upgrade return code is zero
53
+ debug:
54
+ msg: "Success! Capsule server upgrade completed. Current version of Capsule server server is {{ ansible_facts.packages['satellite-capsule'][0]['version'] }}."
55
+
56
+ rescue:
57
+ - name: Print satellite-maintain output
58
+ debug:
59
+ var: result
60
+
61
+ - name: Grep top 10 Error messages from /var/log/foreman-installer/capsule.log
62
+ shell: grep '^\[ERROR' /var/log/foreman-installer/capsule.log | head -n10
63
+ register: output_grep
64
+
65
+ - name: Print grepped Error messages
66
+ debug:
67
+ var: output_grep.stdout_lines
68
+
69
+ - name: satellite-maintain upgrade return code is non-zero
70
+ fail:
71
+ msg: "Failed! Capsule server upgrade failed. See /var/log/foreman-installer/capsule.log in the Capsule server for more information"
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable BlockLength
4
3
  Rails.application.routes.draw do
5
4
  namespace :api do
6
5
  scope '(:apiv)',
@@ -73,7 +72,7 @@ Rails.application.routes.draw do
73
72
  :module => :v2,
74
73
  :defaults => { :apiv => 'v2' },
75
74
  :apiv => /v1|v2/,
76
- :constraints => ApiConstraints.new(:version => 2) do
75
+ :constraints => ApiConstraints.new(:version => 2, :default => true) do
77
76
  resources :ansible_roles, :only => [:show, :index, :destroy] do
78
77
  collection do
79
78
  put :import
@@ -104,4 +103,3 @@ Rails.application.routes.draw do
104
103
  end
105
104
  end
106
105
  end
107
- # rubocop:enable BlockLength
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Defines the relation between Hostgroup and AnsibleRole
4
- # rubocop:disable Metrics/LineLength
5
4
  class CreateJoinTableHostgroupAnsibleRoles < ActiveRecord::Migration[4.2]
6
5
  def change
7
6
  create_join_table :hostgroup, :ansible_roles, :table_name => 'hostgroup_ansible_roles' do |t|
8
7
  t.index [:hostgroup_id, :ansible_role_id], :name => 'index_ansible_roles_hostgroup_on_hostgroup_id_and_role_id'
9
8
  t.index [:ansible_role_id, :hostgroup_id], :name => 'index_ansible_roles_hostgroup_on_role_id_and_hostgroup_id'
10
- # rubocop:enable Metrics/LineLength
11
9
  end
12
10
  end
13
11
  end
@@ -0,0 +1,9 @@
1
+ class UpdateAnsibleInvTemplateName < ActiveRecord::Migration[5.2]
2
+ def up
3
+ Setting.where(:name => 'ansible_inventory_template').update_all(:default => 'Ansible - Ansible Inventory')
4
+ end
5
+
6
+ def down
7
+ Setting.where(:name => 'ansible_inventory_template').update_all(:default => 'Ansible Inventory')
8
+ end
9
+ end
@@ -18,7 +18,7 @@ User.as_anonymous_admin do
18
18
  sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
19
19
  template = JobTemplate.import_raw!(File.read(template),
20
20
  :default => true,
21
- :locked => true,
21
+ :lock => true,
22
22
  :update => sync)
23
23
  template.organizations = organizations if template.present?
24
24
  template.locations = locations if template.present?
@@ -70,36 +70,31 @@ module ForemanAnsible
70
70
  Apipie.configuration.checksum_path += ['/foreman_ansible/api/']
71
71
  end
72
72
 
73
- # rubocop:disable BlockLength
74
73
  config.to_prepare do
75
- begin
76
- foreman_version = ::Foreman::Version.new
77
- if Rails.env.test? ||
78
- foreman_version.major.to_i == 1 && foreman_version.minor.to_i < 13
79
- ::FactImporter.register_fact_importer(:ansible,
80
- ForemanAnsible::FactImporter)
81
- else
82
- ::FactImporter.register_fact_importer(
83
- :ansible,
84
- ForemanAnsible::StructuredFactImporter
85
- )
86
- end
87
- ::FactParser.register_fact_parser(:ansible, ForemanAnsible::FactParser)
88
- ::Host::Managed.prepend ForemanAnsible::HostManagedExtensions
89
- ::Hostgroup.include ForemanAnsible::HostgroupExtensions
90
- ::HostsHelper.include ForemanAnsible::HostsHelperExtensions
91
- ::HostsController.include ForemanAnsible::Concerns::HostsControllerExtensions
92
- ::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsControllerExtensions
93
- ::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsParamGroupExtensions
94
- ::HostgroupsController.include ForemanAnsible::Concerns::HostgroupsControllerExtensions
95
- ::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsControllerExtensions
96
- ::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsParamGroupExtensions
97
- ::ConfigReportImporter.include ForemanAnsible::AnsibleReportImporter
98
- rescue StandardError => e
99
- Rails.logger.warn "Foreman Ansible: skipping engine hook (#{e})"
74
+ foreman_version = ::Foreman::Version.new
75
+ if Rails.env.test? ||
76
+ foreman_version.major.to_i == 1 && foreman_version.minor.to_i < 13
77
+ ::Foreman::Plugin.fact_importer_registry.register(:ansible, ForemanAnsible::FactImporter)
78
+ else
79
+ ::Foreman::Plugin.fact_importer_registry.register(
80
+ :ansible,
81
+ ForemanAnsible::StructuredFactImporter
82
+ )
100
83
  end
84
+ ::FactParser.register_fact_parser(:ansible, ForemanAnsible::FactParser)
85
+ ::Host::Managed.prepend ForemanAnsible::HostManagedExtensions
86
+ ::Hostgroup.include ForemanAnsible::HostgroupExtensions
87
+ ::HostsHelper.include ForemanAnsible::HostsHelperExtensions
88
+ ::HostsController.include ForemanAnsible::Concerns::HostsControllerExtensions
89
+ ::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsControllerExtensions
90
+ ::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsParamGroupExtensions
91
+ ::HostgroupsController.include ForemanAnsible::Concerns::HostgroupsControllerExtensions
92
+ ::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsControllerExtensions
93
+ ::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsParamGroupExtensions
94
+ ::ConfigReportImporter.include ForemanAnsible::AnsibleReportImporter
95
+ rescue StandardError => e
96
+ Rails.logger.warn "Foreman Ansible: skipping engine hook (#{e})"
101
97
  end
102
- # rubocop:enable BlockLength
103
98
 
104
99
  rake_tasks do
105
100
  Rake::Task['db:seed'].enhance do