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
File without changes
data/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "test": "test"
8
8
  },
9
9
  "peerDependencies": {
10
- "@theforeman/vendor": ">= 8.16.0"
10
+ "@theforeman/vendor": ">= 12.0.1"
11
11
  },
12
12
  "dependencies": {
13
13
  "react-json-tree": "^0.11.0"
@@ -15,12 +15,12 @@
15
15
  "devDependencies": {
16
16
  "@babel/core": "^7.7.0",
17
17
  "@testing-library/user-event": "^13.2.1",
18
- "@theforeman/builder": "^10.0",
19
- "@theforeman/eslint-plugin-foreman": "^10.0",
20
- "@theforeman/find-foreman": "^10.0",
21
- "@theforeman/stories": "^10.0",
22
- "@theforeman/test": "^10.0",
23
- "@theforeman/vendor-dev": "^10.0",
18
+ "@theforeman/builder": ">= 12.0.1",
19
+ "@theforeman/eslint-plugin-foreman": ">= 12.0.1",
20
+ "@theforeman/find-foreman": ">= 12.0.1",
21
+ "@theforeman/stories": ">= 12.0.1",
22
+ "@theforeman/test": ">= 12.0.1",
23
+ "@theforeman/vendor-dev": ">= 12.0.1",
24
24
  "babel-eslint": "^10.0.3",
25
25
  "eslint": "^6.7.2",
26
26
  "prettier": "^1.13.5"
@@ -1,4 +1,4 @@
1
- {
1
+ [{
2
2
  "reporter": "ansible",
3
3
  "reported_at":"2018-01-15 17:31:36 521275",
4
4
  "metrics": {
@@ -24,4 +24,108 @@
24
24
  }
25
25
  }
26
26
  ]
27
- }
27
+ },
28
+ {
29
+ "reporter": "ansible",
30
+ "reported_at":"2022-12-22 10:52:48 521275",
31
+ "metrics": {
32
+ "time":
33
+ { "total":133 }
34
+ },
35
+ "host": "io.local",
36
+ "status": {
37
+ "applied": 8,
38
+ "failed": 0,
39
+ "skipped": 0
40
+ },
41
+ "logs": [
42
+ {
43
+ "log": {
44
+ "sources": {
45
+ "source": "Schedule multiple cronjobs"
46
+ },
47
+ "messages": {
48
+ "message": "{\"changed\": true, \"failed\": false, \"module\": \"cron\", \"msg\": \"All items completed\", \"results\": [{\"_ansible_item_label\": \"date\", \"_ansible_no_log\": false, \"ansible_loop_var\": \"item\", \"changed\": true, \"envs\": [], \"failed\": false, \"invocation\": {\"module_args\": {\"backup\": false, \"cron_file\": null, \"day\": \"*\", \"disabled\": false, \"env\": null, \"hour\": \"5,2\", \"insertafter\": null, \"insertbefore\": null, \"job\": \"date > /dev/null\", \"minute\": \"0\", \"month\": \"*\", \"name\": \"Cron date\", \"reboot\": false, \"special_time\": null, \"state\": \"present\", \"user\": null, \"weekday\": \"*\"}}, \"item\": \"date\", \"jobs\": [\"Cron date\"]}, {\"_ansible_item_label\": \"df\", \"_ansible_no_log\": false, \"ansible_loop_var\": \"item\", \"changed\": true, \"envs\": [], \"failed\": false, \"invocation\": {\"module_args\": {\"backup\": false, \"cron_file\": null, \"day\": \"*\", \"disabled\": false, \"env\": null, \"hour\": \"5,2\", \"insertafter\": null, \"insertbefore\": null, \"job\": \"df > /dev/null\", \"minute\": \"0\", \"month\": \"*\", \"name\": \"Cron df\", \"reboot\": false, \"special_time\": null, \"state\": \"present\", \"user\": null, \"weekday\": \"*\"}}, \"item\": \"df\", \"jobs\": [\"Cron date\", \"Cron df\"]}]}"
49
+ },
50
+ "level": "notice"
51
+ }
52
+ },
53
+ {
54
+ "log": {
55
+ "sources": {
56
+ "source": "Schedule one cronjob"
57
+ },
58
+ "messages": {
59
+ "message": "{\"_ansible_no_log\": false, \"changed\": true, \"envs\": [], \"failed\": false, \"invocation\": {\"module_args\": {\"backup\": false, \"cron_file\": null, \"day\": \"*\", \"disabled\": false, \"env\": null, \"hour\": \"5,2\", \"insertafter\": null, \"insertbefore\": null, \"job\": \"hostname > /dev/null\", \"minute\": \"0\", \"month\": \"*\", \"name\": \"Schedule hostname\", \"reboot\": false, \"special_time\": null, \"state\": \"present\", \"user\": null, \"weekday\": \"*\"}}, \"jobs\": [\"Cron date\", \"Cron df\", \"Schedule hostname\"], \"module\": \"cron\"}"
60
+ },
61
+ "level": "notice"
62
+ }
63
+ },
64
+ {
65
+ "log": {
66
+ "sources": {
67
+ "source": "Render multiple templates"
68
+ },
69
+ "messages": {
70
+ "message": "{\"changed\": true, \"failed\": false, \"module\": \"template\", \"msg\": \"All items completed\", \"results\": [{\"_ansible_item_label\": \"test1.txt\", \"_ansible_no_log\": false, \"ansible_loop_var\": \"item\", \"changed\": true, \"checksum\": \"dba7673010f19a94af4345453005933fd511bea9\", \"dest\": \"/tmp/test1.txt\", \"diff\": [], \"failed\": false, \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"_original_basename\": \"test1.txt.j2\", \"attributes\": null, \"backup\": false, \"checksum\": \"dba7673010f19a94af4345453005933fd511bea9\", \"content\": null, \"delimiter\": null, \"dest\": \"/tmp/test1.txt\", \"directory_mode\": null, \"follow\": false, \"force\": true, \"group\": null, \"local_follow\": null, \"mode\": null, \"owner\": null, \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670606.02-7241-175625077259447/source\", \"unsafe_writes\": false, \"validate\": null}}, \"item\": \"test1.txt\", \"md5sum\": null, \"mode\": \"0644\", \"owner\": \"root\", \"secontext\": \"unconfined_u:object_r:admin_home_t:s0\", \"size\": 6, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670606.02-7241-175625077259447/source\", \"state\": \"file\", \"uid\": 0}, {\"_ansible_item_label\": \"test2.txt\", \"_ansible_no_log\": false, \"ansible_loop_var\": \"item\", \"changed\": true, \"checksum\": \"9054fbe0b622c638224d50d20824d2ff6782e308\", \"dest\": \"/tmp/test2.txt\", \"diff\": [], \"failed\": false, \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"_original_basename\": \"test2.txt.j2\", \"attributes\": null, \"backup\": false, \"checksum\": \"9054fbe0b622c638224d50d20824d2ff6782e308\", \"content\": null, \"delimiter\": null, \"dest\": \"/tmp/test2.txt\", \"directory_mode\": null, \"follow\": false, \"force\": true, \"group\": null, \"local_follow\": null, \"mode\": null, \"owner\": null, \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670620.49-7241-225254470383476/source\", \"unsafe_writes\": false, \"validate\": null}}, \"item\": \"test2.txt\", \"md5sum\": null, \"mode\": \"0644\", \"owner\": \"root\", \"secontext\": \"unconfined_u:object_r:admin_home_t:s0\", \"size\": 6, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670620.49-7241-225254470383476/source\", \"state\": \"file\", \"uid\": 0}]}"
71
+ },
72
+ "level": "notice"
73
+ }
74
+ },
75
+ {
76
+ "log": {
77
+ "sources": {
78
+ "source": "Render one template"
79
+ },
80
+ "messages": {
81
+ "message": "{\"_ansible_no_log\": false, \"changed\": true, \"checksum\": \"41c5985fc771b6ecfe8feaa99f8fa9b77ac7d6ce\", \"dest\": \"/tmp/test3.txt\", \"diff\": [], \"failed\": false, \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"_original_basename\": \"test3.txt.j2\", \"attributes\": null, \"backup\": false, \"checksum\": \"41c5985fc771b6ecfe8feaa99f8fa9b77ac7d6ce\", \"content\": null, \"delimiter\": null, \"dest\": \"/tmp/test3.txt\", \"directory_mode\": null, \"follow\": false, \"force\": true, \"group\": null, \"local_follow\": null, \"mode\": null, \"owner\": null, \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670634.79-7306-243717749452063/source\", \"unsafe_writes\": false, \"validate\": null}}, \"md5sum\": null, \"mode\": \"0644\", \"module\": \"template\", \"owner\": \"root\", \"secontext\": \"unconfined_u:object_r:admin_home_t:s0\", \"size\": 6, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670634.79-7306-243717749452063/source\", \"state\": \"file\", \"uid\": 0}"
82
+ },
83
+ "level": "notice"
84
+ }
85
+ },
86
+ {
87
+ "log": {
88
+ "sources": {
89
+ "source": "Copy multiple local files"
90
+ },
91
+ "messages": {
92
+ "message": "{\"changed\": true, \"failed\": false, \"module\": \"copy\", \"msg\": \"All items completed\", \"results\": [{\"_ansible_item_label\": \"test4.txt\", \"_ansible_no_log\": false, \"ansible_loop_var\": \"item\", \"changed\": true, \"checksum\": \"ab2649b7e58f7e32b0c75be95d11e2979399d392\", \"dest\": \"/tmp/test4.txt\", \"diff\": [], \"failed\": false, \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"_original_basename\": \"test4.txt\", \"attributes\": null, \"backup\": false, \"checksum\": \"ab2649b7e58f7e32b0c75be95d11e2979399d392\", \"content\": null, \"delimiter\": null, \"dest\": \"/tmp/test4.txt\", \"directory_mode\": null, \"follow\": false, \"force\": true, \"group\": \"root\", \"local_follow\": null, \"mode\": 256, \"owner\": \"root\", \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670648.88-7343-91799014257533/source\", \"unsafe_writes\": false, \"validate\": null}}, \"item\": \"test4.txt\", \"md5sum\": null, \"mode\": \"0400\", \"owner\": \"root\", \"secontext\": \"unconfined_u:object_r:admin_home_t:s0\", \"size\": 6, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670648.88-7343-91799014257533/source\", \"state\": \"file\", \"uid\": 0}, {\"_ansible_item_label\": \"test5.txt\", \"_ansible_no_log\": false, \"ansible_loop_var\": \"item\", \"changed\": true, \"checksum\": \"4ea77484f3a1c7dde4c0cca2f5c40953388f19f5\", \"dest\": \"/tmp/test5.txt\", \"diff\": [], \"failed\": false, \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"_original_basename\": \"test5.txt\", \"attributes\": null, \"backup\": false, \"checksum\": \"4ea77484f3a1c7dde4c0cca2f5c40953388f19f5\", \"content\": null, \"delimiter\": null, \"dest\": \"/tmp/test5.txt\", \"directory_mode\": null, \"follow\": false, \"force\": true, \"group\": \"root\", \"local_follow\": null, \"mode\": 256, \"owner\": \"root\", \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670662.97-7343-50902792283881/source\", \"unsafe_writes\": false, \"validate\": null}}, \"item\": \"test5.txt\", \"md5sum\": null, \"mode\": \"0400\", \"owner\": \"root\", \"secontext\": \"unconfined_u:object_r:admin_home_t:s0\", \"size\": 6, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670662.97-7343-50902792283881/source\", \"state\": \"file\", \"uid\": 0}]}"
93
+ },
94
+ "level": "notice"
95
+ }
96
+ },
97
+ {
98
+ "log": {
99
+ "sources": {
100
+ "source": "Copy one local files"
101
+ },
102
+ "messages": {
103
+ "message": "{\"_ansible_no_log\": false, \"changed\": true, \"checksum\": \"ec4cddb45c3ce640bed61b3d8ab6c18e715dac78\", \"dest\": \"/tmp/test6.txt\", \"diff\": [], \"failed\": false, \"gid\": 0, \"group\": \"root\", \"invocation\": {\"module_args\": {\"_original_basename\": \"test6.txt\", \"attributes\": null, \"backup\": false, \"checksum\": \"ec4cddb45c3ce640bed61b3d8ab6c18e715dac78\", \"content\": null, \"delimiter\": null, \"dest\": \"/tmp/test6.txt\", \"directory_mode\": null, \"follow\": false, \"force\": true, \"group\": \"root\", \"local_follow\": null, \"mode\": 256, \"owner\": \"root\", \"regexp\": null, \"remote_src\": null, \"selevel\": null, \"serole\": null, \"setype\": null, \"seuser\": null, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670677.05-7408-75605497546833/source\", \"unsafe_writes\": false, \"validate\": null}}, \"md5sum\": null, \"mode\": \"0400\", \"module\": \"copy\", \"owner\": \"root\", \"secontext\": \"unconfined_u:object_r:admin_home_t:s0\", \"size\": 6, \"src\": \"/root/.ansible/tmp/ansible-tmp-1671670677.05-7408-75605497546833/source\", \"state\": \"file\", \"uid\": 0}"
104
+ },
105
+ "level": "notice"
106
+ }
107
+ },
108
+ {
109
+ "log": {
110
+ "sources": {
111
+ "source": "Restart multiple services"
112
+ },
113
+ "messages": {
114
+ "message": "{\"changed\":true,\"failed\":false,\"module\":\"service\",\"msg\":\"All items completed\",\"results\":[{\"_ansible_item_label\":\"chronyd\",\"_ansible_no_log\":false,\"ansible_loop_var\":\"item\",\"changed\":true,\"failed\":false,\"invocation\":{\"module_args\":{\"daemon_reexec\":false,\"daemon_reload\":false,\"enabled\":null,\"force\":null,\"masked\":null,\"name\":\"chronyd\",\"no_block\":false,\"scope\":null,\"state\":\"restarted\",\"user\":null}},\"item\":\"chronyd\",\"name\":\"chronyd\",\"state\":\"started\"},{\"_ansible_item_label\":\"firewalld\",\"_ansible_no_log\":false,\"ansible_loop_var\":\"item\",\"changed\":true,\"failed\":false,\"invocation\":{\"module_args\":{\"daemon_reexec\":false,\"daemon_reload\":false,\"enabled\":null,\"force\":null,\"masked\":null,\"name\":\"firewalld\",\"no_block\":false,\"scope\":null,\"state\":\"restarted\",\"user\":null}},\"item\":\"firewalld\",\"name\":\"firewalld\",\"state\":\"started\"}]}"
115
+ },
116
+ "level": "notice"
117
+ }
118
+ },
119
+ {
120
+ "log": {
121
+ "sources": {
122
+ "source": "Restart one service"
123
+ },
124
+ "messages": {
125
+ "message": "{\"_ansible_no_log\":false,\"changed\":true,\"failed\":false,\"invocation\":{\"module_args\":{\"daemon_reexec\":false,\"daemon_reload\":false,\"enabled\":null,\"force\":null,\"masked\":null,\"name\":\"chronyd\",\"no_block\":false,\"scope\":null,\"state\":\"restarted\",\"user\":null}},\"module\":\"service\",\"name\":\"chronyd\",\"state\":\"started\"}"
126
+ },
127
+ "level": "notice"
128
+ }
129
+ }
130
+ ]
131
+ }]
@@ -4,13 +4,15 @@ require 'test_plugin_helper'
4
4
 
5
5
  # Tests for the behavior of Host with roles, checks inheritance, etc
6
6
  class ConfigReportExtensionsTest < ActiveSupport::TestCase
7
- let(:example_report) do
7
+ let(:example_reports) do
8
8
  JSON.parse(File.read(ansible_fixture_file('report.json')))
9
9
  end
10
10
 
11
+ let(:example_report1) { example_reports.first }
12
+
11
13
  describe '.import' do
12
14
  it 'sets an origin for Ansible reports' do
13
- report = ConfigReport.import(example_report)
15
+ report = ConfigReport.import(example_report1)
14
16
  assert_equal 'Ansible', report.origin
15
17
  end
16
18
 
@@ -33,4 +33,64 @@ ANSIBLELOG
33
33
  ansible_module_message(log).to_s
34
34
  )
35
35
  end
36
+
37
+ test 'accepting an almost empty message' do
38
+ log_value = <<-ANSIBLELOG.strip_heredoc
39
+ {"changed": true, "failed": false, "module": "copy"}
40
+ ANSIBLELOG
41
+ message = FactoryBot.build(:message, value: log_value)
42
+ log = FactoryBot.build(:log)
43
+ log.message = message
44
+ assert_match(
45
+ /Copy/,
46
+ ansible_module_message(log).to_s
47
+ )
48
+ end
49
+
50
+ test 'FQCN module message extraction' do
51
+ log_value = <<-ANSIBLELOG.strip_heredoc
52
+ {"msg": "Nothing to do", "changed": false, "results": [], "rc": 0, "invocation": {"module_args": {"name": ["openssh"], "state": "present", "allow_downgrade": false, "autoremove": false, "bugfix": false, "disable_gpg_check": false, "disable_plugin": [], "disablerepo": [], "download_only": false, "enable_plugin": [], "enablerepo": [], "exclude": [], "installroot": "/", "install_repoquery": true, "install_weak_deps": true, "security": false, "skip_broken": false, "update_cache": false, "update_only": false, "validate_certs": true, "lock_timeout": 30, "conf_file": null, "disable_excludes": null, "download_dir": null, "list": null, "releasever": null}}, "_ansible_no_log": false, "failed": false, "module": "ansible.builtin.package"}
53
+ ANSIBLELOG
54
+ message = FactoryBot.build(:message, value: log_value)
55
+ log = FactoryBot.build(:log)
56
+ log.message = message
57
+ assert_match(
58
+ /Nothing to do/,
59
+ ansible_module_message(log).to_s
60
+ )
61
+ end
62
+
63
+ test 'accepting a censored message' do
64
+ log_value = <<-ANSIBLELOG.strip_heredoc
65
+ {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": true, "failed": false, "module": "copy"}
66
+ ANSIBLELOG
67
+ message = FactoryBot.build(:message, value: log_value)
68
+ log = FactoryBot.build(:log)
69
+ log.message = message
70
+ assert_match(
71
+ /output has been hidden/,
72
+ ansible_module_message(log).to_s
73
+ )
74
+ end
75
+
76
+ test 'module message extraction with action' do
77
+ example_report = JSON.parse(File.read(ansible_fixture_file('report.json'))).second
78
+ report = ConfigReport.import(example_report)
79
+ expected_outputs = [
80
+ 'No additional data',
81
+ ['Cron job: 0 5,2 * * * date > /dev/null (disabled: false)', 'Cron job: 0 5,2 * * * df > /dev/null (disabled: false)'],
82
+ ['Cron job: 0 5,2 * * * hostname > /dev/null (disabled: false)'],
83
+ ['Rendered template test1.txt.j2 to /tmp/test1.txt', 'Rendered template test2.txt.j2 to /tmp/test2.txt'],
84
+ ['Rendered template test3.txt.j2 to /tmp/test3.txt'],
85
+ ['Copy test4.txt to /tmp/test4.txt', 'Copy test5.txt to /tmp/test5.txt'],
86
+ ['Copy test6.txt to /tmp/test6.txt'],
87
+ ['Service chronyd started (enabled: )', 'Service firewalld started (enabled: )'],
88
+ ['Service chronyd started (enabled: )']
89
+ ]
90
+ actual_outputs = []
91
+ report.logs.each do |log|
92
+ actual_outputs << ansible_module_message(log)
93
+ end
94
+ assert_equal expected_outputs, actual_outputs
95
+ end
36
96
  end
@@ -86,12 +86,16 @@ const validateRegexp = (variable, value) => {
86
86
  };
87
87
 
88
88
  const validateList = (variable, value) => {
89
- if (variable.validatorRule.split(',').find(item => item.trim() === value)) {
89
+ let { validatorRule } = variable;
90
+ if (typeof validatorRule !== 'string') {
91
+ validatorRule = validatorRule.toString();
92
+ }
93
+ if (validatorRule.split(',').find(item => item.trim() === value)) {
90
94
  return validationSuccess;
91
95
  }
92
96
  return {
93
97
  key: 'error',
94
- msg: sprintf(__('Invalid, expected one of: %s'), variable.validatorRule),
98
+ msg: sprintf(__('Invalid, expected one of: %s'), validatorRule),
95
99
  };
96
100
  };
97
101
 
@@ -0,0 +1,151 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+ import { usePaginationOptions } from 'foremanReact/components/Pagination/PaginationHooks';
5
+
6
+ import RelativeDateTime from 'foremanReact/components/common/dates/RelativeDateTime';
7
+
8
+ import {
9
+ TableComposable,
10
+ Thead,
11
+ Tbody,
12
+ Tr,
13
+ Th,
14
+ Td,
15
+ } from '@patternfly/react-table';
16
+ import { Flex, FlexItem, Pagination } from '@patternfly/react-core';
17
+
18
+ import { decodeId } from '../../../../globalIdHelper';
19
+ import withLoading from '../../../withLoading';
20
+ <<<<<<< HEAD
21
+ import { readableCron } from './JobsTabHelper';
22
+ import {
23
+ preparePerPageOptions,
24
+ refreshPage,
25
+ } from '../../../../helpers/paginationHelper';
26
+ =======
27
+ import { readableCron, readablePurpose } from './JobsTabHelper';
28
+ >>>>>>> 5b01704 (Fixes #34458 - Show Hostgroup jobs on the Host Detail page)
29
+
30
+ const PreviousJobsTable = ({ history, totalCount, jobs, pagination }) => {
31
+ const columns = [
32
+ __('Description'),
33
+ __('Result'),
34
+ __('State'),
35
+ __('Executed at'),
36
+ __('Schedule'),
37
+ ];
38
+
39
+ const handlePerPageSelected = (event, perPage) => {
40
+ refreshPage(history, { page: 1, perPage });
41
+ };
42
+
43
+ const handlePageSelected = (event, page) => {
44
+ refreshPage(history, { ...pagination, page });
45
+ };
46
+
47
+ const perPageOptions = preparePerPageOptions(usePaginationOptions());
48
+
49
+ return (
50
+ <React.Fragment>
51
+ <h3>{__('Previously executed jobs')}</h3>
52
+ <<<<<<< HEAD
53
+ <Flex className="pf-u-pt-md">
54
+ =======
55
+ <Flex direction={{ default: 'column' }} className="pf-u-pt-md">
56
+ <FlexItem align={{ default: 'alignRight' }}>
57
+ <Pagination updateParamsByUrl itemCount={totalCount} variant="top" />
58
+ </FlexItem>
59
+ <FlexItem>
60
+ <TableComposable variant="compact">
61
+ <Thead>
62
+ <Tr>
63
+ {columns.map(col => (
64
+ <Th key={col}>{col}</Th>
65
+ ))}
66
+ </Tr>
67
+ </Thead>
68
+ <Tbody>
69
+ {jobs.map(job => (
70
+ <Tr key={job.id}>
71
+ <Td>
72
+ <a
73
+ onClick={() =>
74
+ window.tfm.nav.pushUrl(
75
+ `/job_invocations/${decodeId(job.id)}`
76
+ )
77
+ }
78
+ >
79
+ {job.description}
80
+ </a>
81
+ &nbsp;
82
+ {readablePurpose(job.recurringLogic.purpose)}
83
+ </Td>
84
+ <Td>{job.task.result}</Td>
85
+ <Td>{job.task.state}</Td>
86
+ <Td>
87
+ <RelativeDateTime date={job.startAt} />
88
+ </Td>
89
+ <Td>{readableCron(job.recurringLogic.cronLine)}</Td>
90
+ </Tr>
91
+ ))}
92
+ </Tbody>
93
+ </TableComposable>
94
+ </FlexItem>
95
+ >>>>>>> 5b01704 (Fixes #34458 - Show Hostgroup jobs on the Host Detail page)
96
+ <FlexItem align={{ default: 'alignRight' }}>
97
+ <Pagination
98
+ itemCount={totalCount}
99
+ page={pagination.page}
100
+ perPage={pagination.perPage}
101
+ onSetPage={handlePageSelected}
102
+ onPerPageSelect={handlePerPageSelected}
103
+ perPageOptions={perPageOptions}
104
+ variant="top"
105
+ />
106
+ </FlexItem>
107
+ </Flex>
108
+ <TableComposable variant="compact">
109
+ <Thead>
110
+ <Tr>
111
+ {columns.map(col => (
112
+ <Th key={col}>{col}</Th>
113
+ ))}
114
+ </Tr>
115
+ </Thead>
116
+ <Tbody>
117
+ {jobs.map(job => (
118
+ <Tr key={job.id}>
119
+ <Td>
120
+ <a
121
+ onClick={() =>
122
+ window.tfm.nav.pushUrl(
123
+ `/job_invocations/${decodeId(job.id)}`
124
+ )
125
+ }
126
+ >
127
+ {job.description}
128
+ </a>
129
+ </Td>
130
+ <Td>{job.task.result}</Td>
131
+ <Td>{job.task.state}</Td>
132
+ <Td>
133
+ <RelativeDateTime date={job.startAt} />
134
+ </Td>
135
+ <Td>{readableCron(job.recurringLogic.cronLine)}</Td>
136
+ </Tr>
137
+ ))}
138
+ </Tbody>
139
+ </TableComposable>
140
+ </React.Fragment>
141
+ );
142
+ };
143
+
144
+ PreviousJobsTable.propTypes = {
145
+ jobs: PropTypes.array.isRequired,
146
+ history: PropTypes.object.isRequired,
147
+ totalCount: PropTypes.number.isRequired,
148
+ pagination: PropTypes.object.isRequired,
149
+ };
150
+
151
+ export default withLoading(PreviousJobsTable);
@@ -88,11 +88,12 @@ SelectField.defaultProps = {
88
88
  blankLabel: '',
89
89
  };
90
90
 
91
- const pickerWithHandlers = Component => {
91
+ const pickerWithHandlers = ComponentType => {
92
92
  const Subcomponent = ({ form, field, isRequired, label, ...rest }) => {
93
93
  const { onChange, onBlur } = wrapPickerProps(field);
94
94
  const valid = shouldValidate(form, field.name);
95
95
 
96
+ const Component = ComponentType === 'date' ? DatePicker : TimePicker;
96
97
  return (
97
98
  <FormGroup
98
99
  label={label}
@@ -103,7 +104,11 @@ const pickerWithHandlers = Component => {
103
104
  >
104
105
  <Component
105
106
  aria-label={field.name}
106
- onChange={onChange}
107
+ onChange={(a, b) => {
108
+ // datepicker: onChange (event: React.FormEvent<HTMLInputElement>, value: string, date?: Date) => void
109
+ // timepicker: onChange (time: string, hour?: number, minute?: number, seconds?: number, isValid?: boolean ) => void
110
+ ComponentType === 'date' ? onChange(b, a) : onChange(a);
111
+ }}
107
112
  onBlur={onBlur}
108
113
  {...rest}
109
114
  validated={valid}
@@ -127,5 +132,5 @@ const pickerWithHandlers = Component => {
127
132
  return Subcomponent;
128
133
  };
129
134
 
130
- export const DatePickerField = pickerWithHandlers(DatePicker);
131
- export const TimePickerField = pickerWithHandlers(TimePicker);
135
+ export const DatePickerField = pickerWithHandlers('date');
136
+ export const TimePickerField = pickerWithHandlers('time');
@@ -8,4 +8,9 @@ fragment CurrentUserAttributes on User {
8
8
  name
9
9
  }
10
10
  }
11
+ usergroups {
12
+ nodes {
13
+ admin
14
+ }
15
+ }
11
16
  }
@@ -11,7 +11,10 @@ export const permissionCheck = (user, permissionsRequired) => {
11
11
  );
12
12
  }
13
13
 
14
- if (user.admin) {
14
+ if (
15
+ user.admin ||
16
+ user.usergroups.nodes.find(usergroup => usergroup.admin === true)
17
+ ) {
15
18
  return { allowed: true };
16
19
  }
17
20
 
@@ -71,6 +71,9 @@ export const userFactory = (login, permissions = []) => ({
71
71
  permissions: {
72
72
  nodes: permissions,
73
73
  },
74
+ usergroups: {
75
+ nodes: [],
76
+ },
74
77
  });
75
78
 
76
79
  export const admin = {
@@ -81,6 +84,9 @@ export const admin = {
81
84
  permissions: {
82
85
  nodes: [],
83
86
  },
87
+ usergroups: {
88
+ nodes: [],
89
+ },
84
90
  };
85
91
 
86
92
  export const intruder = userFactory('intruder', [