foreman_ansible 11.0.0 → 11.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -9
  3. data/app/graphql/types/overriden_ansible_variable.rb +4 -2
  4. data/app/helpers/foreman_ansible/ansible_hostgroups_helper.rb +7 -1
  5. data/app/helpers/foreman_ansible/ansible_reports_helper.rb +28 -10
  6. data/app/helpers/foreman_ansible/smart_proxies_helper.rb +7 -1
  7. data/app/views/foreman_ansible/config_reports/_ansible.html.erb +1 -1
  8. data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +4 -32
  9. data/app/views/foreman_ansible/job_templates/smart_proxy_upgrade_-_ansible_default.erb +59 -0
  10. data/db/migrate/20210818083407_fix_ansible_setting_category_to_dsl.rb +1 -1
  11. data/lib/foreman_ansible/version.rb +1 -1
  12. data/locale/ca/foreman_ansible.edit.po +1162 -0
  13. data/locale/ca/foreman_ansible.po.time_stamp +0 -0
  14. data/locale/cs_CZ/foreman_ansible.edit.po +1207 -0
  15. data/locale/cs_CZ/foreman_ansible.po.time_stamp +0 -0
  16. data/locale/de/foreman_ansible.edit.po +1148 -0
  17. data/locale/de/foreman_ansible.po.time_stamp +0 -0
  18. data/locale/en/foreman_ansible.edit.po +1146 -0
  19. data/locale/en/foreman_ansible.po.time_stamp +0 -0
  20. data/locale/en_GB/foreman_ansible.edit.po +1155 -0
  21. data/locale/en_GB/foreman_ansible.po.time_stamp +0 -0
  22. data/locale/es/foreman_ansible.edit.po +1148 -0
  23. data/locale/es/foreman_ansible.po.time_stamp +0 -0
  24. data/locale/fr/foreman_ansible.edit.po +1148 -0
  25. data/locale/fr/foreman_ansible.po.time_stamp +0 -0
  26. data/locale/gl/foreman_ansible.edit.po +1156 -0
  27. data/locale/gl/foreman_ansible.po.time_stamp +0 -0
  28. data/locale/it/foreman_ansible.edit.po +1148 -0
  29. data/locale/it/foreman_ansible.po.time_stamp +0 -0
  30. data/locale/ja/foreman_ansible.edit.po +1148 -0
  31. data/locale/ja/foreman_ansible.po.time_stamp +0 -0
  32. data/locale/ko/foreman_ansible.edit.po +1148 -0
  33. data/locale/ko/foreman_ansible.po.time_stamp +0 -0
  34. data/locale/nl_NL/foreman_ansible.edit.po +1168 -0
  35. data/locale/nl_NL/foreman_ansible.po.time_stamp +0 -0
  36. data/locale/pl/foreman_ansible.edit.po +1180 -0
  37. data/locale/pl/foreman_ansible.po.time_stamp +0 -0
  38. data/locale/pt_BR/foreman_ansible.edit.po +1148 -0
  39. data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
  40. data/locale/ru/foreman_ansible.edit.po +1149 -0
  41. data/locale/ru/foreman_ansible.po.time_stamp +0 -0
  42. data/locale/sv_SE/foreman_ansible.edit.po +1180 -0
  43. data/locale/sv_SE/foreman_ansible.po.time_stamp +0 -0
  44. data/locale/zh_CN/foreman_ansible.edit.po +1148 -0
  45. data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
  46. data/locale/zh_TW/foreman_ansible.edit.po +1148 -0
  47. data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
  48. data/package.json +7 -7
  49. data/test/fixtures/report.json +106 -2
  50. data/test/unit/concerns/config_reports_extensions_test.rb +4 -2
  51. data/test/unit/helpers/ansible_reports_helper_test.rb +60 -0
  52. data/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTableHelper.js +6 -2
  53. data/webpack/components/AnsibleHostDetail/components/JobsTab/PreviousJobsTable.js.orig +151 -0
  54. data/webpack/formHelper.js +9 -4
  55. data/webpack/graphql/queries/currentUserAttributes.gql +5 -0
  56. data/webpack/permissionsHelper.js +4 -1
  57. data/webpack/testHelper.js +6 -0
  58. metadata +54 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 348701b380a514ccae60dda27305a137438dd4cd2812f9515e071a527a0b20c5
4
- data.tar.gz: ab770d603437ed890a945381d28411e0caff547f6bef26b22c98191fe6317b98
3
+ metadata.gz: d240da772a37f88926b90ead02fae80bea4f14e257cff99873c805c7ff171a92
4
+ data.tar.gz: 00e38d4208388c1893e29f440f1afc6f4988fc31a9c1d9e1107bb337f34e14a2
5
5
  SHA512:
6
- metadata.gz: 0a780ccd49ae7534e43de5ea1f50aab631b3f59c30c5793455e242568b77d2572fe187f7f0c75667cb1c22ccfd03666dd2ce7df2541cb974df1693ff58079250
7
- data.tar.gz: ab9bdea79a470967e8c6592d7166317668a5d9f892887b8d715fc1daaa9a8ce99959cb5c4da2496dabf4b9e4d2ada5909c2e78bfa250bcd13d2250d7d32a1473
6
+ metadata.gz: b1af6d0d6eee6c4f7ef48c22d795c6480516c1f8fa80539d64b6c6184b945af1a8a6350cfa963963b486a1b169a907efffa6573528547e1e386d47b819d96967
7
+ data.tar.gz: 2e8f162c2ec013b1bee7be62f06b77a55b0d22d57e40449e3cdb7312ff3a532fa3bb61a0b083fb7a5421d5ad33a1d7811d749e0ec4c6e95741d36bd49644da46
data/README.md CHANGED
@@ -6,21 +6,18 @@
6
6
 
7
7
  Reporting and facts import from Ansible to Foreman.
8
8
 
9
- * Main website: [theforeman.org](http://theforeman.org)
10
- * Plugin manual: [foreman_ansible manual](http://theforeman.org/plugins/foreman_ansible)
11
- * ServerFault tag: [Foreman](http://serverfault.com/questions/tagged/foreman)
12
- * Issues: [foreman ansible on Redmine](http://projects.theforeman.org/projects/ansible/issues)
13
- * Community and support: [#theforeman](https://kiwiirc.com/client/irc.freenode.net/?#theforeman) for general support, [#theforeman-dev](https://kiwiirc.com/client/irc.freenode.net/?#theforeman-dev) for development chat in [Freenode](irc.freenode.net)
14
- * Mailing lists:
15
- * [foreman-users](https://groups.google.com/forum/?fromgroups#!forum/foreman-users)
16
- * [foreman-dev](https://groups.google.com/forum/?fromgroups#!forum/foreman-dev)
9
+ * Main website: [theforeman.org](https://theforeman.org)
10
+ * Plugin manual: [foreman_ansible manual](https://theforeman.org/plugins/foreman_ansible)
11
+ * ServerFault tag: [Foreman](https://serverfault.com/questions/tagged/foreman)
12
+ * Issues: [foreman ansible on Redmine](https://projects.theforeman.org/projects/ansible/issues)
13
+ * Chat and forum: [https://theforeman.org/support.html](https://theforeman.org/support.html)
17
14
 
18
15
  ## Features
19
16
  * Import facts
20
17
  * Monitor playbook and Ansible runs runtime
21
18
  * Sends Ansible reports to Foreman that contain what changed on your system after an ansible run.
22
19
  * Stores a list of roles applicable to your hosts and 'plays' them
23
- * Looking for an Ansible dynamic inventory for Foreman? Use [foreman_ansible_inventory](https://github.com/theforeman/foreman_ansible_inventory/)
20
+ * Looking for an Ansible dynamic inventory for Foreman? Use [theforeman.foreman.foreman](https://github.com/theforeman/foreman-ansible-modules/blob/develop/plugins/inventory/foreman.py)
24
21
 
25
22
  ## Documentation (installation and configuration)
26
23
  Check out the official manual at [theforeman.org](http://theforeman.org/plugins/foreman_ansible/2.x/index.html)
@@ -8,12 +8,14 @@ module Types
8
8
  argument :match, String, required: false
9
9
  end
10
10
 
11
- field :meta, ::Types::Meta, resolve: (proc do |object|
11
+ field :meta, ::Types::Meta
12
+
13
+ def meta
12
14
  {
13
15
  :can_edit => ::User.current.can?(object.ansible_variable.permission_name(:edit), object.ansible_variable),
14
16
  :can_destroy => ::User.current.can?(object.ansible_variable.permission_name(:destroy), object.ansible_variable)
15
17
  }
16
- end)
18
+ end
17
19
 
18
20
  def lookup_values(match: nil)
19
21
  return CollectionLoader.for(object.ansible_variable.class, :lookup_values).load(object.ansible_variable) unless match
@@ -3,13 +3,19 @@
3
3
  module ForemanAnsible
4
4
  module AnsibleHostgroupsHelper
5
5
  def ansible_hostgroups_actions(hostgroup)
6
+ actions = []
6
7
  play_roles = if hostgroup.all_ansible_roles.empty?
7
8
  { action: { content: (link_to _('Run all Ansible roles'), 'javascript:void(0);', disabled: true, title: 'No roles assigned', class: 'disabled'), options: { class: 'disabled' } }, priority: 31 }
8
9
  else
9
10
  { 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
11
  end
11
12
 
12
- [play_roles] if User.current.can?(:create_job_invocations)
13
+ assign_jobs = { action: { content: (link_to _('Configure Ansible Job'), "/ansible/hostgroups/#{hostgroup.id}", class: 'la') }, priority: 32 }
14
+
15
+ actions.push play_roles if User.current.can?(:create_job_invocations)
16
+ actions.push assign_jobs if User.current.can?(:view_job_invocations) && User.current.can?(:view_recurring_logics)
17
+
18
+ actions
13
19
  end
14
20
  end
15
21
  end
@@ -28,26 +28,36 @@ module ForemanAnsible
28
28
  def ansible_module_message(log)
29
29
  msg_json = parsed_message_json(log)
30
30
  return _("Execution error: #{msg_json['msg']}") if msg_json['failed'].present?
31
+ return msg_json['censored'] if msg_json['censored'].present?
31
32
 
32
- module_action = msg_json['module']
33
+ module_action = msg_json.fetch('module', '').delete_prefix('ansible.builtin.').delete_prefix('ansible.legacy.')
33
34
  case module_action
34
35
  when 'package'
35
36
  msg_json['results'].empty? ? msg_json['msg'] : msg_json['results']
36
37
  when 'template'
37
- module_args = msg_json['invocation']['module_args']
38
- _("Rendered template #{module_args['_original_basename']} to #{msg_json['dest']}")
38
+ get_results(msg_json) do |module_args, result|
39
+ _("Rendered template #{module_args['_original_basename']} to #{result['dest']}")
40
+ end
39
41
  when 'service'
40
- _("Service #{msg_json['name']} #{msg_json['state']} (enabled: #{msg_json['enabled']})")
42
+ get_results(msg_json) do |_, result|
43
+ _("Service #{result['name']} #{result['state']} (enabled: #{result['enabled']})")
44
+ end
41
45
  when 'group'
42
- _("User group #{msg_json['name']} #{msg_json['state']}, gid: #{msg_json['gid']}")
46
+ get_results(msg_json) do |_, result|
47
+ _("User group #{result['name']} #{result['state']}, gid: #{result['gid']}")
48
+ end
43
49
  when 'user'
44
- _("User #{msg_json['name']} #{msg_json['state']}, uid: #{msg_json['uid']}")
50
+ get_results(msg_json) do |_, result|
51
+ _("User #{result['name']} #{result['state']}, uid: #{result['uid']}")
52
+ end
45
53
  when 'cron'
46
- module_args = msg_json['invocation']['module_args']
47
- _("Cron job: #{module_args['minute']} #{module_args['hour']} #{module_args['day']} #{module_args['month']} #{module_args['weekday']} #{module_args['job']} (disabled: #{module_args['disabled']})")
54
+ get_results(msg_json) do |module_args, _|
55
+ _("Cron job: #{module_args['minute']} #{module_args['hour']} #{module_args['day']} #{module_args['month']} #{module_args['weekday']} #{module_args['job']} (disabled: #{module_args['disabled']})")
56
+ end
48
57
  when 'copy'
49
- module_args = msg_json['invocation']['module_args']
50
- _("Copy #{module_args['_original_basename']} to #{msg_json['dest']}")
58
+ get_results(msg_json) do |module_args, result|
59
+ _("Copy #{module_args['_original_basename']} to #{result['dest']}")
60
+ end
51
61
  when 'command', 'shell'
52
62
  msg_json['stdout_lines']
53
63
  else
@@ -82,6 +92,14 @@ module ForemanAnsible
82
92
 
83
93
  private
84
94
 
95
+ def get_results(msg_json)
96
+ results = msg_json.key?('results') ? msg_json['results'] : [msg_json]
97
+ results.map do |result|
98
+ module_args = result.fetch('invocation', {}).fetch('module_args', {})
99
+ yield module_args, result
100
+ end
101
+ end
102
+
85
103
  def parsed_message_json(log)
86
104
  JSON.parse(log.message.value)
87
105
  rescue StandardError => e
@@ -27,7 +27,13 @@ module ForemanAnsible
27
27
  end
28
28
 
29
29
  def proxy_update_button(proxy)
30
- feature = RemoteExecutionFeature.feature(:ansible_run_capsule_upgrade)
30
+ name = if Foreman::Plugin.find('foreman_theme_satellite').present?
31
+ :ansible_run_capsule_upgrade
32
+ else
33
+ :ansible_run_smart_proxy_upgrade
34
+ end
35
+
36
+ feature = RemoteExecutionFeature.feature(name)
31
37
  return if feature.nil?
32
38
 
33
39
  path = new_job_invocation_path(:host_ids => proxy.infrastructure_host_facets.pluck(:host_id),
@@ -33,7 +33,7 @@
33
33
  <div class='pull-left'>
34
34
  <%= truncate(log_message, length: allowed_length) %>
35
35
  </div>
36
- <%= show_full_error_message_value(log_message) if log_message.length > allowed_length %>
36
+ <%= show_full_error_message_value(log_message) if (log_message&.length || 0) > allowed_length %>
37
37
  <% end %>
38
38
  </td>
39
39
  </tr>
@@ -1,5 +1,5 @@
1
1
  <%#
2
- name: Smart Proxy Upgrade Playbook
2
+ name: Capsule Upgrade Playbook
3
3
  snippet: false
4
4
  template_inputs:
5
5
  - name: target_version
@@ -26,8 +26,8 @@ feature: ansible_run_capsule_upgrade
26
26
  - hosts: all
27
27
  vars:
28
28
  target_version: "<%= input('target_version').present? ? input('target_version') : product_short_version %>"
29
- <% if plugin_present?('foreman_theme_satellite') -%>
30
29
  tasks:
30
+ <% if plugin_present?('foreman_theme_satellite') -%>
31
31
  - name: Gather the rpm package facts
32
32
  package_facts:
33
33
  manager: auto
@@ -75,35 +75,7 @@ feature: ansible_run_capsule_upgrade
75
75
  fail:
76
76
  msg: "Failed! Capsule server upgrade failed. See /var/log/foreman-installer/capsule.log in the Capsule server for more information"
77
77
  <% else -%>
78
- tasks:
79
- - name: Gather the rpm package facts
80
- package_facts:
81
- manager: auto
82
-
83
- - name: Fail if the target server is a Foreman server
78
+ - name: Fail if foreman_theme_satellite is missing
84
79
  fail:
85
- msg: "This playbook cannot be executed on a Foreman server. Use only on a Smart Proxy server."
86
- when: "'foreman' in ansible_facts.packages"
87
-
88
- - name: Install foreman release gpg key
89
- rpm_key:
90
- state: present
91
- key: http://yum.theforeman.org/releases/{{ target_version }}/RPM-GPG-KEY-foreman
92
- when: target_version != "nightly"
93
-
94
- - name: Update foreman repositories
95
- package:
96
- name: https://yum.theforeman.org/releases/{{ target_version }}/el{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/foreman-release.rpm
97
- state: installed
98
-
99
- - name: Clean yum metadata
100
- command: yum clean all
101
-
102
- - name: Update all packages
103
- package:
104
- name: '*'
105
- state: latest
106
-
107
- - name: Run the installer
108
- shell: foreman-installer
80
+ msg: "Failed! The plugin foreman_theme_satellite is not present. This playbook is only for use with Satellite."
109
81
  <% end -%>
@@ -0,0 +1,59 @@
1
+ <%#
2
+ name: Smart Proxy Upgrade Playbook
3
+ snippet: false
4
+ template_inputs:
5
+ - name: target_version
6
+ required: false
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: Maintenance Operations
19
+ description_format: "%{template_name}"
20
+ provider_type: Ansible
21
+ kind: job_template
22
+ feature: ansible_run_smart_proxy_upgrade
23
+ %>
24
+
25
+ ---
26
+ - hosts: all
27
+ vars:
28
+ target_version: "<%= input('target_version').present? ? input('target_version') : product_short_version %>"
29
+ tasks:
30
+ - name: Gather the rpm package facts
31
+ package_facts:
32
+ manager: auto
33
+
34
+ - name: Fail if the target server is a Foreman server
35
+ fail:
36
+ msg: "This playbook cannot be executed on a Foreman server. Use only on a Smart Proxy server."
37
+ when: "'foreman' in ansible_facts.packages"
38
+
39
+ - name: Install foreman release gpg key
40
+ rpm_key:
41
+ state: present
42
+ key: http://yum.theforeman.org/releases/{{ target_version }}/RPM-GPG-KEY-foreman
43
+ when: target_version != "nightly"
44
+
45
+ - name: Update foreman repositories
46
+ package:
47
+ name: https://yum.theforeman.org/releases/{{ target_version }}/el{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/foreman-release.rpm
48
+ state: installed
49
+
50
+ - name: Clean yum metadata
51
+ command: yum clean all
52
+
53
+ - name: Update all packages
54
+ package:
55
+ name: '*'
56
+ state: latest
57
+
58
+ - name: Run the installer
59
+ shell: foreman-installer
@@ -1,5 +1,5 @@
1
1
  class FixAnsibleSettingCategoryToDsl < ActiveRecord::Migration[6.0]
2
2
  def up
3
- Setting.where(category: 'Setting::Ansible').update_all(category: 'Setting')
3
+ Setting.where(category: 'Setting::Ansible').update_all(category: 'Setting') if column_exists?(:settings, :category)
4
4
  end
5
5
  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 = '11.0.0'
7
+ VERSION = '11.1.1'
8
8
  end