foreman_ansible 6.2.0 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/ansible_roles_controller.rb +12 -8
  3. data/app/controllers/ansible_variables_controller.rb +4 -0
  4. data/app/controllers/api/v2/ansible_roles_controller.rb +32 -11
  5. data/app/controllers/api/v2/ansible_variables_controller.rb +6 -4
  6. data/app/controllers/foreman_ansible/concerns/import_controller_helper.rb +3 -3
  7. data/app/helpers/foreman_ansible/ansible_reports_helper.rb +8 -0
  8. data/app/helpers/foreman_ansible/ansible_roles_data_preparations.rb +95 -0
  9. data/app/helpers/foreman_ansible/ansible_roles_helper.rb +20 -1
  10. data/app/jobs/sync_roles_and_variables.rb +20 -0
  11. data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +7 -4
  12. data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +7 -4
  13. data/app/models/foreman_ansible/ansible_provider.rb +2 -1
  14. data/app/models/host_ansible_role.rb +1 -0
  15. data/app/models/hostgroup_ansible_role.rb +1 -0
  16. data/app/models/setting/ansible.rb +9 -0
  17. data/app/services/foreman_ansible/ansible_report_importer.rb +4 -0
  18. data/app/services/foreman_ansible/ansible_report_scanner.rb +15 -1
  19. data/app/services/foreman_ansible/api_roles_importer.rb +23 -11
  20. data/app/services/foreman_ansible/fact_parser.rb +21 -1
  21. data/app/services/foreman_ansible/import_roles_and_variables_error_notification.rb +31 -0
  22. data/app/services/foreman_ansible/import_roles_and_variables_success_notification.rb +26 -0
  23. data/app/services/foreman_ansible/inventory_creator.rb +3 -7
  24. data/app/services/foreman_ansible/roles_importer.rb +3 -2
  25. data/app/services/foreman_ansible/ui_roles_importer.rb +2 -2
  26. data/app/services/foreman_ansible/variables_importer.rb +32 -2
  27. data/app/views/ansible_roles/import.html.erb +10 -50
  28. data/app/views/ansible_variables/index.html.erb +1 -2
  29. data/app/views/api/v2/ansible_roles/sync.json.rabl +5 -0
  30. data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +1 -2
  31. data/app/views/foreman_ansible/config_reports/_ansible.html.erb +13 -6
  32. data/app/views/foreman_ansible/job_templates/ansible_collections_-_install_from_galaxy.erb +28 -0
  33. data/app/views/foreman_ansible/job_templates/convert_to_rhel.erb +44 -0
  34. data/config/routes.rb +5 -4
  35. data/db/migrate/20210120150019_add_position_to_ansible_role.rb +27 -0
  36. data/db/seeds.d/100_common_parameters.rb +7 -0
  37. data/db/seeds.d/90_notification_blueprints.rb +19 -1
  38. data/lib/foreman_ansible/engine.rb +1 -0
  39. data/lib/foreman_ansible/register.rb +5 -5
  40. data/lib/foreman_ansible/version.rb +1 -1
  41. data/locale/ca/LC_MESSAGES/foreman_ansible.mo +0 -0
  42. data/locale/ca/foreman_ansible.po +1 -1
  43. data/locale/cs_CZ/LC_MESSAGES/foreman_ansible.mo +0 -0
  44. data/locale/cs_CZ/foreman_ansible.po +1 -1
  45. data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
  46. data/locale/de/foreman_ansible.po +1 -1
  47. data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
  48. data/locale/en/foreman_ansible.po +1 -1
  49. data/locale/en_GB/LC_MESSAGES/foreman_ansible.mo +0 -0
  50. data/locale/en_GB/foreman_ansible.po +1 -1
  51. data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
  52. data/locale/es/foreman_ansible.po +1 -1
  53. data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
  54. data/locale/fr/foreman_ansible.po +1 -1
  55. data/locale/gl/LC_MESSAGES/foreman_ansible.mo +0 -0
  56. data/locale/gl/foreman_ansible.po +1 -1
  57. data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
  58. data/locale/it/foreman_ansible.po +1 -1
  59. data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
  60. data/locale/ja/foreman_ansible.po +1 -1
  61. data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
  62. data/locale/ko/foreman_ansible.po +1 -1
  63. data/locale/nl_NL/LC_MESSAGES/foreman_ansible.mo +0 -0
  64. data/locale/nl_NL/foreman_ansible.po +1 -1
  65. data/locale/pl/LC_MESSAGES/foreman_ansible.mo +0 -0
  66. data/locale/pl/foreman_ansible.po +1 -1
  67. data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
  68. data/locale/pt_BR/foreman_ansible.po +1 -1
  69. data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
  70. data/locale/ru/foreman_ansible.po +1 -1
  71. data/locale/sv_SE/LC_MESSAGES/foreman_ansible.mo +0 -0
  72. data/locale/sv_SE/foreman_ansible.po +1 -1
  73. data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
  74. data/locale/zh_CN/foreman_ansible.po +1 -1
  75. data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
  76. data/locale/zh_TW/foreman_ansible.po +1 -1
  77. data/test/factories/ansible_roles.rb +12 -0
  78. data/test/factories/host_ansible_enhancements.rb +23 -0
  79. data/test/foreman_ansible/helpers/ansible_roles_helper_test.rb +45 -0
  80. data/test/functional/ansible_variables_controller_test.rb +0 -15
  81. data/test/functional/api/v2/ansible_roles_controller_test.rb +23 -0
  82. data/test/functional/api/v2/hostgroups_controller_test.rb +5 -4
  83. data/test/functional/api/v2/hosts_controller_test.rb +9 -8
  84. data/test/functional/hosts_controller_test.rb +10 -6
  85. data/test/unit/concerns/host_managed_extensions_test.rb +17 -3
  86. data/test/unit/concerns/hostgroup_extensions_test.rb +13 -7
  87. data/test/unit/host_ansible_role_test.rb +2 -1
  88. data/test/unit/hostgroup_ansible_role_test.rb +2 -1
  89. data/test/unit/ignore_roles_test.rb +43 -0
  90. data/test/unit/import_roles_and_variables.rb +60 -0
  91. data/test/unit/services/api_roles_importer_test.rb +22 -5
  92. data/test/unit/services/fact_parser_test.rb +16 -0
  93. data/test/unit/services/inventory_creator_test.rb +15 -7
  94. data/test/unit/services/ui_roles_importer_test.rb +2 -2
  95. data/webpack/__mocks__/foremanReact/common/helpers.js +13 -0
  96. data/webpack/__mocks__/foremanReact/components/common/forms/OrderableSelect/helpers.js +5 -0
  97. data/webpack/__mocks__/foremanReact/redux/API.js +7 -0
  98. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.js +178 -0
  99. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.scss +9 -0
  100. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js +39 -0
  101. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesConstants.js +4 -0
  102. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesHelpers.js +11 -0
  103. data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesHelpers.test.js +50 -0
  104. data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesImport.test.js +39 -0
  105. data/webpack/components/AnsibleRolesAndVariables/__test__/__snapshots__/AnsibleRolesAndVariablesImport.test.js.snap +177 -0
  106. data/webpack/components/AnsibleRolesAndVariables/index.js +31 -0
  107. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js +14 -18
  108. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss +1 -1
  109. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js +6 -0
  110. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherConstants.js +1 -2
  111. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js +13 -8
  112. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherSelectors.js +8 -28
  113. data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js +1 -0
  114. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcher.test.js +2 -0
  115. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js +0 -8
  116. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js +2 -15
  117. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcher.test.js.snap +4 -9
  118. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherReducer.test.js.snap +8 -97
  119. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherSelectors.test.js.snap +5 -30
  120. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +5 -2
  121. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.js +43 -0
  122. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.test.js +19 -0
  123. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js +63 -51
  124. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js +3 -0
  125. data/webpack/components/AnsibleRolesSwitcher/components/OrderedRolesTooltip.js +23 -0
  126. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRoleInputs.test.js.snap +51 -0
  127. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap +28 -28
  128. data/webpack/components/AnsibleRolesSwitcher/index.js +3 -7
  129. data/webpack/index.js +6 -0
  130. metadata +55 -9
  131. data/app/views/ansible_variables/import.html.erb +0 -56
@@ -3,6 +3,7 @@
3
3
  class Setting
4
4
  # Provide settings related with Ansible
5
5
  class Ansible < ::Setting
6
+ ::Setting::BLANK_ATTRS.concat %w[ansible_roles_to_ignore]
6
7
  class << self
7
8
  # It would be more disadvantages than advantages to split up
8
9
  # default_settings into multiple methods, this way it's already very
@@ -80,6 +81,14 @@ class Setting
80
81
  'with Ansible inventory'),
81
82
  'Ansible - Ansible Inventory',
82
83
  N_('Default Ansible inventory report template')
84
+ ),
85
+ set(
86
+ 'ansible_roles_to_ignore',
87
+ N_('Those roles will be excluded when importing roles from smart proxy, '\
88
+ 'The expected input is comma separated values and you can use * wildcard metacharacters'\
89
+ 'For example: foo*, *b*,*bar'),
90
+ [],
91
+ N_('Ansible roles to ignore')
83
92
  )
84
93
  ]
85
94
  end
@@ -18,6 +18,10 @@ module ForemanAnsible
18
18
  partial_hostname_match(hostname)
19
19
  end
20
20
 
21
+ def self.authorized_smart_proxy_features
22
+ super + ['Ansible']
23
+ end
24
+
21
25
  def partial_hostname_match(hostname)
22
26
  return @host unless @host.new_record?
23
27
  hosts = Host.where(Host.arel_table[:name].matches("#{hostname}.%"))
@@ -5,7 +5,21 @@ module ForemanAnsible
5
5
  # sets the origin of the report to 'Ansible'
6
6
  class AnsibleReportScanner
7
7
  class << self
8
- def add_reporter_data(report, raw); end
8
+ def add_reporter_data(_report, raw)
9
+ check_mode_message = raw['check_mode'] ? 'check_mode_enabled' : 'check_mode_disabled'
10
+ check_mode_log = {
11
+ 'log': {
12
+ 'sources': {
13
+ 'source': 'check_mode'
14
+ },
15
+ 'messages': {
16
+ 'message': check_mode_message
17
+ },
18
+ 'level': 'info'
19
+ }
20
+ }
21
+ raw['logs'].insert(0, check_mode_log.deep_stringify_keys)
22
+ end
9
23
 
10
24
  def identify_origin(raw)
11
25
  'Ansible' if ansible_report?(raw)
@@ -3,15 +3,31 @@
3
3
  module ForemanAnsible
4
4
  # imports Ansible roles through API
5
5
  class ApiRolesImporter < RolesImporter
6
- def import!(role_names = nil)
7
- new_roles = import_role_names[:new]
8
- if role_names.present?
9
- new_roles.select! do |role|
10
- role_names.include?(role.name)
6
+ include ::ForemanAnsible::AnsibleRolesDataPreparations
7
+
8
+ def import!(role_names)
9
+ @roles_importer = ForemanAnsible::UiRolesImporter.new(@ansible_proxy)
10
+ @variables_importer = ForemanAnsible::VariablesImporter.new(@ansible_proxy)
11
+ params = { 'changed' => {} }
12
+ roles = prepare_ansible_import_rows(@roles_importer.import!, @variables_importer, false)
13
+ roles.each do |role|
14
+ if role_names.include? role[:name]
15
+ params['changed'][role[:kind]] ||= {}
16
+ params['changed'][role[:kind]][role[:name]] = { 'id' => role[:id], 'name' => role[:name] }
11
17
  end
12
18
  end
13
- new_roles.map(&:save)
14
- new_roles
19
+ params
20
+ end
21
+
22
+ def confirm_import(params)
23
+ @roles_importer.finish_import(params['changed'])
24
+ @variables_importer.import_variables_roles(params['changed']) if params['changed']['new'] || params['changed']['old']
25
+ end
26
+
27
+ def confirm_sync(params)
28
+ job = SyncRolesAndVariables.perform_later(params['changed'], @ansible_proxy)
29
+ task = ForemanTasks::Task.find_by(external_id: job.provider_job_id)
30
+ task
15
31
  end
16
32
 
17
33
  def obsolete!
@@ -19,9 +35,5 @@ module ForemanAnsible
19
35
  obsolete_roles.map(&:destroy)
20
36
  obsolete_roles
21
37
  end
22
-
23
- def fetch!
24
- fetch_role_names
25
- end
26
38
  end
27
39
  end
@@ -72,6 +72,22 @@ module ForemanAnsible
72
72
  Time.zone.now.to_i - facts['ansible_uptime_seconds'].to_i
73
73
  end
74
74
 
75
+ def virtual
76
+ facts['ansible_virtualization_role'] == 'guest'
77
+ end
78
+
79
+ def ram
80
+ facts['ansible_memtotal_mb'].to_i
81
+ end
82
+
83
+ def sockets
84
+ facts['ansible_processor_count'].to_i
85
+ end
86
+
87
+ def cores
88
+ facts['ansible_processor_cores'].to_i
89
+ end
90
+
75
91
  private
76
92
 
77
93
  def ansible_interfaces
@@ -85,7 +101,11 @@ module ForemanAnsible
85
101
 
86
102
  def ip_from_interface(interface)
87
103
  return if facts[:"ansible_#{interface}"]['ipv4'].blank?
88
- facts[:"ansible_#{interface}"]['ipv4']['address']
104
+ if facts[:"ansible_#{interface}"]['ipv4'].is_a?(Array)
105
+ facts[:"ansible_#{interface}"]['ipv4'][0]['address']
106
+ else
107
+ facts[:"ansible_#{interface}"]['ipv4']['address']
108
+ end
89
109
  end
90
110
 
91
111
  def ipv6_from_interface(interface)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAnsible
4
+ class ImportRolesAndVariablesErrorNotification < ::UINotifications::Base
5
+ private
6
+
7
+ def initialize(error, task)
8
+ @job_error = error
9
+ @subject = task
10
+ end
11
+
12
+ def create
13
+ ::Notification.create!(
14
+ :audience => Notification::AUDIENCE_USER,
15
+ :notification_blueprint => blueprint,
16
+ :initiator => initiator,
17
+ :message => message,
18
+ :subject => subject
19
+ )
20
+ end
21
+
22
+ def blueprint
23
+ name = 'Sync_roles_and_variables_failed'
24
+ @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => name)
25
+ end
26
+
27
+ def message
28
+ _("Failed to import roles and variables Due to: #{@job_error}")
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAnsible
4
+ class ImportRolesAndVariablesSuccessNotification < ::UINotifications::Base
5
+ private
6
+
7
+ def create
8
+ ::Notification.create!(
9
+ :audience => Notification::AUDIENCE_USER,
10
+ :notification_blueprint => blueprint,
11
+ :initiator => initiator,
12
+ :message => message,
13
+ :subject => subject
14
+ )
15
+ end
16
+
17
+ def blueprint
18
+ name = 'Sync_roles_and_variables_successfully'
19
+ @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => name)
20
+ end
21
+
22
+ def message
23
+ blueprint.message
24
+ end
25
+ end
26
+ end
@@ -99,7 +99,7 @@ module ForemanAnsible
99
99
  params = {
100
100
  'ansible_user' => host_setting(host, 'remote_execution_ssh_user'),
101
101
  'ansible_become_method' => host_setting(host, 'remote_execution_effective_user_method'),
102
- 'ansible_ssh_private_key_file' => ansible_or_rex_ssh_private_key(host),
102
+ 'ansible_ssh_private_key_file' => ansible_ssh_private_key(host),
103
103
  'ansible_port' => host_setting(host, 'remote_execution_ssh_port'),
104
104
  'ansible_host' => AnsibleProvider.find_ip_or_hostname(host)
105
105
  }
@@ -122,13 +122,9 @@ module ForemanAnsible
122
122
  result
123
123
  end
124
124
 
125
- def ansible_or_rex_ssh_private_key(host)
125
+ def ansible_ssh_private_key(host)
126
126
  ansible_private_file = host_setting(host, 'ansible_ssh_private_key_file')
127
- if !ansible_private_file.empty?
128
- ansible_private_file
129
- else
130
- ForemanRemoteExecutionCore.settings[:ssh_identity_key_file]
131
- end
127
+ ansible_private_file unless ansible_private_file.empty?
132
128
  end
133
129
 
134
130
  private
@@ -7,6 +7,7 @@ module ForemanAnsible
7
7
 
8
8
  def initialize(proxy = nil)
9
9
  @ansible_proxy = proxy
10
+ @variables_importer = ForemanAnsible::VariablesImporter.new(@ansible_proxy)
10
11
  end
11
12
 
12
13
  def import_role_names
@@ -26,8 +27,8 @@ module ForemanAnsible
26
27
 
27
28
  def detect_changes(imported)
28
29
  changes = {}.with_indifferent_access
29
- old, changes[:new] = imported.partition { |role| role.id.present? }
30
- changes[:obsolete] = ::AnsibleRole.where.not(:id => old.map(&:id))
30
+ changes[:old], changes[:new] = imported.partition { |role| role.id.present? }
31
+ changes[:obsolete] = ::AnsibleRole.where.not(:id => changes[:old].map(&:id))
31
32
  changes
32
33
  end
33
34
 
@@ -15,13 +15,13 @@ module ForemanAnsible
15
15
 
16
16
  def create_new_roles(changes)
17
17
  changes.each_pair do |_, new_role|
18
- ::AnsibleRole.create(JSON.parse(new_role))
18
+ ::AnsibleRole.create(new_role)
19
19
  end
20
20
  end
21
21
 
22
22
  def delete_old_roles(changes)
23
23
  changes.each_pair do |_, old_role|
24
- ::AnsibleRole.find(JSON.parse(old_role)['id']).destroy
24
+ ::AnsibleRole.find(old_role['id']).destroy
25
25
  end
26
26
  end
27
27
  end
@@ -26,6 +26,10 @@ module ForemanAnsible
26
26
  import_variables(local_variables, new_roles)
27
27
  end
28
28
 
29
+ def get_variables_names(role_name)
30
+ remote_variables[role_name]
31
+ end
32
+
29
33
  def import_variables(role_variables, new_roles)
30
34
  detect_changes(
31
35
  role_variables.map do |role_name, variables|
@@ -37,6 +41,34 @@ module ForemanAnsible
37
41
  )
38
42
  end
39
43
 
44
+ def import_variables_roles(roles)
45
+ if roles['new']
46
+ imported_roles = roles['new'].keys
47
+ variables_to_import = {}
48
+ remote_variables.each do |role, variables|
49
+ next unless imported_roles.include? role
50
+ role_obj = AnsibleRole.find_by(:name => role)
51
+ variables_to_import[role] = {}
52
+ values = initialize_variables(variables, role_obj)
53
+ values.each do |value|
54
+ variables_to_import[role][value.key] = value.attributes.to_json
55
+ end
56
+ end
57
+ create_new_variables(variables_to_import)
58
+ end
59
+ return if roles['old'].empty?
60
+ variables_to_update = { 'new' => {}, 'obsolete' => {}, 'update' => {} }
61
+ import_variable_names([]).each do |kind, variables|
62
+ variables.each do |variable|
63
+ next unless roles['old'].values.map { |role| role['id'] }.include?(variable.ansible_role_id)
64
+ role_name = variable.ansible_role.name
65
+ variables_to_update[kind][role_name] ||= {}
66
+ variables_to_update[kind][role_name][variable.key] = variable.attributes.to_json
67
+ end
68
+ end
69
+ finish_import(variables_to_update['new'], variables_to_update['obsolete'], variables_to_update['update'])
70
+ end
71
+
40
72
  def import_new_role(role_name, new_roles)
41
73
  role = AnsibleRole.find_by(:name => role_name)
42
74
  if role.blank? && new_roles.map(&:name).include?(role_name)
@@ -92,8 +124,6 @@ module ForemanAnsible
92
124
  def update_variables(variables)
93
125
  iterate_over_variables(variables) do |_role, memo, attrs|
94
126
  attributes = JSON.parse(attrs)
95
- # Make sure to let the flag if a variable is hidden untouched
96
- attributes.delete('hidden_value')
97
127
  var = AnsibleVariable.find attributes['id']
98
128
  var.update(attributes)
99
129
  memo << var
@@ -1,51 +1,11 @@
1
1
  <% title _("Changed Ansible roles") %>
2
- <%= form_tag confirm_import_ansible_roles_path do %>
3
- <h4><%= _("Select the changes you want to realize in Foreman") %></h4>
4
- <h6>
5
- <%= _("Toggle") %>:
6
- <%= link_to_function(icon_text("check", _("New")),
7
- "toggleCheckboxesBySelector('.role_select_boxes_new')",
8
- :title => _("Check/Uncheck new")) %> |
9
- <%= link_to_function(icon_text("check", _("Obsolete")),
10
- "toggleCheckboxesBySelector('.role_select_boxes_obsolete')",
11
- :title => _("Check/Uncheck obsolete")) %>
12
- </h6>
13
- <table class="<%= table_css_classes %>">
14
- <thead>
15
- <tr>
16
- <th class="ca">
17
- <%= link_to_function(icon_text("check"),
18
- "toggleCheckboxesBySelector('.role_select_boxes')",
19
- :title => _("Check/Uncheck all")) %>
20
- </th>
21
- <th><%= _("Name") %></th>
22
- <th class="col-md-2"><%= _("Hosts count") %></th>
23
- <th class="col-md-2"><%= _("Hostgroups count") %></th>
24
- <th><%= _("Operation") %></th>
25
- </tr>
26
- </thead>
27
- <tbody>
28
- <% changed.each do |kind, roles| %>
29
- <% roles.each do |role| %>
30
- <tr>
31
- <td>
32
- <%= check_box_tag "changed[#{kind}][#{role}]", role.to_json, false, :class => "role_select_boxes role_select_boxes_#{kind} role_select_boxes_role_#{role}" %>
33
- </td>
34
- <td>
35
- <%= link_to_function("#{role}", "toggleCheckboxesBySelector('.role_select_boxes_role_#{role}')", :title => _("Check/Uncheck all %s changes") % role) %>
36
- </td>
37
- <td><%= role.hosts.count %></td>
38
- <td><%= role.hostgroups.count %></td>
39
- <td>
40
- <%= { "new" => _("Add"), "obsolete" => _("Remove") }[kind] %>
41
- </td>
42
- </tr>
43
- <% end %>
44
- <% end %>
45
- </tbody>
46
- </table>
47
- <div>
48
- <%= link_to _("Cancel"), ansible_roles_path, :class => "btn btn-default" %>
49
- <%= submit_tag _("Update"), :class => "btn btn-primary" %>
50
- </div>
51
- <% end %>
2
+ <%= webpacked_plugins_js_for :foreman_ansible %>
3
+ <%= webpacked_plugins_css_for :foreman_ansible %>
4
+
5
+
6
+ <%= react_component(
7
+ 'WrappedImportRolesAndVariables',
8
+ :rowsData => @rows,
9
+ :proxy => @proxy.id
10
+ ) %>
11
+
@@ -1,8 +1,7 @@
1
1
  <% title _("Ansible Variables") %>
2
2
  <%= stylesheet 'foreman_ansible/foreman-ansible' %>
3
3
 
4
- <%= title_actions ansible_proxy_import(hash_for_import_ansible_variables_path),
5
- display_link_if_authorized(_('New Ansible Variable'), hash_for_new_ansible_variable_path, :class => "btn btn-default no-float"),
4
+ <%= title_actions display_link_if_authorized(_('New Ansible Variable'), hash_for_new_ansible_variable_path, :class => "btn btn-default no-float"),
6
5
  documentation_button('#4.3Variables', :root_url => ansible_doc_url)
7
6
  %>
8
7
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @task
4
+
5
+ attributes :id, :action, :state, :result, :start_at
@@ -2,10 +2,9 @@
2
2
  <%= webpacked_plugins_css_for :foreman_ansible %>
3
3
 
4
4
  <div class='tab-pane' id='ansible_roles'>
5
- <% roles = f.object.is_a?(Hostgroup) ? roles_attrs(f.object.inherited_and_own_ansible_roles) : roles_attrs(f.object.all_ansible_roles) %>
6
5
  <% class_name = f.object.is_a?(Hostgroup) ? 'Hostgroup' : 'Host' %>
7
6
  <%= react_component('AnsibleRolesSwitcher', {
8
- :initialAssignedRoles => roles,
7
+ :initialAssignedRoles => role_attributes_for_roles_switcher(f.object),
9
8
  :inheritedRoleIds => f.object.inherited_ansible_roles.map(&:id),
10
9
  :availableRolesUrl => ui_ansible_roles_path,
11
10
  :resourceId => f.object.id,
@@ -1,6 +1,11 @@
1
1
  <%= webpacked_plugins_js_for :foreman_ansible %>
2
2
  <%= stylesheet 'foreman_ansible/foreman-ansible' %>
3
+ <% if ansible_run_in_check_mode?(logs.first) %>
4
+ <%= alert :class => 'alert-info',
5
+ :header => _('Ansible check mode'),
6
+ :text => _('Notice that ansible roles run in check mode.')%>
3
7
 
8
+ <% end %>
4
9
  <table id='report_log' class="<%= table_css_classes %>">
5
10
  <thead>
6
11
  <tr>
@@ -12,12 +17,14 @@
12
17
  </thead>
13
18
  <tbody>
14
19
  <% logs.each do |log| %>
15
- <tr>
16
- <td><span <%= report_tag log.level %>><%= h log.level %></span></td>
17
- <td><%= ansible_module_name(log) %></td>
18
- <td><%= ansible_module_args(log) %></td>
19
- <td><%= ansible_module_message(log) %></td>
20
- </tr>
20
+ <% unless check_mode_log?(log) %>
21
+ <tr>
22
+ <td><span <%= report_tag log.level %>><%= h log.level %></span></td>
23
+ <td><%= ansible_module_name(log) %></td>
24
+ <td><%= ansible_module_args(log) %></td>
25
+ <td><%= ansible_module_message(log) %></td>
26
+ </tr>
27
+ <% end %>
21
28
  <% end %>
22
29
  <tr id='ntsh' <%= "style='display: none;'".html_safe if logs.size > 0%>><td colspan="3">
23
30
  <%= _("Nothing to show") %>