hybrid_platforms_conductor 32.12.0 → 32.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1103 -0
  3. data/LICENSE.md +31 -0
  4. data/README.md +395 -0
  5. data/bin/setup +1 -1
  6. data/docs/api.md +349 -0
  7. data/docs/config_dsl.md +315 -0
  8. data/docs/executables.md +226 -0
  9. data/docs/executables/check-node.md +155 -0
  10. data/docs/executables/deploy.md +198 -0
  11. data/docs/executables/dump_nodes_json.md +110 -0
  12. data/docs/executables/free_ips.md +93 -0
  13. data/docs/executables/free_veids.md +73 -0
  14. data/docs/executables/get_impacted_nodes.md +94 -0
  15. data/docs/executables/last_deploys.md +114 -0
  16. data/docs/executables/nodes_to_deploy.md +139 -0
  17. data/docs/executables/report.md +159 -0
  18. data/docs/executables/run.md +126 -0
  19. data/docs/executables/setup.md +92 -0
  20. data/docs/executables/ssh_config.md +151 -0
  21. data/docs/executables/test.md +213 -0
  22. data/docs/executables/topograph.md +139 -0
  23. data/docs/gen/mermaid/README.md-0.png +0 -0
  24. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  25. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  26. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  27. data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
  28. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  29. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  30. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  31. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  32. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  33. data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
  34. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  35. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  36. data/docs/install.md +161 -0
  37. data/docs/plugins.md +215 -0
  38. data/docs/plugins/action/bash.md +37 -0
  39. data/docs/plugins/action/interactive.md +37 -0
  40. data/docs/plugins/action/remote_bash.md +67 -0
  41. data/docs/plugins/action/ruby.md +69 -0
  42. data/docs/plugins/action/scp.md +61 -0
  43. data/docs/plugins/cmdb/config.md +46 -0
  44. data/docs/plugins/cmdb/host_ip.md +33 -0
  45. data/docs/plugins/cmdb/host_keys.md +33 -0
  46. data/docs/plugins/cmdb/platform_handlers.md +33 -0
  47. data/docs/plugins/connector/local.md +28 -0
  48. data/docs/plugins/connector/ssh.md +95 -0
  49. data/docs/plugins/platform_handler/yaml_inventory.md +105 -0
  50. data/docs/plugins/provisioner/docker.md +27 -0
  51. data/docs/plugins/provisioner/podman.md +27 -0
  52. data/docs/plugins/provisioner/proxmox.md +115 -0
  53. data/docs/plugins/report/confluence.md +49 -0
  54. data/docs/plugins/report/mediawiki.md +28 -0
  55. data/docs/plugins/report/stdout.md +32 -0
  56. data/docs/plugins/test/bitbucket_conf.md +97 -0
  57. data/docs/plugins/test/can_be_checked.md +27 -0
  58. data/docs/plugins/test/check_deploy_and_idempotence.md +61 -0
  59. data/docs/plugins/test/check_from_scratch.md +28 -0
  60. data/docs/plugins/test/connection.md +27 -0
  61. data/docs/plugins/test/deploy_freshness.md +27 -0
  62. data/docs/plugins/test/deploy_from_scratch.md +28 -0
  63. data/docs/plugins/test/deploy_removes_root_access.md +29 -0
  64. data/docs/plugins/test/divergence.md +41 -0
  65. data/docs/plugins/test/executables.md +26 -0
  66. data/docs/plugins/test/file_system.md +49 -0
  67. data/docs/plugins/test/file_system_hdfs.md +65 -0
  68. data/docs/plugins/test/hostname.md +27 -0
  69. data/docs/plugins/test/idempotence.md +56 -0
  70. data/docs/plugins/test/ip.md +28 -0
  71. data/docs/plugins/test/jenkins_ci_conf.md +54 -0
  72. data/docs/plugins/test/jenkins_ci_masters_ok.md +54 -0
  73. data/docs/plugins/test/linear_strategy.md +26 -0
  74. data/docs/plugins/test/local_users.md +48 -0
  75. data/docs/plugins/test/mounts.md +55 -0
  76. data/docs/plugins/test/orphan_files.md +38 -0
  77. data/docs/plugins/test/ports.md +50 -0
  78. data/docs/plugins/test/private_ips.md +27 -0
  79. data/docs/plugins/test/public_ips.md +27 -0
  80. data/docs/plugins/test/spectre.md +26 -0
  81. data/docs/plugins/test/veids.md +27 -0
  82. data/docs/plugins/test/vulnerabilities.md +65 -0
  83. data/docs/plugins/test_report/confluence.md +43 -0
  84. data/docs/plugins/test_report/stdout.md +26 -0
  85. data/docs/plugins_create.md +135 -0
  86. data/docs/tutorial.md +57 -0
  87. data/docs/tutorial/01_installation.md +129 -0
  88. data/docs/tutorial/02_first_node.md +466 -0
  89. data/docs/tutorial/03_scale.md +876 -0
  90. data/docs/tutorial/04_test.md +965 -0
  91. data/docs/tutorial/05_extend_with_plugins.md +1132 -0
  92. data/examples/bare/Gemfile +4 -0
  93. data/examples/bare/hpc_config.rb +2 -0
  94. data/examples/localhost/Gemfile +4 -0
  95. data/examples/localhost/hpc_config.rb +2 -0
  96. data/examples/localhost/inventory.yaml +4 -0
  97. data/lib/hybrid_platforms_conductor/actions_executor.rb +1 -0
  98. data/lib/hybrid_platforms_conductor/deployer.rb +3 -2
  99. data/lib/hybrid_platforms_conductor/hpc_plugins/action/remote_bash.rb +29 -13
  100. data/lib/hybrid_platforms_conductor/hpc_plugins/action/scp.rb +1 -1
  101. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +98 -0
  102. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample +2 -2
  103. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +7 -3
  104. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample +5 -5
  105. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +140 -0
  106. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +5 -2
  107. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +4 -4
  108. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +1 -1
  109. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +19 -17
  110. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +3 -0
  111. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +2 -1
  112. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +2 -1
  113. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -1
  114. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +4 -3
  115. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +2 -1
  116. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +1 -1
  117. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +8 -7
  118. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +1 -1
  119. data/lib/hybrid_platforms_conductor/json_dumper.rb +1 -1
  120. data/lib/hybrid_platforms_conductor/platform_handler.rb +1 -1
  121. data/lib/hybrid_platforms_conductor/services_handler.rb +18 -16
  122. data/lib/hybrid_platforms_conductor/tests_runner.rb +0 -1
  123. data/lib/hybrid_platforms_conductor/topographer.rb +0 -1
  124. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  125. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +16 -0
  126. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +30 -0
  127. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +113 -0
  128. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +6 -2
  129. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +38 -1
  130. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +8 -8
  131. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +10 -0
  132. data/tools/check_md +89 -0
  133. data/tools/generate_mermaid +75 -0
  134. metadata +207 -12
@@ -0,0 +1,315 @@
1
+ # Configuration DSL
2
+
3
+ The DSL used in configuration files is comprised of Ruby methods that can be called directly in the main `hpc_config.rb` file.
4
+
5
+ This DSL can also be completed by plugins. Check [the plugins documentations](plugins) to know about DSL extensions brought by plugins.
6
+
7
+ # Table of Contents
8
+ * [`<platform_type>_platform`](#platform_type_platform)
9
+ * [`include_config_from`](#include_config_from)
10
+ * [`os_image`](#os_image)
11
+ * [`deployment_schedule`](#deployment_schedule)
12
+ * [`for_nodes`](#for_nodes)
13
+ * [`hybrid_platforms_dir`](#hybrid_platforms_dir)
14
+ * [`tests_provisioner`](#tests_provisioner)
15
+ * [`expect_tests_to_fail`](#expect_tests_to_fail)
16
+ * [`retry_deploy_for_errors_on_stdout`](#retry_deploy_for_errors_on_stdout)
17
+ * [`retry_deploy_for_errors_on_stderr`](#retry_deploy_for_errors_on_stderr)
18
+ * [`packaging_timeout`](#packaging_timeout)
19
+ * [`master_cmdbs`](#master_cmdbs)
20
+ * [`sudo_for`](#sudo_for)
21
+
22
+ <a name="platform_type_platform"></a>
23
+ ## `<platform_type>_platform`
24
+
25
+ Declare a new platform of type `<platform_type>`, providing either a local path to it (using `path: '/path/to/files'`) or a git repository to it (using `git: 'git_url'`). The possible platform types are the names of the [`platform_handler` plugins](plugins.md#platform_handler).
26
+
27
+ Git branches can also be specified using `branch: 'branch_name'`.
28
+ An optional code block taking the local repository path as parameter can also be specified to add configuration that is specific to this platform.
29
+
30
+ Examples:
31
+ ```ruby
32
+ # Declare a platform of type Chef, located in a distant git repository
33
+ chef_platform git: 'https://my-git.domain.com/project/my-chef-repo.git'
34
+
35
+ # Declare a platform located in a local path
36
+ chef_platform path: '/path/to/my-chef-repo'
37
+
38
+ # Declare a platform from a git branch, and apply some configuration to it
39
+ chef_platform(
40
+ git: 'https://my-git.domain.com/project/my-chef-repo.git',
41
+ branch: 'my-branch'
42
+ ) do |path|
43
+ # Here path will be a local path containing a checkout of the branch my-branch of the git repo.
44
+
45
+ # We can use that to check for the repo itself before using it.
46
+ raise 'Missing Chef file' unless File.exist?("#{path}/solo.rb")
47
+
48
+ # And we can use other DSL methods that would apply only to this platform
49
+ expect_tests_to_fail [:idempotence], 'Idempotence tests should fail for nodes belonging to this platform'
50
+ end
51
+ ```
52
+
53
+ <a name="include_config_from"></a>
54
+ ## `include_config_from`
55
+
56
+ Include another DSL configuration file.
57
+ Takes the file path as parameter.
58
+ Useful to better organize your configuration files, and move the platform-specific configuration files within platform repositories to avoid having dependencies between your repositories.
59
+
60
+ Examples:
61
+ ```ruby
62
+ # Include a global config file
63
+ include_config_from './my_confs/security.rb'
64
+
65
+ chef_platform(git: 'https://my-git.domain.com/project/my-chef-repo.git') do |path|
66
+ # Include a config file in a platform repository
67
+ include_config_from "#{path}/chef-config.rb"
68
+ end
69
+ ```
70
+
71
+ <a name="os_image"></a>
72
+ ## `os_image`
73
+
74
+ Declare a new OS image, with its corresponding path.
75
+
76
+ An OS image can be used by some processes to adapt to differences based on OS (for example Windows, Debian, CentOS 7, CentOS 8...).
77
+ Example of usages:
78
+ * Get a Dockerfile test image
79
+ * Install packages differently (`apt`, `yum`...)
80
+
81
+ Any node from any platform can define its OS using the `image` metadata. This should be a name referenced using this DSL.
82
+
83
+ `os_image` takes 2 parameters: its name (as a Symbol) and its directory path (as a String).
84
+
85
+ Examples:
86
+ ```ruby
87
+ os_image :centos_7, '/path/to/images/centos_7'
88
+ # Here we should have a Dockerfile /path/to/images/centos_7/Dockerfile for any Docker-based process that needs a test image to be provisioned.
89
+ # Any node having the image metadata set to centos_7 will use this Dockerfile.
90
+ ```
91
+
92
+ <a name="deployment_schedule"></a>
93
+ ## `deployment_schedule`
94
+
95
+ The `deployment_schedule` method defines a schedule to be applied for regular nodes deployment. This schedule is then used by the [`nodes_to_deploy` executable](executables/nodes_to_deploy.md) to know which nodes should be deployed at a given time.
96
+ Takes an [`IceCube::Schedule` object](https://github.com/seejohnrun/ice_cube) as raw parameter but the configuration DSL lets you use some helpers that generate those objects for you:
97
+ * **`daily_at`**: This helper generates a daily schedule. It takes the following parameters:
98
+ * **time** (`String`): Parsable UTC time (like '14:10:50') at which the schedule starts.
99
+ * **duration** (`Integer`): Number of seconds for the schedule duration [default: 3000].
100
+ * **`weekly_at`**: This helper generates a weekly schedule. It takes the following parameters:
101
+ * **days** (`Symbol` or `Array<Symbol>`): Day name (or list of day names) on which the schedule applies. See [IceCube documentation](https://github.com/seejohnrun/ice_cube) for precise day names (`:monday`, `:tuesday`...).
102
+ * **time** (`String`): Parsable UTC time (like '14:10:50') at which the schedule starts.
103
+ * **duration** (`Integer`): Number of seconds for the schedule duration [default: 3000].
104
+
105
+ Can be applied to subset of nodes using the [`for_nodes` DSL method](#for_nodes).
106
+
107
+ Examples:
108
+ ```ruby
109
+ # Deploy everything every day at 4am
110
+ deployment_schedule(daily_at('04:00:00'))
111
+
112
+ # And also deploy production every week on sundays during the morning only (4 hours starting at 8am)
113
+ for_nodes('/prd/') do
114
+ deployment_schedule(weekly_at(:sunday, '08:00:00', duration: 4 * 3600))
115
+ end
116
+ ```
117
+
118
+ <a name="for_nodes"></a>
119
+ ## `for_nodes`
120
+
121
+ The `for_nodes` lets you open a scope in the configuration in which DSL methods apply to a subset of nodes. Scopes can be stacked, and always restrict the nodes it applies to, by doing intersection of the stacking subsets.
122
+ Takes a list of nodes selectors as parameter. Each nodes selector can be the following:
123
+ * `String`: Node name, or a node regexp if enclosed within '/' character (ex: `'/.+worker.+/'`)
124
+ * `Hash<Symbol,Object>`: More complete information that can contain the following keys:
125
+ * **all** (`Boolean`): If true, specify that we want all known nodes.
126
+ * **list** (`String`): Name of a nodes list.
127
+ * **platform** (`String`): Name of a platform containing nodes.
128
+ * **service** (`String`): Name of a service implemented by nodes.
129
+ * **git_diff** (`Hash<Symbol,Object>`): Info about a git diff that impacts nodes:
130
+ * **platform** (`String`): Name of the platform on which checking the git diff
131
+ * **from_commit** (`String`): Commit ID to check from [default: 'master']
132
+ * **to_commit** (`String` or `nil`): Commit ID to check to, or nil for currently checked-out files [default: nil]
133
+ * **smallest_set** (`Boolean`): Smallest set of impacted nodes? [default: false]
134
+
135
+ Examples:
136
+ ```ruby
137
+ # Set deployment schedule of test nodes at 4am
138
+ for_nodes('/tst.*/') do
139
+ deployment_schedule(daily_at('04:00:00'))
140
+ end
141
+
142
+ # Set deployment schedule of nodes implementing the firewall and web_server services at 5am
143
+ for_nodes [
144
+ { service: 'firewall' },
145
+ { service: 'web_server' }
146
+ ] do
147
+ deployment_schedule(daily_at('05:00:00'))
148
+ # Among them make sure the main firewall node is redeployed at 6am
149
+ for_nodes('prd-main-firewall') do
150
+ deployment_schedule(daily_at('06:00:00'))
151
+ end
152
+ end
153
+ ```
154
+
155
+ <a name="hybrid_platforms_dir"></a>
156
+ ## `hybrid_platforms_dir`
157
+
158
+ Get the directory in which the `hpc_config.rb` file is stored.
159
+
160
+ This can be useful in case the configuration needs to access files based on the main configuration path.
161
+
162
+ Examples:
163
+ ```ruby
164
+ # We have our images paths in the same directory storing hpc_config.rb
165
+ os_image :centos_7, "#{hybrid_platforms_dir}/images/centos_7"
166
+ ```
167
+
168
+ <a name="tests_provisioner"></a>
169
+ ## `tests_provisioner`
170
+
171
+ Specify which provisioner should be used when tests need to provision a test container.
172
+ Takes a Symbol as parameter, being the name of the provisioner.
173
+ Possible values are names of [`provisioner` plugins](plugins.md#provisioner). Defaults to `docker`.
174
+
175
+ Examples:
176
+ ```ruby
177
+ # For our test containers we rely on a Proxmox cluster
178
+ tests_provisioner :proxmox
179
+ ```
180
+
181
+ <a name="expect_tests_to_fail"></a>
182
+ ## `expect_tests_to_fail`
183
+
184
+ Inform the tests reports that some tests are expected to be failing.
185
+ This can be useful when tests are failing for temporary reasons or when technical debt is accumulating but we still want to track it.
186
+ Takes 2 parameters:
187
+ * **tests** (`Symbol` or `Array<Symbol>`): Test name (or list of test names) that are expected to fail. Names are [`test` plugins](plugins.md#test)'s names.
188
+ * **reason** (`String`): Descriptive reason for the expected failure. Used in logging only.
189
+
190
+ Can be applied to subset of nodes using the [`for_nodes` DSL method](#for_nodes).
191
+
192
+ Examples:
193
+ ```ruby
194
+ # Bitbucket is currently down, so tests are failing
195
+ expect_tests_to_fail :bitbucket_conf, 'Our Bitbucket server is down.'
196
+
197
+ # Test nodes are not yet patched against Spectre variants
198
+ for_nodes('/tst/') do
199
+ expect_tests_to_fail :spectre, 'Test nodes are not patched yet. See ticket PRJ-455'
200
+ end
201
+ ```
202
+
203
+ <a name="retry_deploy_for_errors_on_stdout"></a>
204
+ ## `retry_deploy_for_errors_on_stdout`
205
+
206
+ `retry_deploy_for_errors_on_stdout` lets you define some rules matching deployment logs to detect non-deterministic errors that can be retried.
207
+ It can happen that deployment fails for an undeterministic reason (network hickups, DNS temporarily down...) and you want to retry it. In this case this method lets you define some pattern-matching rules on a failed deployment stdout that if matched will trigger a subsequent deployment.
208
+ Takes a list of (or a single) rules as parameter. Each rule can be:
209
+ * `String`: An exact match
210
+ * `Regexp`: A regular expression match
211
+
212
+ Can be applied to subset of nodes using the [`for_nodes` DSL method](#for_nodes).
213
+
214
+ Examples:
215
+ ```ruby
216
+ # When Ansible fails because of SSH hickups, retry
217
+ retry_deploy_for_errors_on_stdout(/FAILED: .* SSH connection failed/)
218
+
219
+ # Test nodes have sometimes DNS issues
220
+ for_nodes('/tst/') do
221
+ retry_deploy_for_errors_on_stdout [
222
+ 'DNS resolution failed',
223
+ 'DNS unknown error',
224
+ /Unable to query DNS server .*/
225
+ ]
226
+ end
227
+ ```
228
+
229
+ <a name="retry_deploy_for_errors_on_stderr"></a>
230
+ ## `retry_deploy_for_errors_on_stderr`
231
+
232
+ `retry_deploy_for_errors_on_stderr` lets you define some rules matching deployment logs from stderr to detect non-deterministic errors that can be retried.
233
+ It can happen that deployment fails for an undeterministic reason (network hickups, DNS temporarily down...) and you want to retry it. In this case this method lets you define some pattern-matching rules on a failed deployment stdout that if matched will trigger a subsequent deployment.
234
+ Takes a list of (or a single) rules as parameter. Each rule can be:
235
+ * `String`: An exact match
236
+ * `Regexp`: A regular expression match
237
+
238
+ Can be applied to subset of nodes using the [`for_nodes` DSL method](#for_nodes).
239
+
240
+ Examples:
241
+ ```ruby
242
+ # When Ansible fails because of SSH hickups, retry
243
+ retry_deploy_for_errors_on_stderr(/FAILED: .* SSH connection failed/)
244
+
245
+ # Test nodes have sometimes DNS issues
246
+ for_nodes('/tst/') do
247
+ retry_deploy_for_errors_on_stderr [
248
+ 'DNS resolution failed',
249
+ 'DNS unknown error',
250
+ /Unable to query DNS server .*/
251
+ ]
252
+ end
253
+ ```
254
+
255
+ <a name="packaging_timeout"></a>
256
+ ## `packaging_timeout`
257
+
258
+ `packaging_timeout` defines the timeout to package a platform during deployment. Defaults to 60.
259
+ Takes the timeout (in seconds) as an `Integer` parameter.
260
+
261
+ Examples:
262
+ ```ruby
263
+ # Some packaging are downloading a lot of stuff for a few minutes, so timeout after 10 minutes.
264
+ packaging_timeout 600
265
+ ```
266
+
267
+ <a name="master_cmdbs"></a>
268
+ ## `master_cmdbs`
269
+
270
+ `master_cmdbs` is a method that helps in resolving metadata conflicts between different CMDB.
271
+ Depending on the context and environments, some metadata conflicts might be unacceptable (like IP conflicts) and others might be mergeable (like services definitions).
272
+ `master_cmdbs` takes a hash of CMDB names (taken as names of [`cmdb` plugins](plugins.md#cmdb)), and the corresponding metadata identifiers (as `Array<Symbol>` or `Symbol`) for which this CMDB is considered the authority in case of conflicts.
273
+
274
+ Can be applied to subset of nodes using the [`for_nodes` DSL method](#for_nodes).
275
+
276
+ Examples:
277
+ ```ruby
278
+ master_cmdbs(
279
+ # The host_ip CMDB is the authority to discover host IPs - don't rely on other sources like config or platforms inventory.
280
+ host_ip: :host_ip,
281
+ # The platform_handler CMDB is the authority to discover nodes description and OS images
282
+ platform_handler: %i[description image]
283
+ )
284
+ ```
285
+
286
+ <a name="sudo_for"></a>
287
+ ## `sudo_for`
288
+
289
+ `sudo_for` provides a way to transform sudo commands for some nodes or users.
290
+ This is useful to adapt on environments on which the escalation of privileges is not as simple as using `sudo <cmd>`, or when `root` is not accessible via `sudo`.
291
+ This is used by any Hybrid Platforms Conductor process that needs to perform some [`remote_bash` actions](plugins/action/remote_bash.md) using sudo.
292
+ Takes a code block as parameter that has the following signature:
293
+ * Parameters:
294
+ * **user** (`String`): User for which we want sudo
295
+ * Result:
296
+ * `String`: Corresponding sudo string
297
+
298
+ Can be applied to subset of nodes using the [`for_nodes` DSL method](#for_nodes).
299
+
300
+ Examples:
301
+ ```ruby
302
+ sudo_for do |user|
303
+ # Production users have to first sudo through a service user associated to them to gain root privilege
304
+ if user =~ /^prd_(.*)/
305
+ "sudo -u svc_#{$1} sudo"
306
+ else
307
+ 'sudo'
308
+ end
309
+ end
310
+
311
+ # Our gateways have a sudo alias
312
+ for_nodes({ service: 'gateway' }) do
313
+ sudo_for { |_user| 'aliased_sudo' }
314
+ end
315
+ ```
@@ -0,0 +1,226 @@
1
+ # Executables
2
+
3
+ Here is the list of executables that come bundled with the Hybrid Platforms Conductor, along with their description.
4
+
5
+ You can check the common command line options [at the end of this document](#common_options).
6
+
7
+ # Table of Contents
8
+ * [`report`](executables/report.md)
9
+ * [`run`](executables/run.md)
10
+ * [`check-node`](executables/check-node.md)
11
+ * [`deploy`](executables/deploy.md)
12
+ * [`ssh_config`](executables/ssh_config.md)
13
+ * [`nodes_to_deploy`](executables/nodes_to_deploy.md)
14
+ * [`last_deploys`](executables/last_deploys.md)
15
+ * [`get_impacted_nodes`](executables/get_impacted_nodes.md)
16
+ * [`test`](executables/test.md)
17
+ * [`setup`](executables/setup.md)
18
+ * [`free_ips`](executables/free_ips.md)
19
+ * [`free_veids`](executables/free_veids.md)
20
+ * [`dump_nodes_json`](executables/dump_nodes_json.md)
21
+ * [`topograph`](executables/topograph.md)
22
+ * [Common options](#common_options)
23
+
24
+ <a name="common_options"></a>
25
+ # Common command line options
26
+
27
+ Most of the tools share a set of common command line options. The shared command line options are grouped by functionality the tool is using.
28
+ This section lists them all and how they affect the tools' behaviour.
29
+
30
+ ## Nodes Handler options
31
+
32
+ The nodes handler options add functionality about nodes information.
33
+
34
+ ```
35
+ Nodes handler options:
36
+ -o, --show-nodes Display the list of possible nodes and exit
37
+ ```
38
+
39
+ * `--show-nodes`: Display the list of known nodes, nodes lists, platforms, services, description... and exit.
40
+
41
+ The following metadata is being used to display nodes' information:
42
+
43
+ | Metadata | Type | Usage
44
+ | --- | --- | --- |
45
+ | `description` | `String` | Node's description |
46
+ | `host_ip` | `String` | Node's IP |
47
+ | `hostname` | `String` | Node's hostname |
48
+ | `private_ips` | `Array<String>` | List of a node's private IPs |
49
+ | `services` | `Array<String>` | List of services attached to a node |
50
+
51
+ ## Nodes selection options
52
+
53
+ The nodes selection options are used to select a set of nodes that the tool needs as input.
54
+
55
+ ```
56
+ Nodes selection options:
57
+ -a, --all-nodes Select all nodes
58
+ -b, --nodes-platform PLATFORM Select nodes belonging to a given platform name. Available platforms are: ansible-repo, chef-repo (can be used several times)
59
+ -l, --nodes-list LIST Select nodes defined in a nodes list (can be used several times)
60
+ -n, --node NODE Select a specific node. Can be a regular expression to select several nodes if used with enclosing "/" characters. (can be used several times).
61
+ -r, --nodes-service SERVICE Select nodes implementing a given service (can be used several times)
62
+ --nodes-git-impact GIT_IMPACT
63
+ Select nodes impacted by a git diff from a platform (can be used several times).
64
+ GIT_IMPACT has the format PLATFORM:FROM_COMMIT:TO_COMMIT:FLAGS
65
+ * PLATFORM: Name of the platform to check git diff from. Available platforms are: ansible-repo, chef-repo
66
+ * FROM_COMMIT: Commit ID or refspec from which we perform the diff. If ommitted, defaults to master
67
+ * TO_COMMIT: Commit ID ot refspec to which we perform the diff. If ommitted, defaults to the currently checked-out files
68
+ * FLAGS: Extra comma-separated flags. The following flags are supported:
69
+ - min: If specified then each impacted service will select only 1 node implementing this service. If not specified then all nodes implementing the impacted services will be selected.
70
+ ```
71
+
72
+ * `--all-nodes`: Select all the known nodes.
73
+ * `--nodes-platform PLATFORM`: Specify the name of a platform as a selector. Can be useful to only perform checks of nodes of a given repository after merging a PR on this repository.
74
+ * `--nodes-list LIST`: Specify a hosts list name as selector. Hosts list are a named group of hosts, and are defined by each platform if they make sense. For example all the nodes belonging to the same cluster could be part of a nodes list.
75
+ * `--node NODE`: Select a single node. A regular expression can also be used when `NODE` is enclosed with `/` character (the regular expression grammar is [the Ruby one](http://ruby-doc.org/core-2.5.0/Regexp.html)). Examples: `--node my_node_1`, `--node /my_node_.+/`.
76
+ * `--nodes-service SERVICE`: Select all nodes that implement a given service.
77
+ * `--nodes-git-impact GIT_IMPACT`: Select nodes that are impacted by a git diff on a platform. 2 commit ids or refspecs can be specified for the diff. Examples: `--nodes-git-impact chef-repo::my_branch` will select all nodes that are impacted by the diffs made between `my_branch` and `master` on the git repository belong to the `chef-repo` platform.
78
+
79
+ The following metadata is being used by some selectors:
80
+
81
+ | Metadata | Type | Usage
82
+ | --- | --- | --- |
83
+ | `services` | `Array<String>` | List of services attached to a node, used to retrieve nodes selected by a service |
84
+
85
+ ## Command Runner options
86
+
87
+ The Command Runner options are used to drive how commands are executed.
88
+
89
+ ```
90
+ Command runner options:
91
+ -s, --show-commands Display the commands that would be run instead of running them
92
+ ```
93
+
94
+ * `--show-commands`: Display the commands the tool would execute, without executing them. Useful to understand or debug the tool's behaviour.
95
+
96
+ ## Actions Executor options
97
+
98
+ The Actions Executor options are used to drive how actions are executed.
99
+
100
+ ```
101
+ Actions Executor options:
102
+ -m, --max-threads NBR Set the number of threads to use for concurrent queries (defaults to 16)
103
+ ```
104
+
105
+ * `--max-threads NBR`: Specify the maximal number of threads to use when concurrent execution is performed.
106
+
107
+ ## Connector SSH options
108
+
109
+ The SSH connector options are used to drive how SSH connections are handled.
110
+
111
+ ```
112
+ Connector ssh options:
113
+ -g, --ssh-gateway-user USER Name of the gateway user to be used by the gateways. Can also be set from environment variable hpc_ssh_gateway_user. Defaults to ubradm.
114
+ -j, --ssh-no-control-master If used, don't create SSH control masters for connections.
115
+ -q, --ssh-no-host-key-checking If used, don't check for SSH host keys.
116
+ -u, --ssh-user USER Name of user to be used in SSH connections (defaults to hpc_ssh_user or USER environment variables)
117
+ -w, --password If used, then expect SSH connections to ask for a password.
118
+ -y GATEWAYS_CONF, Name of the gateways configuration to be used. Can also be set from environment variable hpc_ssh_gateways_conf.
119
+ --ssh-gateways-conf
120
+ ```
121
+
122
+ * `--ssh-gateway-user USER`: Specify the user to be used through the gateway accessing the nodes.
123
+ * `--ssh-no-control-master`: If specified, don't use an SSH control master: it will open/close an SSH connection for every command it needs to run.
124
+ * `--ssh-no-host-key-checking`: If specified, make sure SSH connections don't check for host keys.
125
+ * `--ssh-user USER`: Specify the user to be used on the node being accessed by the tool. It is recommended to set the default value of this option in the `hpc_ssh_user` environment variable. If both this option and the `hpc_ssh_user` variables are omitted, then the `USER` environment variable is used.
126
+ * `--password`: When specified, then don't use `-o BatchMode=yes` on SSH commands so that if connection needs a password it will be asked. Useful to deploy on accounts not having key authentication yet.
127
+ * `--ssh-gateways-conf GATEWAYS_CONF`: Specify the gateway configuration name to be used. Gateway configurations are defined in the platforms definition file (`./hpc_config.rb`). It is recommended to set the default value of this option in the `hpc_ssh_gateways_conf` environment variable.
128
+
129
+ ## Deployer options
130
+
131
+ The Deployer options are used to drive a deployment (be it in why-run mode or not).
132
+
133
+ ```
134
+ Deployer options:
135
+ -e, --secrets SECRETS_LOCATION Specify a secrets location. Can be specified several times. Location can be:
136
+ * Local path to a JSON file
137
+ * URL of the form http[s]://<url>:<secret_id> to get a secret JSON file from a Thycotic Secret Server at the given URL.
138
+ -p, --parallel Execute the commands in parallel (put the standard output in files <hybrid-platforms-dir>/run_logs/*.stdout)
139
+ -t, --timeout SECS Timeout in seconds to wait for each chef run. Only used in why-run mode. (defaults to no timeout)
140
+ -W, --why-run Use the why-run mode to see what would be the result of the deploy instead of deploying it for real.
141
+ --retries-on-error NBR Number of retries in case of non-deterministic errors (defaults to 0)
142
+ ```
143
+
144
+ * `--secrets SECRETS_LOCATION`: Specify a JSON file storing secrets that can be used by the deployment process. Secrets are values that are needed for deployment but that should not be part of the platforms repositories (such as passwords, API keys, SSL certificates...).
145
+ The location can be:
146
+ * A local file path (for example /path/to/file.json).
147
+ * A Thycotic Secret Server URL followed by a secret id (for example https://portal.muc.msp.my_company.net/SecretServer:8845).
148
+ * `--parallel`: Specify that the deployment process should perform concurrently on the different nodes it has to deploy to.
149
+ * `--timeout SECS`: Specify the timeout (in seconds) to apply while deploying. This can be set only in why-run mode.
150
+ * `--why-run`: Specify the why-run mode. The why-run mode is used to simulate a deployment on the nodes, and report what a real deployment would have changed on the node.
151
+ * `--retries-on-error NBR`: Specify the number of retries deploys can do in case of non-deterministic errors.
152
+ Non-deterministic errors are matched using a set of strings or regular expressions that can be configured in the `hpc_config.rb` file of any platform, using the `retry_deploy_for_errors_on_stdout` and `retry_deploy_for_errors_on_stderr` properties:
153
+ For example:
154
+ ```ruby
155
+ retry_deploy_for_errors_on_stdout [
156
+ 'This is a raw string error that will be matched against stdout',
157
+ /This is a regexp match ending with.* error/
158
+ ]
159
+ retry_deploy_for_errors_on_stderr [
160
+ 'This is a raw string error that will be matched against stderr'
161
+ ]
162
+ ```
163
+
164
+ ## JSON dump options
165
+
166
+ The JSON dump options drive the way nodes' JSON information is being dumped.
167
+
168
+ ```
169
+ JSON dump options:
170
+ -k, --skip-run Skip the actual gathering of dumps in run_logs. If set, the current run_logs content will be used.
171
+ -j, --json-dir DIRECTORY Specify the output directory in which JSON files are being written. Defaults to nodes_json.
172
+ ```
173
+
174
+ * `--skip-run`: Don't fetch the information from the nodes themselves, but use the previous output from the `run_logs` directory. Useful if executing the command several times.
175
+ * `--json-dir DIRECTORY`: Specify the name of the directory where JSON files will be written.
176
+
177
+ ## Topographer options
178
+
179
+ The Topographer options drive the way the topographer works. The Topographer is used to manipulate and dump the topology off the platforms.
180
+
181
+ ```
182
+ Topographer options:
183
+ -F, --from HOSTS_OPTIONS Specify options for the set of nodes to start from (enclose them with ""). Default: all nodes. HOSTS_OPTIONS follows the following:
184
+ -a, --all-nodes Select all nodes
185
+ -b, --nodes-platform PLATFORM Select nodes belonging to a given platform name. Available platforms are: ansible-repo, chef-repo (can be used several times)
186
+ -l, --nodes-list LIST Select hosts defined in a nodes list (can be used several times)
187
+ -n, --node NODE Select a specific node. Can be a regular expression to select several nodes if used with enclosing "/" characters. (can be used several times).
188
+ -k, --skip-run Skip the actual gathering of JSON node files. If set, the current files in nodes_json will be used.
189
+ -p, --output FORMAT:FILE_NAME Specify a format and file name. Can be used several times. FORMAT can be one of graphviz, json, svg. Ex.: graphviz:graph.gv
190
+ -T, --to HOSTS_OPTIONS Specify options for the set of nodes to get to (enclose them with ""). Default: all nodes. HOSTS_OPTIONS follows the following:
191
+ -a, --all-nodes Select all nodes
192
+ -b, --nodes-platform PLATFORM Select nodes belonging to a given platform name. Available platforms are: ansible-repo, chef-repo (can be used several times)
193
+ -l, --nodes-list LIST Select hosts defined in a nodes list (can be used several times)
194
+ -n, --node NODE Select a specific node. Can be a regular expression to select several nodes if used with enclosing "/" characters. (can be used several times).
195
+ ```
196
+
197
+ * `--from HOSTS_OPTIONS`: Specify the set of source nodes that we want to graph from.
198
+ * `--skip-run`: Don't fetch the information from the nodes themselves, but use the previous output from the `nodes_json` directory (that can be used as an output of the `dump_nodes_json` tool). Useful if executing the command several times.
199
+ * `--output FORMAT:FILE_NAME`: Specify the format and file name in which we want to output the topology graph.
200
+ * `--to HOSTS_OPTIONS`: Specify the set of destination nodes that we want to graph to.
201
+
202
+ ## Test Runner options
203
+
204
+ Test Runner options are used to drive the running of tests.
205
+
206
+ ```
207
+ Tests runner options:
208
+ -i, --tests-list FILE_NAME Specify a tests file name. The file should contain a list of tests name (1 per line). Can be used several times.
209
+ -k, --skip-run Skip running the check-node commands for real, and just analyze existing run logs.
210
+ -r, --report REPORT Specify a report name. Can be used several times. Can be all for all reports. Possible values: confluence, stdout (defaults to stdout).
211
+ -t, --test TEST Specify a test name. Can be used several times. Can be all for all tests. Possible values: ansible_repo_molecule_cdh_admins, ansible_repo_molecule_cdh_datanodes, ansible_repo_molecule_cdh_db, ansible_repo_molecule_cdh_gateways, ansible_repo_molecule_cdh_services, ansible_repo_molecule_common, ansible_repo_molecule_data_gateway, ansible_repo_molecule_dev_servers, ansible_repo_molecule_ds_servers, ansible_repo_molecule_dsnodes, ansible_repo_molecule_import_gateway, ansible_repo_molecule_notebooks, ansible_repo_molecule_tnz_data_gateway, bitbucket_conf, can_be_checked, check_from_scratch, chef_executables, chef_success, chef_woulds, connection, deploy_freshness, deploy_from_scratch, deploy_removes_root_access, executables, food_critic, group_ids, hostname, idempotence, ip, jenkins_ci_conf, jenkins_ci_masters_ok, linear_strategy, obsolete_home_dirs, obsolete_users, orphan_files, private_ips, public_ips, rubocop, spectre, unused_files, unused_node_attributes, unused_recipes, unused_templates, unused_roles, unused_users, user_ids, users_without_roles, veids (defaults to all).
212
+ --max-threads-connections NBR_THREADS
213
+ Specify the max number of threads to parallelize tests connecting on nodes (defaults to 64).
214
+ --max-threads-nodes NBR_THREADS
215
+ Specify the max number of threads to parallelize tests at node level (defaults to 8).
216
+ --max-threads-platforms NBR_THREADS
217
+ Specify the max number of threads to parallelize tests at platform level (defaults to 8).
218
+ ```
219
+
220
+ * `--report REPORT_NAME`: Specify which report plugin to use.
221
+ * `--skip-run`: Don't fetch the information from the nodes themselves, but use the previous output from the `run_logs` directory. Useful if executing the command several times.
222
+ * `--test TEST_NAME`: Specify the test to be performed.
223
+ * `--tests-list FILE_NAME`: Give a file containing a list of tests names. The file can also containg comment lines starting with `#`.
224
+ * `--max-threads-connections NBR_THREADS`: Make sure that there won't be more than `NBR_THREADS` simultaneous connections to nodes.
225
+ * `--max-threads-nodes NBR_THREADS`: Make sure that there won't be more than `NBR_THREADS` simultaneous tests run in parallel at node level. Those include Docker tests.
226
+ * `--max-threads-platforms NBR_THREADS`: Make sure that there won't be more than `NBR_THREADS` simultaneous tests run in parallel at platform level. Those include Molecule, linter tests...