hybrid_platforms_conductor 32.11.1 → 32.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1115 -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 +61 -0
  87. data/docs/tutorial/01_installation.md +131 -0
  88. data/docs/tutorial/02_first_node.md +468 -0
  89. data/docs/tutorial/03_scale.md +878 -0
  90. data/docs/tutorial/04_test.md +977 -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/examples/tutorial/01_installation/my-platforms/Gemfile +3 -0
  98. data/examples/tutorial/01_installation/my-platforms/hpc_config.rb +0 -0
  99. data/examples/tutorial/02_first_node/my-platforms/Gemfile +3 -0
  100. data/examples/tutorial/02_first_node/my-platforms/hpc_config.rb +1 -0
  101. data/examples/tutorial/02_first_node/my-service-conf-repo/inventory.yaml +13 -0
  102. data/examples/tutorial/02_first_node/my-service-conf-repo/my-service.conf.erb +3 -0
  103. data/examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb +58 -0
  104. data/examples/tutorial/02_first_node/node/my-service.conf +4 -0
  105. data/examples/tutorial/03_scale/my-platforms/Gemfile +3 -0
  106. data/examples/tutorial/03_scale/my-platforms/hpc_config.rb +1 -0
  107. data/examples/tutorial/03_scale/my-platforms/my_commands.bash +2 -0
  108. data/examples/tutorial/03_scale/my-service-conf-repo/inventory.yaml +90 -0
  109. data/examples/tutorial/03_scale/my-service-conf-repo/my-service.conf.erb +3 -0
  110. data/examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb +58 -0
  111. data/examples/tutorial/03_scale/my-service-conf-repo/service_web-hello.rb +43 -0
  112. data/examples/tutorial/03_scale/node/my-service.conf +4 -0
  113. data/examples/tutorial/03_scale/web_docker_image/Dockerfile +33 -0
  114. data/examples/tutorial/03_scale/web_docker_image/hello_world.txt +1 -0
  115. data/examples/tutorial/03_scale/web_docker_image/hpc_root.key +27 -0
  116. data/examples/tutorial/03_scale/web_docker_image/hpc_root.key.pub +1 -0
  117. data/examples/tutorial/03_scale/web_docker_image/main.go +43 -0
  118. data/examples/tutorial/03_scale/web_docker_image/start.sh +7 -0
  119. data/examples/tutorial/03_scale/web_docker_image/test.bash +6 -0
  120. data/examples/tutorial/04_test/my-platforms/Gemfile +3 -0
  121. data/examples/tutorial/04_test/my-platforms/hpc_config.rb +12 -0
  122. data/examples/tutorial/04_test/my-platforms/images/debian_10/Dockerfile +13 -0
  123. data/examples/tutorial/04_test/my-platforms/my_commands.bash +2 -0
  124. data/examples/tutorial/04_test/my-service-conf-repo/inventory.yaml +100 -0
  125. data/examples/tutorial/04_test/my-service-conf-repo/my-service.conf.erb +3 -0
  126. data/examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb +58 -0
  127. data/examples/tutorial/04_test/my-service-conf-repo/service_web-hello.rb +43 -0
  128. data/examples/tutorial/04_test/node/my-service.conf +4 -0
  129. data/examples/tutorial/04_test/web_docker_image/Dockerfile +33 -0
  130. data/examples/tutorial/04_test/web_docker_image/hello_world.txt +1 -0
  131. data/examples/tutorial/04_test/web_docker_image/hpc_root.key +27 -0
  132. data/examples/tutorial/04_test/web_docker_image/hpc_root.key.pub +1 -0
  133. data/examples/tutorial/04_test/web_docker_image/main.go +43 -0
  134. data/examples/tutorial/04_test/web_docker_image/start.sh +7 -0
  135. data/examples/tutorial/04_test/web_docker_image/test.bash +6 -0
  136. data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/hosts.json +12 -0
  137. data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-gcc.bash +14 -0
  138. data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-python.bash +14 -0
  139. data/examples/tutorial/05_extend_with_plugins/dev_docker_image/Dockerfile +20 -0
  140. data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key +27 -0
  141. data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key.pub +1 -0
  142. data/examples/tutorial/05_extend_with_plugins/my-platforms/Gemfile +4 -0
  143. data/examples/tutorial/05_extend_with_plugins/my-platforms/hpc_config.rb +13 -0
  144. data/examples/tutorial/05_extend_with_plugins/my-platforms/images/debian_10/Dockerfile +13 -0
  145. data/examples/tutorial/05_extend_with_plugins/my-platforms/my_commands.bash +2 -0
  146. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/inventory.yaml +100 -0
  147. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/my-service.conf.erb +3 -0
  148. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb +58 -0
  149. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_web-hello.rb +43 -0
  150. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/platform_handler/json_bash.rb +115 -0
  151. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/report/web_report.rb +52 -0
  152. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/test/root_space.rb +44 -0
  153. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/my_hpc_plugins.gemspec +15 -0
  154. data/examples/tutorial/05_extend_with_plugins/node/my-service.conf +4 -0
  155. data/examples/tutorial/05_extend_with_plugins/web_docker_image/Dockerfile +33 -0
  156. data/examples/tutorial/05_extend_with_plugins/web_docker_image/hello_world.txt +1 -0
  157. data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key +27 -0
  158. data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key.pub +1 -0
  159. data/examples/tutorial/05_extend_with_plugins/web_docker_image/main.go +43 -0
  160. data/examples/tutorial/05_extend_with_plugins/web_docker_image/start.sh +7 -0
  161. data/examples/tutorial/05_extend_with_plugins/web_docker_image/test.bash +6 -0
  162. data/lib/hybrid_platforms_conductor/actions_executor.rb +1 -0
  163. data/lib/hybrid_platforms_conductor/deployer.rb +3 -2
  164. data/lib/hybrid_platforms_conductor/hpc_plugins/action/remote_bash.rb +29 -13
  165. data/lib/hybrid_platforms_conductor/hpc_plugins/action/scp.rb +1 -1
  166. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +98 -0
  167. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample +2 -2
  168. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +15 -4
  169. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample +5 -5
  170. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +140 -0
  171. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +6 -3
  172. data/lib/hybrid_platforms_conductor/hpc_plugins/report/templates/confluence_inventory.html.erb +1 -1
  173. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +4 -4
  174. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +1 -1
  175. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +19 -17
  176. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +3 -0
  177. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +2 -1
  178. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +2 -1
  179. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -1
  180. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +4 -3
  181. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +2 -1
  182. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +1 -1
  183. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +8 -7
  184. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +1 -1
  185. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/templates/confluence.html.erb +1 -1
  186. data/lib/hybrid_platforms_conductor/json_dumper.rb +1 -1
  187. data/lib/hybrid_platforms_conductor/platform_handler.rb +1 -1
  188. data/lib/hybrid_platforms_conductor/services_handler.rb +18 -16
  189. data/lib/hybrid_platforms_conductor/tests_runner.rb +0 -1
  190. data/lib/hybrid_platforms_conductor/topographer.rb +0 -1
  191. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  192. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +16 -0
  193. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +30 -0
  194. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +113 -0
  195. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +6 -2
  196. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +38 -1
  197. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +37 -4
  198. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +10 -0
  199. data/tools/check_md +89 -0
  200. data/tools/generate_mermaid +75 -0
  201. metadata +337 -12
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Orchestrate all the platforms with Hybrid Platforms Conductor
4
+ gem 'hybrid_platforms_conductor', path: '../..'
@@ -0,0 +1,2 @@
1
+ # Just a bare configuration.
2
+ # It should work already like this.
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Orchestrate all the platforms with Hybrid Platforms Conductor
4
+ gem 'hybrid_platforms_conductor', path: '../..'
@@ -0,0 +1,2 @@
1
+ # This configuration file just defines 1 node being localhost
2
+ yaml_inventory_platform path: '.'
@@ -0,0 +1,4 @@
1
+ ---
2
+ local:
3
+ metadata:
4
+ host_ip: 127.0.0.1
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'hybrid_platforms_conductor'
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'hybrid_platforms_conductor'
@@ -0,0 +1 @@
1
+ yaml_inventory_platform path: "#{Dir.home}/hpc_tutorial/my-service-conf-repo"
@@ -0,0 +1,13 @@
1
+ ---
2
+ local:
3
+ metadata:
4
+ # This is a simple description of the node
5
+ description: The local environment
6
+ # This node is localhost, so here we'll use the local connector, not ssh.
7
+ local_node: true
8
+ # Some other metadata, specific to this node and that can be used by later processes
9
+ service_port: 1107
10
+ service_timeout: 60
11
+ # The list of service names this node should have
12
+ services:
13
+ - my-service
@@ -0,0 +1,3 @@
1
+ service-port: <%= @service_port %>
2
+ service-timeout: <%= @service_timeout %>
3
+ service-logs: stdout
@@ -0,0 +1,58 @@
1
+ # Get the wanted content of the configuration file as a String, based on the node's metadata
2
+ #
3
+ # Parameters::
4
+ # * *node* (String): Node for which we configure our service
5
+ # Result::
6
+ # * String: The wanted content
7
+ def wanted_conf_for(node)
8
+ # We will access the node's metadata using the NodesHandler API, through the @nodes_handler object
9
+ @service_port = @nodes_handler.get_service_port_of(node)
10
+ @service_timeout = @nodes_handler.get_service_timeout_of(node)
11
+ # We use erubis to generate the configuration from our eRuby template, and return it directly
12
+ Erubis::Eruby.new(File.read("#{@platform_handler.repository_path}/my-service.conf.erb")).result(binding)
13
+ end
14
+
15
+ # Get actions to check the node's service against the wanted content
16
+ #
17
+ # Parameters::
18
+ # * *node* (String): Node on which we check the service
19
+ # Result::
20
+ # * Array< Hash<Symbol,Object> >: The list of actions
21
+ def check(node)
22
+ # We first dump the wanted content in a temporary file and then we diff it.
23
+ [
24
+ {
25
+ remote_bash: <<~EOS
26
+ cat <<EOF >/tmp/my-service.conf.wanted
27
+ #{wanted_conf_for(node)}
28
+ EOF
29
+ echo Diffs on my-service.conf:
30
+ if test -f ~/hpc_tutorial/node/my-service.conf; then
31
+ diff ~/hpc_tutorial/node/my-service.conf /tmp/my-service.conf.wanted || true
32
+ else
33
+ echo "Create file from scratch"
34
+ cat /tmp/my-service.conf.wanted
35
+ fi
36
+ EOS
37
+ }
38
+ ]
39
+ end
40
+
41
+ # Get actions to deploy the node's service against the wanted content
42
+ #
43
+ # Parameters::
44
+ # * *node* (String): Node on which we deploy the service
45
+ # Result::
46
+ # * Array< Hash<Symbol,Object> >: The list of actions
47
+ def deploy(node)
48
+ # We first check, as this will display diffs and prepare the file to be copied.
49
+ # And then we really deploy the file on our node.
50
+ check(node) + [
51
+ {
52
+ remote_bash: <<~EOS
53
+ mkdir -p ~/hpc_tutorial/node
54
+ cp /tmp/my-service.conf.wanted ~/hpc_tutorial/node/my-service.conf
55
+ EOS
56
+ }
57
+ ]
58
+ end
@@ -0,0 +1,4 @@
1
+ service-port: 1107
2
+ service-timeout: 60
3
+ service-logs: stdout
4
+
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'hybrid_platforms_conductor'
@@ -0,0 +1 @@
1
+ yaml_inventory_platform path: "#{Dir.home}/hpc_tutorial/my-service-conf-repo"
@@ -0,0 +1,2 @@
1
+ echo Hostname here is
2
+ hostname
@@ -0,0 +1,90 @@
1
+ ---
2
+ local:
3
+ metadata:
4
+ description: The local environment
5
+ local_node: true
6
+ service_port: 1107
7
+ service_timeout: 60
8
+ services:
9
+ - my-service
10
+ web1:
11
+ metadata:
12
+ description: Web service nbr 1
13
+ hostname: web1.hpc_tutorial.org
14
+ planet: Mercury
15
+ service_port: 1201
16
+ service_timeout: 60
17
+ services:
18
+ - web-hello
19
+ - my-service
20
+ web2:
21
+ metadata:
22
+ description: Web service nbr 2
23
+ hostname: web2.hpc_tutorial.org
24
+ planet: Venus
25
+ service_port: 1202
26
+ service_timeout: 60
27
+ services:
28
+ - web-hello
29
+ - my-service
30
+ web3:
31
+ metadata:
32
+ description: Web service nbr 3
33
+ hostname: web3.hpc_tutorial.org
34
+ planet: Earth
35
+ service_port: 1203
36
+ service_timeout: 60
37
+ services:
38
+ - web-hello
39
+ - my-service
40
+ web4:
41
+ metadata:
42
+ description: Web service nbr 4
43
+ hostname: web4.hpc_tutorial.org
44
+ planet: Mars
45
+ service_port: 1204
46
+ service_timeout: 60
47
+ services:
48
+ - web-hello
49
+ - my-service
50
+ web5:
51
+ metadata:
52
+ description: Web service nbr 5
53
+ hostname: web5.hpc_tutorial.org
54
+ planet: Jupiter
55
+ service_port: 1205
56
+ service_timeout: 60
57
+ services:
58
+ - web-hello
59
+ - my-service
60
+ web6:
61
+ metadata:
62
+ description: Web service nbr 6
63
+ hostname: web6.hpc_tutorial.org
64
+ services:
65
+ - web-hello
66
+ web7:
67
+ metadata:
68
+ description: Web service nbr 7
69
+ hostname: web7.hpc_tutorial.org
70
+ services:
71
+ - web-hello
72
+ web8:
73
+ metadata:
74
+ description: Web service nbr 8
75
+ hostname: web8.hpc_tutorial.org
76
+ services:
77
+ - web-hello
78
+ web9:
79
+ metadata:
80
+ description: Web service nbr 9
81
+ hostname: web9.hpc_tutorial.org
82
+ services:
83
+ - web-hello
84
+ web10:
85
+ metadata:
86
+ description: Web service nbr 10
87
+ hostname: web10.hpc_tutorial.org
88
+ # The list of service names this node should have
89
+ services:
90
+ - web-hello
@@ -0,0 +1,3 @@
1
+ service-port: <%= @service_port %>
2
+ service-timeout: <%= @service_timeout %>
3
+ service-logs: stdout
@@ -0,0 +1,58 @@
1
+ # Get the wanted content of the configuration file as a String, based on the node's metadata
2
+ #
3
+ # Parameters::
4
+ # * *node* (String): Node for which we configure our service
5
+ # Result::
6
+ # * String: The wanted content
7
+ def wanted_conf_for(node)
8
+ # We will access the node's metadata using the NodesHandler API, through the @nodes_handler object
9
+ @service_port = @nodes_handler.get_service_port_of(node)
10
+ @service_timeout = @nodes_handler.get_service_timeout_of(node)
11
+ # We use erubis to generate the configuration from our eRuby template, and return it directly
12
+ Erubis::Eruby.new(File.read("#{@platform_handler.repository_path}/my-service.conf.erb")).result(binding)
13
+ end
14
+
15
+ # Get actions to check the node's service against the wanted content
16
+ #
17
+ # Parameters::
18
+ # * *node* (String): Node on which we check the service
19
+ # Result::
20
+ # * Array< Hash<Symbol,Object> >: The list of actions
21
+ def check(node)
22
+ # We first dump the wanted content in a temporary file and then we diff it.
23
+ [
24
+ {
25
+ remote_bash: <<~EOS
26
+ cat <<EOF >/tmp/my-service.conf.wanted
27
+ #{wanted_conf_for(node)}
28
+ EOF
29
+ echo Diffs on my-service.conf:
30
+ if test -f ~/hpc_tutorial/node/my-service.conf; then
31
+ diff ~/hpc_tutorial/node/my-service.conf /tmp/my-service.conf.wanted || true
32
+ else
33
+ echo "Create file from scratch"
34
+ cat /tmp/my-service.conf.wanted
35
+ fi
36
+ EOS
37
+ }
38
+ ]
39
+ end
40
+
41
+ # Get actions to deploy the node's service against the wanted content
42
+ #
43
+ # Parameters::
44
+ # * *node* (String): Node on which we deploy the service
45
+ # Result::
46
+ # * Array< Hash<Symbol,Object> >: The list of actions
47
+ def deploy(node)
48
+ # We first check, as this will display diffs and prepare the file to be copied.
49
+ # And then we really deploy the file on our node.
50
+ check(node) + [
51
+ {
52
+ remote_bash: <<~EOS
53
+ mkdir -p ~/hpc_tutorial/node
54
+ cp /tmp/my-service.conf.wanted ~/hpc_tutorial/node/my-service.conf
55
+ EOS
56
+ }
57
+ ]
58
+ end
@@ -0,0 +1,43 @@
1
+ # Get actions to check the node's service against the wanted content
2
+ #
3
+ # Parameters::
4
+ # * *node* (String): Node on which we check the service
5
+ # Result::
6
+ # * Array< Hash<Symbol,Object> >: The list of actions
7
+ def check(node)
8
+ # We first dump the wanted content in a temporary file and then we diff it.
9
+ # We will access the node's planet, hostname and IP from its metadata using the NodesHandler API, through the @nodes_handler object
10
+ [
11
+ {
12
+ remote_bash: <<~EOS
13
+ echo 'Hello #{@nodes_handler.get_planet_of(node) || 'World'} from #{@nodes_handler.get_hostname_of(node)} (#{@nodes_handler.get_host_ip_of(node)})' >/tmp/hello_world.txt.wanted
14
+ echo Diffs on hello_world.txt:
15
+ if test -f /root/hello_world.txt; then
16
+ diff /root/hello_world.txt /tmp/hello_world.txt.wanted || true
17
+ else
18
+ echo "Create hello_world.txt from scratch"
19
+ cat /tmp/hello_world.txt.wanted
20
+ fi
21
+ EOS
22
+ }
23
+ ]
24
+ end
25
+
26
+ # Get actions to deploy the node's service against the wanted content
27
+ #
28
+ # Parameters::
29
+ # * *node* (String): Node on which we deploy the service
30
+ # Result::
31
+ # * Array< Hash<Symbol,Object> >: The list of actions
32
+ def deploy(node)
33
+ # We first check, as this will display diffs and prepare the file to be copied.
34
+ # And then we really deploy the file on our node.
35
+ check(node) + [
36
+ {
37
+ remote_bash: <<~EOS
38
+ mkdir -p ~/hpc_tutorial/node
39
+ cp /tmp/hello_world.txt.wanted /root/hello_world.txt
40
+ EOS
41
+ }
42
+ ]
43
+ end
@@ -0,0 +1,4 @@
1
+ service-port: 1107
2
+ service-timeout: 60
3
+ service-logs: stdout
4
+
@@ -0,0 +1,33 @@
1
+ # syntax=docker/dockerfile:1
2
+ # Pull the image containing Go
3
+ FROM golang:1.16.3-buster
4
+
5
+ # Install the web server
6
+ # Create the message file to be displayed by the web server
7
+ COPY hello_world.txt /root/hello_world.txt
8
+ # Copy the code
9
+ COPY main.go /codebase/src/main.go
10
+ # Build the binary
11
+ RUN cd /codebase && go build -v -o /codebase/bin/server ./src/main.go
12
+ # Set the env which will be available at runtime
13
+ ENV PORT=80
14
+ EXPOSE 80
15
+
16
+ # Install sshd
17
+ RUN apt-get update && apt-get install -y openssh-server
18
+ RUN mkdir /var/run/sshd
19
+ # Activate root login
20
+ RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
21
+ # Speed-up considerably ssh performance and avoid huge lags and timeouts without DNS
22
+ RUN sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
23
+ EXPOSE 22
24
+
25
+ # Upload our root key for key authentication of root
26
+ COPY hpc_root.key.pub /root/.ssh/authorized_keys
27
+ RUN chmod 700 /root/.ssh
28
+ RUN chmod 400 /root/.ssh/authorized_keys
29
+
30
+ # Startup script
31
+ COPY start.sh /start.sh
32
+ RUN chmod +x /start.sh
33
+ CMD ["/start.sh"]
@@ -0,0 +1,27 @@
1
+ -----BEGIN OPENSSH PRIVATE KEY-----
2
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
3
+ NhAAAAAwEAAQAAAQEAu5oVFddWtHFKA8+PnRssWieXrnMUPM8+qTdQrxoMaNacFWN+pBv3
4
+ Nj61GphCANoEPBvgcm7ltgZa1EumAZh4NJFi7AqM4Z2AFsqsvzRS1HNFRClEwr576iRkMc
5
+ ECIr0JmxeOscVcDMx0/9uFSfON7DiuStOOpIJIiQfjtFBsLFpzdfsVfZ3zc18Hxugqsbq0
6
+ t0bsTZdjRKnIYeKTSXKbF2n9b/dAf2tBtpywpun1WXQul7w1z20m9zv955k4kq3rAhSIPH
7
+ aOSE+QCXlICYqwmP2KVKCG6XEqSWjF4ujzcE7PlKIK1gsXdfum6GL23X8k8njBIjRzq6a0
8
+ Uabp65tvVQAAA8hgF2y/YBdsvwAAAAdzc2gtcnNhAAABAQC7mhUV11a0cUoDz4+dGyxaJ5
9
+ eucxQ8zz6pN1CvGgxo1pwVY36kG/c2PrUamEIA2gQ8G+BybuW2BlrUS6YBmHg0kWLsCozh
10
+ nYAWyqy/NFLUc0VEKUTCvnvqJGQxwQIivQmbF46xxVwMzHT/24VJ843sOK5K046kgkiJB+
11
+ O0UGwsWnN1+xV9nfNzXwfG6CqxurS3RuxNl2NEqchh4pNJcpsXaf1v90B/a0G2nLCm6fVZ
12
+ dC6XvDXPbSb3O/3nmTiSresCFIg8do5IT5AJeUgJirCY/YpUoIbpcSpJaMXi6PNwTs+Uog
13
+ rWCxd1+6boYvbdfyTyeMEiNHOrprRRpunrm29VAAAAAwEAAQAAAQEAj5IE7vkkvuUweqgf
14
+ RWGlWL2SJIyngT4tuzy8/7SUqKsNOoUxRxCr6ZSl7tt1L8eplALVi135aIuGeZAHVJNF8x
15
+ 0Mso4EcSmi/E5RU+cMONCawuY+XDeBB5igIT+PjdxT/KBTsRLUNmtGYwSyBf1hsNVT9ang
16
+ MWAPeOdTyQv/LRUe+O/ZKQ/h/X51BEwSXqz32RmlmZdMnDacIJ0NWdbcbAEtB4JT83S20d
17
+ bycQNOxGVmyevOGjyTXfUX6FhtYT7A7zzqNUL8UstSdajWeTZvVGd0C7Ob1kxaU3tnAwFr
18
+ 0sHTPHX7FQQFGhiU8gBZHOJ/PQzo+qqcCSsM3FcJlpVw5QAAAIAPYGXt7diWFYEhZVfj3n
19
+ KA0lX7LjQms0en4CoSkN4BELQJnaaqlTkrqN7PNL/WbmeavzDqQMk1jb9Q2+gra826THX5
20
+ GGtbFPFb9TSwBNi+zsyVURKEzqNYSw28ytKIdj98VW1qqQoolgTc5qoXG1JW5f5bEPbzUT
21
+ LXPP5j+YvuCgAAAIEA8NVJc5vXzJxbdgBxOPPHaPCAZ28V15Ggy+Bj1K/9G6FHqa/SFhy0
22
+ tCpBDNB/POX2UXCQDLteTIDodj9h2Yat6PJP9RKYCC9F5+/fU/0Y/tvD/p/uNhwEuqToex
23
+ gBUoL+r7/G3qYK13n8AKwrvb2wiYgP3aUVW7AyOier1MKt4OsAAACBAMdqmcj+5fNSTuOg
24
+ iPgGylUSIYnJ0w2jjZIaX96aat/w+SgciLhenbwpcf/9E8MDYKbXyhArdQvOgkEVogEI4s
25
+ PrFG66ogawPuRUUsuZBhm/b535EEvNAlkC8fMPVuKfOIsHJs8Cwcy7QPZSZu5pyKznpnCT
26
+ UlYGT6aB0GGoeeC/AAAAEWFkbWluQGV4YW1wbGUuY29tAQ==
27
+ -----END OPENSSH PRIVATE KEY-----
@@ -0,0 +1 @@
1
+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7mhUV11a0cUoDz4+dGyxaJ5eucxQ8zz6pN1CvGgxo1pwVY36kG/c2PrUamEIA2gQ8G+BybuW2BlrUS6YBmHg0kWLsCozhnYAWyqy/NFLUc0VEKUTCvnvqJGQxwQIivQmbF46xxVwMzHT/24VJ843sOK5K046kgkiJB+O0UGwsWnN1+xV9nfNzXwfG6CqxurS3RuxNl2NEqchh4pNJcpsXaf1v90B/a0G2nLCm6fVZdC6XvDXPbSb3O/3nmTiSresCFIg8do5IT5AJeUgJirCY/YpUoIbpcSpJaMXi6PNwTs+UogrWCxd1+6boYvbdfyTyeMEiNHOrprRRpunrm29V admin@example.com
@@ -0,0 +1,43 @@
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "io/ioutil"
6
+ "log"
7
+ "net/http"
8
+ "os"
9
+ )
10
+
11
+ const homepageEndPoint = "/"
12
+
13
+ // StartWebServer the webserver
14
+ func StartWebServer() {
15
+ http.HandleFunc(homepageEndPoint, handleHomepage)
16
+ port := os.Getenv("PORT")
17
+ if len(port) == 0 {
18
+ panic("Environment variable PORT is not set")
19
+ }
20
+
21
+ log.Printf("Starting web server to listen on endpoints [%s] and port %s",
22
+ homepageEndPoint, port)
23
+ if err := http.ListenAndServe(":"+port, nil); err != nil {
24
+ panic(err)
25
+ }
26
+ }
27
+
28
+ func handleHomepage(w http.ResponseWriter, r *http.Request) {
29
+ urlPath := r.URL.Path
30
+ log.Printf("Web request received on url path %s", urlPath)
31
+ content, content_err := ioutil.ReadFile("/root/hello_world.txt")
32
+ if content_err != nil {
33
+ fmt.Printf("Failed to read message to display, err: %s", content_err)
34
+ }
35
+ _, write_err := w.Write(content)
36
+ if write_err != nil {
37
+ fmt.Printf("Failed to write response, err: %s", write_err)
38
+ }
39
+ }
40
+
41
+ func main() {
42
+ StartWebServer()
43
+ }