foreman_ansible 7.1.2 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_ansible/api/v2/hostgroups_controller_extensions.rb +5 -1
  3. data/app/controllers/foreman_ansible/api/v2/hosts_controller_extensions.rb +3 -1
  4. data/app/helpers/foreman_ansible/ansible_hostgroups_helper.rb +15 -0
  5. data/app/helpers/foreman_ansible/ansible_reports_helper.rb +0 -4
  6. data/app/helpers/foreman_ansible/hosts_helper.rb +19 -0
  7. data/app/services/foreman_ansible/variables_importer.rb +9 -9
  8. data/app/views/api/v2/hostgroups/ansible_roles.json.rabl +9 -1
  9. data/app/views/api/v2/hosts/ansible_roles.json.rabl +9 -1
  10. data/config/routes.rb +3 -3
  11. data/db/migrate/20200421201839_update_ansible_inv_template_name.rb +1 -5
  12. data/lib/foreman_ansible/engine.rb +0 -1
  13. data/lib/foreman_ansible/register.rb +10 -2
  14. data/lib/foreman_ansible/remote_execution.rb +0 -6
  15. data/lib/foreman_ansible/version.rb +1 -1
  16. data/locale/action_names.rb +4 -3
  17. data/locale/ca/foreman_ansible.po +360 -45
  18. data/locale/cs_CZ/foreman_ansible.po +372 -57
  19. data/locale/de/foreman_ansible.po +355 -40
  20. data/locale/en/foreman_ansible.po +355 -40
  21. data/locale/en_GB/foreman_ansible.po +357 -42
  22. data/locale/es/foreman_ansible.po +355 -40
  23. data/locale/foreman_ansible.pot +767 -263
  24. data/locale/fr/foreman_ansible.po +355 -40
  25. data/locale/gl/foreman_ansible.po +358 -43
  26. data/locale/it/foreman_ansible.po +355 -40
  27. data/locale/ja/foreman_ansible.po +355 -40
  28. data/locale/ko/foreman_ansible.po +355 -40
  29. data/locale/nl_NL/foreman_ansible.po +359 -44
  30. data/locale/pl/foreman_ansible.po +363 -48
  31. data/locale/pt_BR/foreman_ansible.po +355 -40
  32. data/locale/ru/foreman_ansible.po +355 -40
  33. data/locale/sv_SE/foreman_ansible.po +363 -48
  34. data/locale/zh_CN/foreman_ansible.po +355 -40
  35. data/locale/zh_TW/foreman_ansible.po +355 -40
  36. data/webpack/components/AnsibleHostDetail/components/RolesTab/AllRolesModal/AllRolesTable.js +11 -1
  37. data/webpack/components/AnsibleHostDetail/components/RolesTab/RolesTable.js +10 -1
  38. data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/RolesTab.fixtures.js +30 -0
  39. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +3 -12
  40. data/webpack/components/AnsibleRolesSwitcher/components/OrderedRolesTooltip.js +11 -12
  41. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRole.test.js.snap +6 -20
  42. data/webpack/graphql/queries/allAnsibleRoles.gql +3 -0
  43. data/webpack/graphql/queries/hostAnsibleRoles.gql +3 -0
  44. metadata +4 -6
  45. data/app/helpers/foreman_ansible/hosts_helper_extensions.rb +0 -30
  46. data/app/overrides/hostgroup_play_roles.rb +0 -9
  47. data/app/views/foreman_ansible/ansible_roles/_hostgroup_ansible_roles_button.erb +0 -19
  48. data/app/views/foreman_ansible/job_templates/configure_cloud_connector_-_ansible_default.erb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ded4963f8ef2ac710b82d4ae1a6a20dceed5fbb577059981fab73fd07b61ad6a
4
- data.tar.gz: fd300c47edc4ce921b1a8500c183b3757fd3cf4acf8fb7d9377eafda98bd17b4
3
+ metadata.gz: df3c4d8c1514c442f1da8c0c6ef356482f5edb63ca14df0e39ef83818076f22b
4
+ data.tar.gz: 253b5ef0614bb34d78ad96b7312537b496b4850ea34d6ba7a960f9df34da5e02
5
5
  SHA512:
6
- metadata.gz: b0717c5963bcabf982fdc647570e1a603dfb7794af517293bdd3f41d72e7158ad1ab8ad05930aa749f3ea8f79ab7f9ab20d3bd4de5568d12e79d25f8fdd83b0e
7
- data.tar.gz: 9edde27d8e6503d55def1157329c5dd63195c0ca6d339694b5144c3578e435dbe0cb946f08efa13bd95e6ae24006b45abec0cd5099c56bf751d5c067b8cb9085
6
+ metadata.gz: b6f8201c41db492b56888c675cb460f88e5dae92aeb808487747783ba43031961a27f66eb2df975216385b8e003d2df645f4208f0a1f0d4bec44b0c02f878984
7
+ data.tar.gz: da19e080f0fa135ae2cb4757fae4a10a946989ecc953cf41eb774877b075bcfc68455707d4abc3a4265fdcb1421714572947bb14eefc709a8d825d6c23623987
@@ -46,7 +46,11 @@ module ForemanAnsible
46
46
  find_resource
47
47
  return unless @hostgroup
48
48
 
49
- @ansible_roles = @hostgroup.all_ansible_roles
49
+ @inherited_ansible_roles = @hostgroup.inherited_ansible_roles
50
+ @directly_assigned_roles = @hostgroup.ansible_roles
51
+ @ansible_roles = (
52
+ @directly_assigned_roles + @inherited_ansible_roles + @hostgroup.host_ansible_roles
53
+ ).uniq
50
54
  end
51
55
 
52
56
  api :POST, '/hostgroups/:id/assign_ansible_roles',
@@ -49,7 +49,9 @@ module ForemanAnsible
49
49
  def ansible_roles
50
50
  return unless @host
51
51
 
52
- @ansible_roles = @host.all_ansible_roles
52
+ @inherited_ansible_roles = @host.inherited_ansible_roles
53
+ @directly_assigned_roles = @host.ansible_roles
54
+ @ansible_roles = (@directly_assigned_roles + @inherited_ansible_roles).uniq
53
55
  end
54
56
 
55
57
  api :POST, '/hosts/:id/assign_ansible_roles',
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAnsible
4
+ module AnsibleHostgroupsHelper
5
+ def ansible_hostgroups_actions(hostgroup)
6
+ play_roles = if hostgroup.all_ansible_roles.empty?
7
+ { action: (link_to _('Run all Ansible roles'), 'javascript:void(0);', disabled: true, title: 'No Roles assigned'), priority: 31 }
8
+ else
9
+ { action: display_link_if_authorized(_('Run all Ansible roles'), hash_for_play_roles_hostgroup_path(id: hostgroup), 'data-no-turbolink': true, title: _('Run all Ansible roles on hosts belonging to this host group')), priority: 31 }
10
+ end
11
+
12
+ [play_roles] if User.current.can?(:create_job_invocations)
13
+ end
14
+ end
15
+ end
@@ -57,10 +57,6 @@ module ForemanAnsible
57
57
  _('No additional data')
58
58
  end
59
59
 
60
- def ansible_report_origin_icon
61
- 'foreman_ansible/Ansible.png'
62
- end
63
-
64
60
  def ansible_report_origin_partial
65
61
  'foreman_ansible/config_reports/ansible'
66
62
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAnsible
4
+ module HostsHelper
5
+ def ansible_hosts_multiple_actions
6
+ return [] unless User.current.can?(:create_job_invocations) &&
7
+ User.current.can?(:play_roles_on_host)
8
+
9
+ [{ action: [_('Run all Ansible roles'),
10
+ multiple_play_roles_hosts_path,
11
+ false], priority: 1000 }]
12
+ end
13
+
14
+ def ansible_roles_present?(host)
15
+ host.ansible_roles.present? ||
16
+ host.inherited_ansible_roles.present?
17
+ end
18
+ end
19
+ end
@@ -31,14 +31,12 @@ module ForemanAnsible
31
31
  end
32
32
 
33
33
  def import_variables(role_variables, new_roles)
34
- detect_changes(
35
- role_variables.map do |role_name, variables|
36
- next if variables.blank?
37
- role = import_new_role(role_name, new_roles)
38
- next if role.blank?
39
- initialize_variables(variables, role)
40
- end.select(&:present?).flatten.compact
41
- )
34
+ detect_changes(role_variables.map do |role_name, variables|
35
+ next if variables.blank?
36
+ role = import_new_role(role_name, new_roles)
37
+ next if role.blank?
38
+ initialize_variables(variables, role)
39
+ end.select(&:present?).flatten.compact)
42
40
  end
43
41
 
44
42
  def import_variables_roles(roles)
@@ -96,7 +94,9 @@ module ForemanAnsible
96
94
  persisted, changes[:new] = imported.partition { |var| var.id.present? }
97
95
  changed, _old = persisted.partition(&:changed?)
98
96
  _overriden, changes[:update] = changed.partition(&:override?)
99
- changes[:obsolete] = AnsibleVariable.where.not(:id => persisted.pluck(:id), :imported => false)
97
+ changes[:obsolete] = AnsibleVariable.where.not(id: persisted.pluck(:id)).
98
+ where.not(imported: false)
99
+
100
100
  changes
101
101
  end
102
102
 
@@ -2,4 +2,12 @@
2
2
 
3
3
  collection @ansible_roles
4
4
 
5
- attributes :id, :name, :created_at, :updated_at
5
+ extends 'api/v2/ansible_roles/show'
6
+
7
+ node :inherited do |role|
8
+ @inherited_ansible_roles.include?(role)
9
+ end
10
+
11
+ node :directly_assigned do |role|
12
+ @directly_assigned_roles.include?(role)
13
+ end
@@ -2,4 +2,12 @@
2
2
 
3
3
  collection @ansible_roles
4
4
 
5
- attributes :id, :name, :created_at, :updated_at
5
+ extends 'api/v2/ansible_roles/show'
6
+
7
+ node :inherited do |role|
8
+ @inherited_ansible_roles.include?(role)
9
+ end
10
+
11
+ node :directly_assigned do |role|
12
+ @directly_assigned_roles.include?(role)
13
+ end
data/config/routes.rb CHANGED
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Rails.application.routes.draw do
4
- match '/ansible/hostgroups' => 'react#index', :via => [:get]
5
- match '/ansible/hostgroups/*page' => 'react#index', :via => [:get]
6
-
7
4
  namespace :api, defaults: { format: 'json' } do
8
5
  scope '(:apiv)',
9
6
  :module => :v2,
@@ -113,4 +110,7 @@ Rails.application.routes.draw do
113
110
  end
114
111
  end
115
112
  end
113
+
114
+ match '/ansible/hostgroups' => 'react#index', :via => [:get]
115
+ match '/ansible/hostgroups/*page' => 'react#index', :via => [:get]
116
116
  end
@@ -1,9 +1,5 @@
1
1
  class UpdateAnsibleInvTemplateName < ActiveRecord::Migration[5.2]
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')
3
+ # Setting defaults are updated automatically now
8
4
  end
9
5
  end
@@ -67,7 +67,6 @@ module ForemanAnsible
67
67
  config.to_prepare do
68
68
  ::Host::Managed.prepend ForemanAnsible::HostManagedExtensions
69
69
  ::Hostgroup.include ForemanAnsible::HostgroupExtensions
70
- ::HostsHelper.include ForemanAnsible::HostsHelperExtensions
71
70
  ::HostsController.include ForemanAnsible::Concerns::HostsControllerExtensions
72
71
  ::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsControllerExtensions
73
72
  ::Api::V2::HostsController.include ForemanAnsible::Api::V2::HostsParamGroupExtensions
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Foreman::Plugin.register :foreman_ansible do
4
- requires_foreman '>= 3.3'
4
+ requires_foreman '>= 3.4'
5
5
 
6
6
  settings do
7
7
  category :ansible, N_('Ansible') do
@@ -187,7 +187,7 @@ Foreman::Plugin.register :foreman_ansible do
187
187
 
188
188
  register_global_js_file 'global'
189
189
 
190
- extend_graphql_type :type => ::Types::Host do
190
+ extend_graphql_type :type => '::Types::Host' do
191
191
  field :all_ansible_roles, ::Types::InheritedAnsibleRole.connection_type, :null => true, :method => :present_all_ansible_roles
192
192
  field :own_ansible_roles, ::Types::AnsibleRole.connection_type, :null => true
193
193
  field :available_ansible_roles, ::Types::AnsibleRole.connection_type, :null => true
@@ -236,4 +236,12 @@ Foreman::Plugin.register :foreman_ansible do
236
236
  register_report_scanner ForemanAnsible::AnsibleReportScanner
237
237
  register_report_origin 'Ansible', 'ConfigReport'
238
238
  end
239
+
240
+ describe_host do
241
+ multiple_actions_provider :ansible_hosts_multiple_actions
242
+ end
243
+
244
+ describe_hostgroup do
245
+ hostgroup_actions_provider :ansible_hostgroups_actions
246
+ end
239
247
  end
@@ -48,12 +48,6 @@ module ForemanAnsible
48
48
  :description => N_('Upgrade Capsules on given Capsule server hosts'),
49
49
  :proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
50
50
  )
51
- RemoteExecutionFeature.register(
52
- :ansible_configure_cloud_connector,
53
- N_('Configure Cloud Connector on given hosts'),
54
- :description => N_('Configure Cloud Connector on given hosts'),
55
- :proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
56
- )
57
51
  end
58
52
  end
59
53
  end
@@ -4,5 +4,5 @@
4
4
  # This way other parts of Foreman can just call ForemanAnsible::VERSION
5
5
  # and detect what version the plugin is running.
6
6
  module ForemanAnsible
7
- VERSION = '7.1.2'
7
+ VERSION = '9.0.0'
8
8
  end
@@ -1,5 +1,6 @@
1
1
  # Autogenerated!
2
- _("Action with sub plans")
3
- _("Import facts")
2
+ _("Preupgrade job")
3
+ _("Remote action:")
4
4
  _("Import Puppet classes")
5
- _("Remote action:")
5
+ _("Import facts")
6
+ _("Action with sub plans")