foreman_ansible 7.1.8 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) 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_reports_helper.rb +4 -0
  5. data/app/helpers/foreman_ansible/hosts_helper.rb +19 -0
  6. data/app/services/foreman_ansible/variables_importer.rb +9 -9
  7. data/app/views/api/v2/hostgroups/ansible_roles.json.rabl +9 -1
  8. data/app/views/api/v2/hosts/ansible_roles.json.rabl +9 -1
  9. data/lib/foreman_ansible/engine.rb +0 -1
  10. data/lib/foreman_ansible/register.rb +5 -1
  11. data/lib/foreman_ansible/version.rb +1 -1
  12. data/locale/action_names.rb +4 -3
  13. data/locale/ca/foreman_ansible.edit.po +1162 -0
  14. data/locale/ca/foreman_ansible.po +360 -45
  15. data/locale/ca/foreman_ansible.po.time_stamp +0 -0
  16. data/locale/cs_CZ/foreman_ansible.edit.po +1207 -0
  17. data/locale/cs_CZ/foreman_ansible.po +372 -57
  18. data/locale/cs_CZ/foreman_ansible.po.time_stamp +0 -0
  19. data/locale/de/foreman_ansible.edit.po +1148 -0
  20. data/locale/de/foreman_ansible.po +355 -40
  21. data/locale/de/foreman_ansible.po.time_stamp +0 -0
  22. data/locale/en/foreman_ansible.edit.po +1146 -0
  23. data/locale/en/foreman_ansible.po +355 -40
  24. data/locale/en/foreman_ansible.po.time_stamp +0 -0
  25. data/locale/en_GB/foreman_ansible.edit.po +1155 -0
  26. data/locale/en_GB/foreman_ansible.po +357 -42
  27. data/locale/en_GB/foreman_ansible.po.time_stamp +0 -0
  28. data/locale/es/foreman_ansible.edit.po +1148 -0
  29. data/locale/es/foreman_ansible.po +355 -40
  30. data/locale/es/foreman_ansible.po.time_stamp +0 -0
  31. data/locale/foreman_ansible.pot +767 -263
  32. data/locale/fr/foreman_ansible.edit.po +1148 -0
  33. data/locale/fr/foreman_ansible.po +355 -40
  34. data/locale/fr/foreman_ansible.po.time_stamp +0 -0
  35. data/locale/gl/foreman_ansible.edit.po +1156 -0
  36. data/locale/gl/foreman_ansible.po +358 -43
  37. data/locale/gl/foreman_ansible.po.time_stamp +0 -0
  38. data/locale/it/foreman_ansible.edit.po +1148 -0
  39. data/locale/it/foreman_ansible.po +355 -40
  40. data/locale/it/foreman_ansible.po.time_stamp +0 -0
  41. data/locale/ja/foreman_ansible.edit.po +1148 -0
  42. data/locale/ja/foreman_ansible.po +355 -40
  43. data/locale/ja/foreman_ansible.po.time_stamp +0 -0
  44. data/locale/ko/foreman_ansible.edit.po +1148 -0
  45. data/locale/ko/foreman_ansible.po +355 -40
  46. data/locale/ko/foreman_ansible.po.time_stamp +0 -0
  47. data/locale/nl_NL/foreman_ansible.edit.po +1168 -0
  48. data/locale/nl_NL/foreman_ansible.po +359 -44
  49. data/locale/nl_NL/foreman_ansible.po.time_stamp +0 -0
  50. data/locale/pl/foreman_ansible.edit.po +1180 -0
  51. data/locale/pl/foreman_ansible.po +363 -48
  52. data/locale/pl/foreman_ansible.po.time_stamp +0 -0
  53. data/locale/pt_BR/foreman_ansible.edit.po +1148 -0
  54. data/locale/pt_BR/foreman_ansible.po +355 -40
  55. data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
  56. data/locale/ru/foreman_ansible.edit.po +1149 -0
  57. data/locale/ru/foreman_ansible.po +355 -40
  58. data/locale/ru/foreman_ansible.po.time_stamp +0 -0
  59. data/locale/sv_SE/foreman_ansible.edit.po +1180 -0
  60. data/locale/sv_SE/foreman_ansible.po +363 -48
  61. data/locale/sv_SE/foreman_ansible.po.time_stamp +0 -0
  62. data/locale/zh_CN/foreman_ansible.edit.po +1148 -0
  63. data/locale/zh_CN/foreman_ansible.po +355 -40
  64. data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
  65. data/locale/zh_TW/foreman_ansible.edit.po +1148 -0
  66. data/locale/zh_TW/foreman_ansible.po +355 -40
  67. data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
  68. data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTableHelper.js +4 -13
  69. data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/__test__/AnsibleVariableOverrides.test.js +1 -3
  70. data/webpack/components/AnsibleHostDetail/components/JobsTab/PreviousJobsTable.js.orig +151 -0
  71. data/webpack/components/AnsibleHostDetail/components/RolesTab/AllRolesModal/AllRolesTable.js +11 -1
  72. data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/EditRolesForm.js +8 -10
  73. data/webpack/components/AnsibleHostDetail/components/RolesTab/EditRolesModal/index.js +1 -1
  74. data/webpack/components/AnsibleHostDetail/components/RolesTab/RolesTable.js +10 -1
  75. data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/EditRoles.test.js +1 -2
  76. data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/RolesTab.fixtures.js +30 -0
  77. data/webpack/components/AnsibleHostDetail/components/RolesTab/__test__/RolesTab.test.js +1 -3
  78. data/webpack/components/AnsibleHostDetail/components/RolesTab/index.js +2 -26
  79. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +3 -12
  80. data/webpack/components/AnsibleRolesSwitcher/components/OrderedRolesTooltip.js +11 -12
  81. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRole.test.js.snap +6 -20
  82. data/webpack/graphql/queries/allAnsibleRoles.gql +3 -0
  83. data/webpack/graphql/queries/hostAnsibleRoles.gql +3 -0
  84. data/webpack/testHelper.js +3 -12
  85. metadata +82 -45
  86. data/app/helpers/foreman_ansible/hosts_helper_extensions.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e7ff6676073d880f0e1104159ece7cf319117e0137add3d039165d0050c7841
4
- data.tar.gz: 548ccdf064118379d4de2dd463ee4596fa2cc95bab13349ae3a0dcb733d611fa
3
+ metadata.gz: 47b85dc5fe69b87ea05703f75380a2387deb64674755903ec03c3cb55dcc3bdb
4
+ data.tar.gz: ece7521c8b3f6da727abd6abad8be7384701a1598f6601dc5baf0b1f579931df
5
5
  SHA512:
6
- metadata.gz: 4d820c8d1184bf52c7acde87d2b0cc64d06b61330ec562b181949deb69b861e3bcc32295d6319d6f8c77d2226b82cd2370d078fa7a9820f7a75dafefd022b5fa
7
- data.tar.gz: d7d1b851ee5c4f72f331cfcb4af9430c8c0ba126572d8076ca7d16041ece7d241551b68fd1ad7f96a9c0fd8fbafc353c3d71b61e96f6327de3fe748a77b4705c
6
+ metadata.gz: f72ecf4fc7949815787bd4b93c1da3ee7df5baf2c2266950ddc6bd01b701ae38559896ae45b11995fa3574c84f041e01d7caf41ba1e18ba4b9c0c2cea397b752
7
+ data.tar.gz: cee830b49ad5443db42d34e6e0910e0783b2d116f91b02745a8556e184b4e66535c3620b4e9c15b4329a35286d117df51a0bba3e7d7ae818ab1016a63636e61c
@@ -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',
@@ -57,6 +57,10 @@ 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
+
60
64
  def ansible_report_origin_partial
61
65
  'foreman_ansible/config_reports/ansible'
62
66
  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
@@ -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
@@ -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,8 @@ 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
239
243
  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.8'
7
+ VERSION = '8.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")