hybrid_platforms_conductor 32.13.0 → 32.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1 -1
  4. data/docs/executables/check-node.md +1 -1
  5. data/docs/executables/deploy.md +1 -1
  6. data/docs/executables/free_ips.md +1 -1
  7. data/docs/executables/free_veids.md +1 -1
  8. data/docs/executables/get_impacted_nodes.md +1 -1
  9. data/docs/executables/last_deploys.md +1 -1
  10. data/docs/executables/nodes_to_deploy.md +1 -1
  11. data/docs/executables/report.md +1 -1
  12. data/docs/executables/run.md +1 -1
  13. data/docs/executables/setup.md +1 -1
  14. data/docs/executables/ssh_config.md +1 -1
  15. data/docs/executables/test.md +1 -1
  16. data/docs/tutorial.md +4 -0
  17. data/docs/tutorial/04_test.md +12 -2
  18. data/docs/tutorial/05_extend_with_plugins.md +3 -5
  19. data/examples/tutorial/01_installation/my-platforms/Gemfile +3 -0
  20. data/examples/tutorial/01_installation/my-platforms/hpc_config.rb +0 -0
  21. data/examples/tutorial/02_first_node/my-platforms/Gemfile +3 -0
  22. data/examples/tutorial/02_first_node/my-platforms/hpc_config.rb +1 -0
  23. data/examples/tutorial/02_first_node/my-service-conf-repo/inventory.yaml +13 -0
  24. data/examples/tutorial/02_first_node/my-service-conf-repo/my-service.conf.erb +3 -0
  25. data/examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb +58 -0
  26. data/examples/tutorial/02_first_node/node/my-service.conf +4 -0
  27. data/examples/tutorial/03_scale/my-platforms/Gemfile +3 -0
  28. data/examples/tutorial/03_scale/my-platforms/hpc_config.rb +1 -0
  29. data/examples/tutorial/03_scale/my-platforms/my_commands.bash +2 -0
  30. data/examples/tutorial/03_scale/my-service-conf-repo/inventory.yaml +90 -0
  31. data/examples/tutorial/03_scale/my-service-conf-repo/my-service.conf.erb +3 -0
  32. data/examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb +58 -0
  33. data/examples/tutorial/03_scale/my-service-conf-repo/service_web-hello.rb +43 -0
  34. data/examples/tutorial/03_scale/node/my-service.conf +4 -0
  35. data/examples/tutorial/03_scale/web_docker_image/Dockerfile +33 -0
  36. data/examples/tutorial/03_scale/web_docker_image/hello_world.txt +1 -0
  37. data/examples/tutorial/03_scale/web_docker_image/hpc_root.key +27 -0
  38. data/examples/tutorial/03_scale/web_docker_image/hpc_root.key.pub +1 -0
  39. data/examples/tutorial/03_scale/web_docker_image/main.go +43 -0
  40. data/examples/tutorial/03_scale/web_docker_image/start.sh +7 -0
  41. data/examples/tutorial/03_scale/web_docker_image/test.bash +6 -0
  42. data/examples/tutorial/04_test/my-platforms/Gemfile +3 -0
  43. data/examples/tutorial/04_test/my-platforms/hpc_config.rb +12 -0
  44. data/examples/tutorial/04_test/my-platforms/images/debian_10/Dockerfile +13 -0
  45. data/examples/tutorial/04_test/my-platforms/my_commands.bash +2 -0
  46. data/examples/tutorial/04_test/my-service-conf-repo/inventory.yaml +100 -0
  47. data/examples/tutorial/04_test/my-service-conf-repo/my-service.conf.erb +3 -0
  48. data/examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb +58 -0
  49. data/examples/tutorial/04_test/my-service-conf-repo/service_web-hello.rb +43 -0
  50. data/examples/tutorial/04_test/node/my-service.conf +4 -0
  51. data/examples/tutorial/04_test/web_docker_image/Dockerfile +33 -0
  52. data/examples/tutorial/04_test/web_docker_image/hello_world.txt +1 -0
  53. data/examples/tutorial/04_test/web_docker_image/hpc_root.key +27 -0
  54. data/examples/tutorial/04_test/web_docker_image/hpc_root.key.pub +1 -0
  55. data/examples/tutorial/04_test/web_docker_image/main.go +43 -0
  56. data/examples/tutorial/04_test/web_docker_image/start.sh +7 -0
  57. data/examples/tutorial/04_test/web_docker_image/test.bash +6 -0
  58. data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/hosts.json +12 -0
  59. data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-gcc.bash +14 -0
  60. data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-python.bash +14 -0
  61. data/examples/tutorial/05_extend_with_plugins/dev_docker_image/Dockerfile +20 -0
  62. data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key +27 -0
  63. data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key.pub +1 -0
  64. data/examples/tutorial/05_extend_with_plugins/my-platforms/Gemfile +4 -0
  65. data/examples/tutorial/05_extend_with_plugins/my-platforms/hpc_config.rb +13 -0
  66. data/examples/tutorial/05_extend_with_plugins/my-platforms/images/debian_10/Dockerfile +13 -0
  67. data/examples/tutorial/05_extend_with_plugins/my-platforms/my_commands.bash +2 -0
  68. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/inventory.yaml +100 -0
  69. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/my-service.conf.erb +3 -0
  70. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb +58 -0
  71. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_web-hello.rb +43 -0
  72. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/platform_handler/json_bash.rb +115 -0
  73. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/report/web_report.rb +52 -0
  74. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/test/root_space.rb +44 -0
  75. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/my_hpc_plugins.gemspec +15 -0
  76. data/examples/tutorial/05_extend_with_plugins/node/my-service.conf +4 -0
  77. data/examples/tutorial/05_extend_with_plugins/web_docker_image/Dockerfile +33 -0
  78. data/examples/tutorial/05_extend_with_plugins/web_docker_image/hello_world.txt +1 -0
  79. data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key +27 -0
  80. data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key.pub +1 -0
  81. data/examples/tutorial/05_extend_with_plugins/web_docker_image/main.go +43 -0
  82. data/examples/tutorial/05_extend_with_plugins/web_docker_image/start.sh +7 -0
  83. data/examples/tutorial/05_extend_with_plugins/web_docker_image/test.bash +6 -0
  84. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  85. data/tools/generate_mermaid +1 -1
  86. metadata +131 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33b6e3bc5318de72c2f4d6c9ee0d092ba1cf078befdf07836765b10398dc0513
4
- data.tar.gz: '02068aaed645f9897f265da954817ae489dcff55f59e8ede8a179905594230db'
3
+ metadata.gz: 727927dd5825fdf3350a93fbc918d4d21fe5e24c89138bfc28315eb59b859054
4
+ data.tar.gz: 854722e9cfe5fe96df75c2bc1ef37afb659365809e9a6c4eb06fdc5295deb100
5
5
  SHA512:
6
- metadata.gz: 8307851f71ca547872c97772a7890cd3c7db399260e458abb74a226e96b23f51baad3905e74f586c20cf9b8c0ecd658a3b9df1f28c250112476d1e0328f01364
7
- data.tar.gz: 129f0b7f6c06c15465a3922374531e4bed7cd1fcc67081dcfe04ead71d5b600c247dcaa4803b05ecca8be26df5c745b4b4cbf7cab9e95d40accd16096e22dbe3
6
+ metadata.gz: 81e5c8928a3f03b1379bfb9136e927d8f39d6fd193068f24cddb90e671e4d9db21538dd87a566d7541e52b68e565f5a336e6afde98565ffd00e75b1ebf5d9ff8
7
+ data.tar.gz: dcb51c4dce6027f6153556a71671f4ae2cdfa29ad89d4c5ebca317a03455dd5c155ac0c00489a6c88b83fb222689ecf7fba05ef0706a33960970ef782e671a28
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [v32.13.1](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v32.13.0...v32.13.1) (2021-05-06 14:03:16)
2
+
3
+ ### Patches
4
+
5
+ * [Add tutorial files in examples](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/dfb456f031d48ba1ed6922a5f84ed659fe587ab8)
6
+
1
7
  # [v32.13.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v32.12.0...v32.13.0) (2021-05-06 11:20:57)
2
8
 
3
9
  ### Features
data/README.md CHANGED
@@ -246,7 +246,7 @@ So with the concepts described above, the process described as deploying **servi
246
246
  <!-- Mermaid generator - Section start -->
247
247
  ![Mermaid diagram](/docs/gen/mermaid/README.md-0.png)
248
248
  <details>
249
- <summary>See diagram Mermaid code</summary>
249
+ <summary><sub><sup>Diagram code</sup></sub></summary>
250
250
 
251
251
  ```mermaid
252
252
  sequenceDiagram
@@ -12,7 +12,7 @@ It will:
12
12
  <!-- Mermaid generator - Section start -->
13
13
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/check-node.md-0.png)
14
14
  <details>
15
- <summary>See diagram Mermaid code</summary>
15
+ <summary><sub><sup>Diagram code</sup></sub></summary>
16
16
 
17
17
  ```mermaid
18
18
  sequenceDiagram
@@ -12,7 +12,7 @@ It will:
12
12
  <!-- Mermaid generator - Section start -->
13
13
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/deploy.md-0.png)
14
14
  <details>
15
- <summary>See diagram Mermaid code</summary>
15
+ <summary><sub><sup>Diagram code</sup></sub></summary>
16
16
 
17
17
  ```mermaid
18
18
  sequenceDiagram
@@ -10,7 +10,7 @@ Useful to assign new IPs.
10
10
  <!-- Mermaid generator - Section start -->
11
11
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/free_ips.md-0.png)
12
12
  <details>
13
- <summary>See diagram Mermaid code</summary>
13
+ <summary><sub><sup>Diagram code</sup></sub></summary>
14
14
 
15
15
  ```mermaid
16
16
  sequenceDiagram
@@ -10,7 +10,7 @@ Useful to assign unused VEIDs to new VMs to be created.
10
10
  <!-- Mermaid generator - Section start -->
11
11
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/free_veids.md-0.png)
12
12
  <details>
13
- <summary>See diagram Mermaid code</summary>
13
+ <summary><sub><sup>Diagram code</sup></sub></summary>
14
14
 
15
15
  ```mermaid
16
16
  sequenceDiagram
@@ -8,7 +8,7 @@ This is especially useful to know which nodes have to be tested against a given
8
8
  <!-- Mermaid generator - Section start -->
9
9
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png)
10
10
  <details>
11
- <summary>See diagram Mermaid code</summary>
11
+ <summary><sub><sup>Diagram code</sup></sub></summary>
12
12
 
13
13
  ```mermaid
14
14
  sequenceDiagram
@@ -7,7 +7,7 @@ The `last_deploys` executable will fetch the last deployments information for a
7
7
  <!-- Mermaid generator - Section start -->
8
8
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/last_deploys.md-0.png)
9
9
  <details>
10
- <summary>See diagram Mermaid code</summary>
10
+ <summary><sub><sup>Diagram code</sup></sub></summary>
11
11
 
12
12
  ```mermaid
13
13
  sequenceDiagram
@@ -11,7 +11,7 @@ The list of nodes is given in standard output.
11
11
  <!-- Mermaid generator - Section start -->
12
12
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png)
13
13
  <details>
14
- <summary>See diagram Mermaid code</summary>
14
+ <summary><sub><sup>Diagram code</sup></sub></summary>
15
15
 
16
16
  ```mermaid
17
17
  sequenceDiagram
@@ -8,7 +8,7 @@ This executable is using [report plugins](../plugins.md#report) so that the tool
8
8
  <!-- Mermaid generator - Section start -->
9
9
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/report.md-0.png)
10
10
  <details>
11
- <summary>See diagram Mermaid code</summary>
11
+ <summary><sub><sup>Diagram code</sup></sub></summary>
12
12
 
13
13
  ```mermaid
14
14
  sequenceDiagram
@@ -8,7 +8,7 @@ It will use connectors (SSH...) to do so.
8
8
  <!-- Mermaid generator - Section start -->
9
9
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/run.md-0.png)
10
10
  <details>
11
- <summary>See diagram Mermaid code</summary>
11
+ <summary><sub><sup>Diagram code</sup></sub></summary>
12
12
 
13
13
  ```mermaid
14
14
  sequenceDiagram
@@ -10,7 +10,7 @@ It is intended to be run only for the initial setup or when such dependencies ch
10
10
  <!-- Mermaid generator - Section start -->
11
11
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/setup.md-0.png)
12
12
  <details>
13
- <summary>See diagram Mermaid code</summary>
13
+ <summary><sub><sup>Diagram code</sup></sub></summary>
14
14
 
15
15
  ```mermaid
16
16
  sequenceDiagram
@@ -11,7 +11,7 @@ This executable is also used internally by other tools of Hybrid Platforms Condu
11
11
  <!-- Mermaid generator - Section start -->
12
12
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/ssh_config.md-0.png)
13
13
  <details>
14
- <summary>See diagram Mermaid code</summary>
14
+ <summary><sub><sup>Diagram code</sup></sub></summary>
15
15
 
16
16
  ```mermaid
17
17
  sequenceDiagram
@@ -12,7 +12,7 @@ This executable is perfectly suited to be integrated in a continuous integration
12
12
  <!-- Mermaid generator - Section start -->
13
13
  ![Mermaid diagram](/docs/gen/mermaid/docs/executables/test.md-0.png)
14
14
  <details>
15
- <summary>See diagram Mermaid code</summary>
15
+ <summary><sub><sup>Diagram code</sup></sub></summary>
16
16
 
17
17
  ```mermaid
18
18
  sequenceDiagram
data/docs/tutorial.md CHANGED
@@ -43,6 +43,10 @@ The tutorial assumes that all of the Hybrid Platforms Conductor commands will be
43
43
  All steps, command lines and files creations are explicitly detailed in the tutorial steps.
44
44
  No previous knowledge of Ruby is required to get through this tutorial.
45
45
 
46
+ If in doubt, you can always refer to the [tutorial example folder](../examples/tutorial) to check files content.
47
+ Please note however that the content of this example tutorial folder maps the content of the files at the end of each section of the tutorial (numberd from 01 to 05), and intermediate steps in the tutorial can modify such files.
48
+ So the tutorial example folders may not reflect the expected content at an intermediate tutorial step.
49
+
46
50
  **[Next >> Let's start by the first step: installation of your Hybrid Platforms Conductor's environment](tutorial/01_installation.md)**
47
51
 
48
52
  ---
@@ -299,10 +299,19 @@ And now we try again the tests:
299
299
  Here we see that 3 nodes failed, but 1 of them is expected to fail, and is not counted in the failures summaries.
300
300
  Expected success is now down to 90 %.
301
301
 
302
- Let's bring back the 2 nodes that are expected to succeed and check tests again:
302
+ Let's bring back the 2 nodes that are expected to succeed and check tests again (we will also make sure to update their IP address in `/etc/hosts` as they could have changed):
303
303
  ```bash
304
+ # Restart only web3 and web5 - keep web1 down
304
305
  docker container start web3 web5
305
306
 
307
+ # Regenerate IPs in /etc/hosts
308
+ sed '/hpc_tutorial.org/d' /etc/hosts >/tmp/hosts
309
+ cp /tmp/hosts /etc/hosts
310
+ for ((i=2;i<=10;i++));
311
+ do
312
+ echo "$(docker container inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web$i) web$i.hpc_tutorial.org" >>/etc/hosts
313
+ done
314
+
306
315
  ./bin/test --all --test connection
307
316
  # ===== Run 11 connected tests ==== Begin...
308
317
  # ===== Run test commands on 11 connected nodes (timeout to 25 secs) ==== Begin...
@@ -625,9 +634,10 @@ And now we run all the tests:
625
634
 
626
635
  All tests are green!
627
636
 
628
- Before going further, let's bring back `web1` online:
637
+ Before going further, let's bring back `web1` online, and add its IP in `/etc/hosts` as well:
629
638
  ```bash
630
639
  docker container start web1
640
+ echo "$(docker container inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web1) web1.hpc_tutorial.org" >>/etc/hosts
631
641
  ```
632
642
 
633
643
  We'll see later how easy to add you own test plugins to complement those, but now it's time to see other kind of tests.
@@ -352,8 +352,8 @@ Let's see what does it take to integrate this new platform repository into Hybri
352
352
  ### Write a simple platform handler that can handle your existing repository
353
353
 
354
354
  A [`platform_handler` plugin](/docs/plugins.md#platform_handler) handles a given kind of platform repository, and has basically 2 roles:
355
- * Provide inventory information (nodes defined, their metadata, the services they are hosting...).
356
- * Provide services information (how to check/deploy services on a node).
355
+ * Provide **inventory** information (nodes defined, their metadata, the services they are hosting...).
356
+ * Provide **services** information (how to check/deploy services on a node).
357
357
 
358
358
  So let's write a new plugin handling your repository.
359
359
  Like any plugin, we create a file named `lib/<gem_name>/hpc_plugins/<plugin_type>/<plugin_name>.rb` that define a simple class inherting from a plugin's class.
@@ -999,8 +999,6 @@ For that we'll create a report plugin that will publish to our `web10` instance.
999
999
 
1000
1000
  Here is the code of our report plugin:
1001
1001
  ```ruby
1002
- # This file is an example of a Reports plugin that can be used to dump information about the platforms.
1003
- # The MyReportPlugin example contains example of code that could be used to write a plugin for a new kind of report.
1004
1002
  require 'hybrid_platforms_conductor/report'
1005
1003
 
1006
1004
  module MyHpcPlugins
@@ -1042,7 +1040,7 @@ module MyHpcPlugins
1042
1040
  end.join("\n")
1043
1041
  )
1044
1042
  # Upload the file on our web10 instance
1045
- system 'scp -o StrictHostKeyChecking=no /tmp/web_report.txt web10.hpc_tutorial.org:/root/hello_world.txt'
1043
+ system 'scp -o StrictHostKeyChecking=no /tmp/web_report.txt root@web10.hpc_tutorial.org:/root/hello_world.txt'
1046
1044
  out 'Upload successful'
1047
1045
  end
1048
1046
 
@@ -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