foreman_ansible 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/api/v2/ansible_roles_controller.rb +10 -5
  3. data/app/controllers/foreman_ansible/api/v2/hostgroups_controller_extensions.rb +1 -1
  4. data/app/controllers/foreman_ansible/api/v2/hosts_controller_extensions.rb +1 -1
  5. data/app/models/ansible_role.rb +9 -0
  6. data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +1 -0
  7. data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +1 -0
  8. data/app/models/host_ansible_role.rb +0 -1
  9. data/app/models/setting/ansible.rb +15 -0
  10. data/app/services/foreman_ansible/insights_notification_builder.rb +64 -0
  11. data/app/services/foreman_ansible/insights_plan_runner.rb +17 -2
  12. data/app/services/foreman_ansible/inventory_creator.rb +10 -0
  13. data/app/services/foreman_ansible/renderer_methods.rb +10 -3
  14. data/app/services/foreman_ansible/ui_roles_importer.rb +0 -2
  15. data/app/views/api/v2/ansible_roles/show.json.rabl +1 -1
  16. data/app/views/foreman_ansible/job_templates/package_action_-_ansible_default.erb +4 -0
  17. data/app/views/foreman_ansible/job_templates/power_action_-_ansible_default.erb +2 -2
  18. data/app/views/foreman_ansible/job_templates/puppet_run_once_-_ansible_default.erb +1 -1
  19. data/app/views/foreman_ansible/job_templates/run_command_-_ansible_default.erb +2 -1
  20. data/app/views/foreman_ansible/job_templates/service_action_-_ansible_default.erb +1 -1
  21. data/db/migrate/20180410125416_rename_ansible_job_categories.rb +30 -0
  22. data/db/seeds.d/75_job_templates.rb +18 -16
  23. data/db/seeds.d/90_notification_blueprints.rb +17 -0
  24. data/lib/foreman_ansible/engine.rb +1 -2
  25. data/lib/foreman_ansible/register.rb +1 -0
  26. data/lib/foreman_ansible/remote_execution.rb +4 -1
  27. data/lib/foreman_ansible/version.rb +1 -1
  28. data/locale/en/foreman_ansible.po +130 -7
  29. data/locale/foreman_ansible.pot +224 -34
  30. data/test/fixtures/insights_playbook.yaml +79 -0
  31. data/test/unit/services/insights_plan_runner_test.rb +36 -0
  32. data/test/unit/services/inventory_creator_test.rb +18 -0
  33. metadata +32 -47
  34. data/webpack/components/ReportJsonViewer.js +0 -17
  35. data/webpack/index.js +0 -4
@@ -0,0 +1,79 @@
1
+ # Red Hat Insights has recommended one or more actions for you, a system administrator, to review and if you
2
+ # deem appropriate, deploy on your systems running Red Hat software. Based on the analysis, we have automatically
3
+ # generated an Ansible Playbook for you. Please review and test the recommended actions and the Playbook as
4
+ # they may contain configuration changes, updates, reboots and/or other changes to your systems. Red Hat is not
5
+ # responsible for any adverse outcomes related to these recommendations or Playbooks.
6
+ #
7
+ # Addresses maintenance plan 38439429 (demo)
8
+ # https://access.redhat.com/insights/planner/438294928
9
+ # Generated by Red Hat Insights on Wed, 18 Apr 2018 07:54:18 GMT
10
+ # Warning: Some of the rules in the plan do not have Ansible support and this playbook does not address them!
11
+
12
+ # Kernel vulnerable to denial of service via Bluetooth stack (CVE-2017-1000251/Blueborne)
13
+ # Identifier: (CVE_2017_1000251_kernel_blueborne|KERNEL_CVE_2017_1000251_POSSIBLE_DOS,105,fix)
14
+ # Version: 43787ds87s78d87s87438787s87ds87ds87
15
+ - name: Update system to the latest kernel and reboot
16
+ hosts: "juana-sensel.lobatolan.home"
17
+ become: true
18
+ vars:
19
+ # determine if we need to update the 'kernel' package or 'kernel-rt' package
20
+ kernel_pkg: "{{'kernel-rt' if 'rt' in ansible_kernel else 'kernel'}}"
21
+
22
+ tasks:
23
+ - name: Update kernel
24
+ yum:
25
+ name: "{{kernel_pkg}}"
26
+ state: latest
27
+ register: yum
28
+
29
+ - when: yum|changed
30
+ name: set reboot fact
31
+ set_fact:
32
+ insights_needs_reboot: True
33
+
34
+ - when: not yum|changed
35
+ # The latest kernel is already installed so boot from it. Sort the installed kernels
36
+ # by buildtime and select the one with the most recent build time
37
+ block:
38
+ - name: get latest installed {{kernel_pkg}} package version
39
+ shell: rpm -q {{kernel_pkg}} --queryformat="%{buildtime}\t%{version}-%{release}.%{arch}\n" | sort -nr | head -1 | cut -f2
40
+ register: latest_kernel
41
+ check_mode: no
42
+
43
+ - name: get configured default kernel
44
+ command: /sbin/grubby --default-kernel
45
+ register: default_kernel
46
+ check_mode: no
47
+
48
+ - when: default_kernel.stdout.split('-', 1)[1] != latest_kernel.stdout
49
+ name: set the default kernel to the latest installed
50
+ command: /sbin/grubby --set-default /boot/vmlinuz-{{latest_kernel.stdout}}
51
+ register: grub_change
52
+ check_mode: no
53
+
54
+ - when: grub_change|changed
55
+ name: set reboot fact
56
+ set_fact:
57
+ insights_needs_reboot: True
58
+
59
+
60
+ # Automatic system reboot was suppressed for this playbook.
61
+ # This play lists the systems that need to be rebooted manually for the changes to take effect.
62
+ - name: Reboot reminder
63
+ hosts: juana-sensel.lobatolan.home
64
+ gather_facts: False
65
+ tasks:
66
+ - debug:
67
+ msg: "Automatic system reboot was suppressed for this playbook. Reboot {{inventory_hostname}} manually for the changes to take effect."
68
+ when:
69
+ - insights_needs_reboot is defined
70
+ - insights_needs_reboot
71
+
72
+ - name: run insights
73
+ hosts: juana-sensel.lobatolan.home
74
+ become: True
75
+ gather_facts: False
76
+ tasks:
77
+ - name: run insights
78
+ command: redhat-access-insights
79
+ changed_when: false
@@ -0,0 +1,36 @@
1
+ require 'test_plugin_helper'
2
+
3
+ if defined? RedhatAccess
4
+ module ForemanAnsible
5
+ # Tests for the RH Insights plan runner. Mostly about checking whether
6
+ # the playbook can be parsed properly
7
+ class InsightsPlanRunnerTest < ActiveSupport::TestCase
8
+ test 'disclaimer is saved as raw_playbook' do
9
+ disclaimer = <<-DISCLAIMER.strip_heredoc.strip
10
+ # Red Hat Insights has recommended one or more actions for you, a system administrator, to review and if you
11
+ # deem appropriate, deploy on your systems running Red Hat software. Based on the analysis, we have automatically
12
+ # generated an Ansible Playbook for you. Please review and test the recommended actions and the Playbook as
13
+ # they may contain configuration changes, updates, reboots and/or other changes to your systems. Red Hat is not
14
+ # responsible for any adverse outcomes related to these recommendations or Playbooks.
15
+ #
16
+ # Addresses maintenance plan 38439429 (demo)
17
+ # https://access.redhat.com/insights/planner/438294928
18
+ # Generated by Red Hat Insights on Wed, 18 Apr 2018 07:54:18 GMT
19
+ DISCLAIMER
20
+
21
+ playbook = File.read(ansible_fixture_file('insights_playbook.yaml'))
22
+ planner = ::ForemanAnsible::InsightsPlanRunner.new(
23
+ FactoryBot.build(:organization), rand
24
+ )
25
+ assert_empty planner.parse_disclaimer
26
+ planner.expects(:insights_api_host).returns('')
27
+ planner.expects(:get_ssl_options_for_org).returns(nil)
28
+ RestClient::Resource.any_instance.expects(:get).returns(
29
+ OpenStruct.new(:body => playbook)
30
+ )
31
+ planner.playbook
32
+ assert_equal disclaimer, planner.parse_disclaimer
33
+ end
34
+ end
35
+ end
36
+ end
@@ -62,6 +62,8 @@ module ForemanAnsible
62
62
  connection_params['ansible_user']
63
63
  refute_equal Setting['remote_execution_ssh_port'],
64
64
  connection_params['ansible_port']
65
+ assert_equal ForemanRemoteExecutionCore.settings[:ssh_identity_key_file],
66
+ connection_params['ansible_ssh_private_key_file']
65
67
  assert_equal extra_options['ansible_port'],
66
68
  connection_params['ansible_port']
67
69
  assert_equal Setting['remote_execution_ssh_password'],
@@ -77,6 +79,22 @@ module ForemanAnsible
77
79
  inventory.rex_ssh_password(@host))
78
80
  end
79
81
 
82
+ test 'ssh private key is passed when available' do
83
+ host = FactoryBot.build(:host)
84
+ path_to_key = '/path/to/private/key'
85
+ inventory = ForemanAnsible::InventoryCreator.new(host,
86
+ @template_invocation)
87
+ host.params.expects(:[]).with('ansible_ssh_private_key_file').
88
+ returns(path_to_key)
89
+ host.params.expects(:[]).with('remote_execution_ssh_user').
90
+ returns('root')
91
+ host.params.expects(:[]).with('remote_execution_ssh_port').
92
+ returns('2222')
93
+ connection_params = inventory.connection_params(host)
94
+ assert_equal path_to_key,
95
+ connection_params['ansible_ssh_private_key_file']
96
+ end
97
+
80
98
  test 'template invocation inputs are sent as Ansible variables' do
81
99
  job_template = FactoryBot.build(
82
100
  :job_template,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "<"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
- - !ruby/object:Gem::Dependency
42
- name: dynflow
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.8.14
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.8.14
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: foreman-tasks
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -59,9 +45,6 @@ dependencies:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
47
  version: '0.8'
62
- - - "<"
63
- - !ruby/object:Gem::Version
64
- version: '0.12'
65
48
  type: :runtime
66
49
  prerelease: false
67
50
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,9 +52,6 @@ dependencies:
69
52
  - - "~>"
70
53
  - !ruby/object:Gem::Version
71
54
  version: '0.8'
72
- - - "<"
73
- - !ruby/object:Gem::Version
74
- version: '0.12'
75
55
  - !ruby/object:Gem::Dependency
76
56
  name: foreman_ansible_core
77
57
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +130,7 @@ files:
150
130
  - app/services/foreman_ansible/fact_importer.rb
151
131
  - app/services/foreman_ansible/fact_parser.rb
152
132
  - app/services/foreman_ansible/fact_sparser.rb
133
+ - app/services/foreman_ansible/insights_notification_builder.rb
153
134
  - app/services/foreman_ansible/insights_plan_runner.rb
154
135
  - app/services/foreman_ansible/inventory_creator.rb
155
136
  - app/services/foreman_ansible/playbook_creator.rb
@@ -191,8 +172,10 @@ files:
191
172
  - db/migrate/20160802153302_create_join_table_hostgroup_ansible_roles.rb
192
173
  - db/migrate/20160805094233_add_primary_key_hostgroup_ansible_roles.rb
193
174
  - db/migrate/20161122154057_automatically_set_role_timestamps.rb
175
+ - db/migrate/20180410125416_rename_ansible_job_categories.rb
194
176
  - db/seeds.d/62_ansible_proxy_feature.rb
195
177
  - db/seeds.d/75_job_templates.rb
178
+ - db/seeds.d/90_notification_blueprints.rb
196
179
  - lib/foreman_ansible.rb
197
180
  - lib/foreman_ansible/engine.rb
198
181
  - lib/foreman_ansible/register.rb
@@ -205,6 +188,7 @@ files:
205
188
  - package.json
206
189
  - test/factories/ansible_proxy.rb
207
190
  - test/factories/ansible_roles.rb
191
+ - test/fixtures/insights_playbook.yaml
208
192
  - test/fixtures/report.json
209
193
  - test/fixtures/sample_facts.json
210
194
  - test/functional/ansible_roles_controller_test.rb
@@ -229,13 +213,12 @@ files:
229
213
  - test/unit/services/fact_importer_test.rb
230
214
  - test/unit/services/fact_parser_test.rb
231
215
  - test/unit/services/fact_sparser_test.rb
216
+ - test/unit/services/insights_plan_runner_test.rb
232
217
  - test/unit/services/inventory_creator_test.rb
233
218
  - test/unit/services/proxy_selector_test.rb
234
219
  - test/unit/services/roles_importer_test.rb
235
220
  - test/unit/services/structured_fact_importer_test.rb
236
221
  - test/unit/services/ui_roles_importer_test.rb
237
- - webpack/components/ReportJsonViewer.js
238
- - webpack/index.js
239
222
  homepage: https://github.com/theforeman/foreman_ansible
240
223
  licenses:
241
224
  - GPL-3.0
@@ -256,39 +239,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
239
  version: '0'
257
240
  requirements: []
258
241
  rubyforge_project:
259
- rubygems_version: 2.6.12
242
+ rubygems_version: 2.7.3
260
243
  signing_key:
261
244
  specification_version: 4
262
245
  summary: Ansible integration with Foreman (theforeman.org)
263
246
  test_files:
264
- - test/factories/ansible_proxy.rb
265
- - test/factories/ansible_roles.rb
266
- - test/functional/api/v2/ansible_roles_controller_test.rb
267
- - test/functional/api/v2/hostgroups_controller_test.rb
268
- - test/functional/api/v2/hosts_controller_test.rb
269
- - test/functional/ansible_roles_controller_test.rb
270
- - test/functional/hosts_controller_test.rb
271
247
  - test/unit/ansible_role_test.rb
272
- - test/unit/concerns/config_reports_extensions_test.rb
273
- - test/unit/concerns/host_managed_extensions_test.rb
274
- - test/unit/concerns/hostgroup_extensions_test.rb
275
- - test/unit/lib/foreman_ansible_core/playbook_runner_test.rb
276
- - test/unit/lib/foreman_ansible_core/roles_reader_test.rb
277
- - test/unit/lib/proxy_api/ansible_test.rb
248
+ - test/unit/hostgroup_ansible_role_test.rb
278
249
  - test/unit/services/api_roles_importer_test.rb
279
- - test/unit/services/fact_importer_test.rb
280
- - test/unit/services/fact_parser_test.rb
281
250
  - test/unit/services/fact_sparser_test.rb
282
- - test/unit/services/inventory_creator_test.rb
283
251
  - test/unit/services/proxy_selector_test.rb
284
- - test/unit/services/roles_importer_test.rb
252
+ - test/unit/services/insights_plan_runner_test.rb
285
253
  - test/unit/services/structured_fact_importer_test.rb
286
254
  - test/unit/services/ui_roles_importer_test.rb
287
- - test/unit/actions/run_ansible_job_test.rb
288
- - test/unit/actions/run_proxy_ansible_command_test.rb
255
+ - test/unit/services/inventory_creator_test.rb
256
+ - test/unit/services/fact_parser_test.rb
257
+ - test/unit/services/roles_importer_test.rb
258
+ - test/unit/services/fact_importer_test.rb
289
259
  - test/unit/helpers/ansible_reports_helper_test.rb
260
+ - test/unit/actions/run_proxy_ansible_command_test.rb
261
+ - test/unit/actions/run_ansible_job_test.rb
262
+ - test/unit/lib/foreman_ansible_core/playbook_runner_test.rb
263
+ - test/unit/lib/foreman_ansible_core/roles_reader_test.rb
264
+ - test/unit/lib/proxy_api/ansible_test.rb
290
265
  - test/unit/host_ansible_role_test.rb
291
- - test/unit/hostgroup_ansible_role_test.rb
292
- - test/fixtures/sample_facts.json
293
- - test/fixtures/report.json
266
+ - test/unit/concerns/host_managed_extensions_test.rb
267
+ - test/unit/concerns/config_reports_extensions_test.rb
268
+ - test/unit/concerns/hostgroup_extensions_test.rb
269
+ - test/factories/ansible_proxy.rb
270
+ - test/factories/ansible_roles.rb
294
271
  - test/test_plugin_helper.rb
272
+ - test/fixtures/insights_playbook.yaml
273
+ - test/fixtures/report.json
274
+ - test/fixtures/sample_facts.json
275
+ - test/functional/ansible_roles_controller_test.rb
276
+ - test/functional/api/v2/ansible_roles_controller_test.rb
277
+ - test/functional/api/v2/hostgroups_controller_test.rb
278
+ - test/functional/api/v2/hosts_controller_test.rb
279
+ - test/functional/hosts_controller_test.rb
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import JSONTree from 'react-json-tree';
3
-
4
- const theme = {
5
- scheme: 'foreman',
6
- backgroundColor: 'rgba(0, 0, 0, 255)',
7
- base00: 'rgba(0, 0, 0, 0)',
8
- };
9
-
10
- class ReportJsonViewer extends React.Component {
11
- render() {
12
- return <div className="report-json-viewer">
13
- <JSONTree data={this.props.data} hideRoot theme={theme} />
14
- </div>;
15
- }
16
- }
17
- export default ReportJsonViewer;
@@ -1,4 +0,0 @@
1
- import componentRegistry from 'foremanReact/components/componentRegistry';
2
- import ReportJsonViewer from './components/ReportJsonViewer';
3
-
4
- componentRegistry.register({ name: 'ReportJsonViewer', type: ReportJsonViewer });