hybrid_platforms_conductor 32.11.2 → 32.13.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1121 -0
- data/LICENSE.md +31 -0
- data/README.md +402 -0
- data/bin/setup +1 -1
- data/docs/api.md +349 -0
- data/docs/config_dsl.md +315 -0
- data/docs/executables.md +226 -0
- data/docs/executables/check-node.md +155 -0
- data/docs/executables/deploy.md +198 -0
- data/docs/executables/dump_nodes_json.md +110 -0
- data/docs/executables/free_ips.md +93 -0
- data/docs/executables/free_veids.md +73 -0
- data/docs/executables/get_impacted_nodes.md +94 -0
- data/docs/executables/last_deploys.md +114 -0
- data/docs/executables/nodes_to_deploy.md +139 -0
- data/docs/executables/report.md +159 -0
- data/docs/executables/run.md +126 -0
- data/docs/executables/setup.md +92 -0
- data/docs/executables/ssh_config.md +151 -0
- data/docs/executables/test.md +213 -0
- data/docs/executables/topograph.md +139 -0
- data/docs/gen/mermaid/README.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
- data/docs/install.md +161 -0
- data/docs/plugins.md +215 -0
- data/docs/plugins/action/bash.md +37 -0
- data/docs/plugins/action/interactive.md +37 -0
- data/docs/plugins/action/remote_bash.md +67 -0
- data/docs/plugins/action/ruby.md +69 -0
- data/docs/plugins/action/scp.md +61 -0
- data/docs/plugins/cmdb/config.md +46 -0
- data/docs/plugins/cmdb/host_ip.md +33 -0
- data/docs/plugins/cmdb/host_keys.md +33 -0
- data/docs/plugins/cmdb/platform_handlers.md +33 -0
- data/docs/plugins/connector/local.md +28 -0
- data/docs/plugins/connector/ssh.md +95 -0
- data/docs/plugins/platform_handler/yaml_inventory.md +105 -0
- data/docs/plugins/provisioner/docker.md +27 -0
- data/docs/plugins/provisioner/podman.md +27 -0
- data/docs/plugins/provisioner/proxmox.md +115 -0
- data/docs/plugins/report/confluence.md +49 -0
- data/docs/plugins/report/mediawiki.md +28 -0
- data/docs/plugins/report/stdout.md +32 -0
- data/docs/plugins/test/bitbucket_conf.md +97 -0
- data/docs/plugins/test/can_be_checked.md +27 -0
- data/docs/plugins/test/check_deploy_and_idempotence.md +61 -0
- data/docs/plugins/test/check_from_scratch.md +28 -0
- data/docs/plugins/test/connection.md +27 -0
- data/docs/plugins/test/deploy_freshness.md +27 -0
- data/docs/plugins/test/deploy_from_scratch.md +28 -0
- data/docs/plugins/test/deploy_removes_root_access.md +29 -0
- data/docs/plugins/test/divergence.md +41 -0
- data/docs/plugins/test/executables.md +26 -0
- data/docs/plugins/test/file_system.md +49 -0
- data/docs/plugins/test/file_system_hdfs.md +65 -0
- data/docs/plugins/test/hostname.md +27 -0
- data/docs/plugins/test/idempotence.md +56 -0
- data/docs/plugins/test/ip.md +28 -0
- data/docs/plugins/test/jenkins_ci_conf.md +54 -0
- data/docs/plugins/test/jenkins_ci_masters_ok.md +54 -0
- data/docs/plugins/test/linear_strategy.md +26 -0
- data/docs/plugins/test/local_users.md +48 -0
- data/docs/plugins/test/mounts.md +55 -0
- data/docs/plugins/test/orphan_files.md +38 -0
- data/docs/plugins/test/ports.md +50 -0
- data/docs/plugins/test/private_ips.md +27 -0
- data/docs/plugins/test/public_ips.md +27 -0
- data/docs/plugins/test/spectre.md +26 -0
- data/docs/plugins/test/veids.md +27 -0
- data/docs/plugins/test/vulnerabilities.md +65 -0
- data/docs/plugins/test_report/confluence.md +43 -0
- data/docs/plugins/test_report/stdout.md +26 -0
- data/docs/plugins_create.md +135 -0
- data/docs/tutorial.md +61 -0
- data/docs/tutorial/01_installation.md +131 -0
- data/docs/tutorial/02_first_node.md +468 -0
- data/docs/tutorial/03_scale.md +878 -0
- data/docs/tutorial/04_test.md +977 -0
- data/docs/tutorial/05_extend_with_plugins.md +1132 -0
- data/examples/bare/Gemfile +4 -0
- data/examples/bare/hpc_config.rb +2 -0
- data/examples/localhost/Gemfile +4 -0
- data/examples/localhost/hpc_config.rb +2 -0
- data/examples/localhost/inventory.yaml +4 -0
- data/examples/tutorial/01_installation/my-platforms/Gemfile +3 -0
- data/examples/tutorial/01_installation/my-platforms/hpc_config.rb +0 -0
- data/examples/tutorial/02_first_node/my-platforms/Gemfile +3 -0
- data/examples/tutorial/02_first_node/my-platforms/hpc_config.rb +1 -0
- data/examples/tutorial/02_first_node/my-service-conf-repo/inventory.yaml +13 -0
- data/examples/tutorial/02_first_node/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/02_first_node/node/my-service.conf +4 -0
- data/examples/tutorial/03_scale/my-platforms/Gemfile +3 -0
- data/examples/tutorial/03_scale/my-platforms/hpc_config.rb +1 -0
- data/examples/tutorial/03_scale/my-platforms/my_commands.bash +2 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/inventory.yaml +90 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/03_scale/my-service-conf-repo/service_web-hello.rb +43 -0
- data/examples/tutorial/03_scale/node/my-service.conf +4 -0
- data/examples/tutorial/03_scale/web_docker_image/Dockerfile +33 -0
- data/examples/tutorial/03_scale/web_docker_image/hello_world.txt +1 -0
- data/examples/tutorial/03_scale/web_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/03_scale/web_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/03_scale/web_docker_image/main.go +43 -0
- data/examples/tutorial/03_scale/web_docker_image/start.sh +7 -0
- data/examples/tutorial/03_scale/web_docker_image/test.bash +6 -0
- data/examples/tutorial/04_test/my-platforms/Gemfile +3 -0
- data/examples/tutorial/04_test/my-platforms/hpc_config.rb +12 -0
- data/examples/tutorial/04_test/my-platforms/images/debian_10/Dockerfile +13 -0
- data/examples/tutorial/04_test/my-platforms/my_commands.bash +2 -0
- data/examples/tutorial/04_test/my-service-conf-repo/inventory.yaml +100 -0
- data/examples/tutorial/04_test/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/04_test/my-service-conf-repo/service_web-hello.rb +43 -0
- data/examples/tutorial/04_test/node/my-service.conf +4 -0
- data/examples/tutorial/04_test/web_docker_image/Dockerfile +33 -0
- data/examples/tutorial/04_test/web_docker_image/hello_world.txt +1 -0
- data/examples/tutorial/04_test/web_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/04_test/web_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/04_test/web_docker_image/main.go +43 -0
- data/examples/tutorial/04_test/web_docker_image/start.sh +7 -0
- data/examples/tutorial/04_test/web_docker_image/test.bash +6 -0
- data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/hosts.json +12 -0
- data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-gcc.bash +14 -0
- data/examples/tutorial/05_extend_with_plugins/dev-servers-conf-repo/install-python.bash +14 -0
- data/examples/tutorial/05_extend_with_plugins/dev_docker_image/Dockerfile +20 -0
- data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/05_extend_with_plugins/dev_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/Gemfile +4 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/hpc_config.rb +13 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/images/debian_10/Dockerfile +13 -0
- data/examples/tutorial/05_extend_with_plugins/my-platforms/my_commands.bash +2 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/inventory.yaml +100 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/my-service.conf.erb +3 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb +58 -0
- data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_web-hello.rb +43 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/platform_handler/json_bash.rb +115 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/report/web_report.rb +52 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/test/root_space.rb +44 -0
- data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/my_hpc_plugins.gemspec +15 -0
- data/examples/tutorial/05_extend_with_plugins/node/my-service.conf +4 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/Dockerfile +33 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/hello_world.txt +1 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key +27 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/hpc_root.key.pub +1 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/main.go +43 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/start.sh +7 -0
- data/examples/tutorial/05_extend_with_plugins/web_docker_image/test.bash +6 -0
- data/lib/hybrid_platforms_conductor/actions_executor.rb +1 -0
- data/lib/hybrid_platforms_conductor/deployer.rb +3 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/action/remote_bash.rb +29 -13
- data/lib/hybrid_platforms_conductor/hpc_plugins/action/scp.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +98 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +15 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample +5 -5
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +140 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +6 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +4 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +19 -17
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +3 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +4 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +8 -7
- data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +1 -1
- data/lib/hybrid_platforms_conductor/json_dumper.rb +1 -1
- data/lib/hybrid_platforms_conductor/platform_handler.rb +1 -1
- data/lib/hybrid_platforms_conductor/services_handler.rb +18 -16
- data/lib/hybrid_platforms_conductor/tests_runner.rb +0 -1
- data/lib/hybrid_platforms_conductor/topographer.rb +0 -1
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +16 -0
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +30 -0
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +113 -0
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +6 -2
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +38 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +37 -4
- data/spec/hybrid_platforms_conductor_test/docs_spec.rb +10 -0
- data/tools/check_md +89 -0
- data/tools/generate_mermaid +75 -0
- metadata +337 -12
@@ -0,0 +1,12 @@
|
|
1
|
+
yaml_inventory_platform path: "#{Dir.home}/hpc_tutorial/my-service-conf-repo"
|
2
|
+
for_nodes('web1') do
|
3
|
+
expect_tests_to_fail %i[connection], 'web1 is temporarily down - will bring it up later'
|
4
|
+
end
|
5
|
+
# Select only the nodes implementing our web-hello service (that is all the webN nodes)
|
6
|
+
for_nodes [{ service: 'web-hello' }] do
|
7
|
+
# On our web servers we should have users used by our services
|
8
|
+
check_local_users_do_exist %w[sshd www-data]
|
9
|
+
# Make sure we have no leftovers of obsolete users
|
10
|
+
check_local_users_do_not_exist %w[dangerous_user obsolete_user]
|
11
|
+
end
|
12
|
+
os_image :debian_10, "#{hybrid_platforms_dir}/images/debian_10"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# syntax=docker/dockerfile:1
|
2
|
+
FROM debian:buster
|
3
|
+
|
4
|
+
RUN apt-get update && apt-get install -y openssh-server
|
5
|
+
RUN mkdir /var/run/sshd
|
6
|
+
# Activate root login with test password
|
7
|
+
RUN echo 'root:root_pwd' | chpasswd
|
8
|
+
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
9
|
+
# Speed-up considerably ssh performance and avoid huge lags and timeouts without DNS
|
10
|
+
RUN sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
|
11
|
+
EXPOSE 22
|
12
|
+
|
13
|
+
CMD ["/usr/sbin/sshd", "-D"]
|
@@ -0,0 +1,100 @@
|
|
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
|
+
image: debian_10
|
14
|
+
hostname: web1.hpc_tutorial.org
|
15
|
+
planet: Mercury
|
16
|
+
service_port: 1201
|
17
|
+
service_timeout: 60
|
18
|
+
services:
|
19
|
+
- web-hello
|
20
|
+
- my-service
|
21
|
+
web2:
|
22
|
+
metadata:
|
23
|
+
description: Web service nbr 2
|
24
|
+
image: debian_10
|
25
|
+
hostname: web2.hpc_tutorial.org
|
26
|
+
planet: Venus
|
27
|
+
service_port: 1202
|
28
|
+
service_timeout: 60
|
29
|
+
services:
|
30
|
+
- web-hello
|
31
|
+
- my-service
|
32
|
+
web3:
|
33
|
+
metadata:
|
34
|
+
description: Web service nbr 3
|
35
|
+
image: debian_10
|
36
|
+
hostname: web3.hpc_tutorial.org
|
37
|
+
planet: Earth
|
38
|
+
service_port: 1203
|
39
|
+
service_timeout: 60
|
40
|
+
services:
|
41
|
+
- web-hello
|
42
|
+
- my-service
|
43
|
+
web4:
|
44
|
+
metadata:
|
45
|
+
description: Web service nbr 4
|
46
|
+
image: debian_10
|
47
|
+
hostname: web4.hpc_tutorial.org
|
48
|
+
planet: Mars
|
49
|
+
service_port: 1204
|
50
|
+
service_timeout: 60
|
51
|
+
services:
|
52
|
+
- web-hello
|
53
|
+
- my-service
|
54
|
+
web5:
|
55
|
+
metadata:
|
56
|
+
description: Web service nbr 5
|
57
|
+
image: debian_10
|
58
|
+
hostname: web5.hpc_tutorial.org
|
59
|
+
planet: Jupiter
|
60
|
+
service_port: 1205
|
61
|
+
service_timeout: 60
|
62
|
+
services:
|
63
|
+
- web-hello
|
64
|
+
- my-service
|
65
|
+
web6:
|
66
|
+
metadata:
|
67
|
+
description: Web service nbr 6
|
68
|
+
image: debian_10
|
69
|
+
hostname: web6.hpc_tutorial.org
|
70
|
+
services:
|
71
|
+
- web-hello
|
72
|
+
web7:
|
73
|
+
metadata:
|
74
|
+
description: Web service nbr 7
|
75
|
+
image: debian_10
|
76
|
+
hostname: web7.hpc_tutorial.org
|
77
|
+
services:
|
78
|
+
- web-hello
|
79
|
+
web8:
|
80
|
+
metadata:
|
81
|
+
description: Web service nbr 8
|
82
|
+
image: debian_10
|
83
|
+
hostname: web8.hpc_tutorial.org
|
84
|
+
services:
|
85
|
+
- web-hello
|
86
|
+
web9:
|
87
|
+
metadata:
|
88
|
+
description: Web service nbr 9
|
89
|
+
image: debian_10
|
90
|
+
hostname: web9.hpc_tutorial.org
|
91
|
+
services:
|
92
|
+
- web-hello
|
93
|
+
web10:
|
94
|
+
metadata:
|
95
|
+
description: Web service nbr 10
|
96
|
+
image: debian_10
|
97
|
+
hostname: web10.hpc_tutorial.org
|
98
|
+
# The list of service names this node should have
|
99
|
+
services:
|
100
|
+
- web-hello
|
@@ -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,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 @@
|
|
1
|
+
Hello World!
|
@@ -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
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"dev1.hpc_tutorial.org": "python",
|
3
|
+
"dev2.hpc_tutorial.org": "python",
|
4
|
+
"dev3.hpc_tutorial.org": "python",
|
5
|
+
"dev4.hpc_tutorial.org": "python",
|
6
|
+
"dev5.hpc_tutorial.org": "python",
|
7
|
+
"dev6.hpc_tutorial.org": "gcc",
|
8
|
+
"dev7.hpc_tutorial.org": "gcc",
|
9
|
+
"dev8.hpc_tutorial.org": "gcc",
|
10
|
+
"dev9.hpc_tutorial.org": "gcc",
|
11
|
+
"dev10.hpc_tutorial.org": "gcc"
|
12
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
hostname=${1}
|
2
|
+
check_flag=${2:-deploy}
|
3
|
+
if [ "${check_flag}" = "check" ]; then
|
4
|
+
# Check if gcc is installed
|
5
|
+
if ssh -o StrictHostKeyChecking=no root@${hostname} 'gcc --version' 2>/dev/null; then
|
6
|
+
echo 'OK'
|
7
|
+
else
|
8
|
+
echo 'Missing'
|
9
|
+
fi
|
10
|
+
else
|
11
|
+
# Install gcc
|
12
|
+
ssh -o StrictHostKeyChecking=no root@${hostname} 'apt install -y gcc' 2>/dev/null
|
13
|
+
echo 'Installed'
|
14
|
+
fi
|
@@ -0,0 +1,14 @@
|
|
1
|
+
hostname=${1}
|
2
|
+
check_flag=${2:-deploy}
|
3
|
+
if [ "${check_flag}" = "check" ]; then
|
4
|
+
# Check if python3 is installed
|
5
|
+
if ssh -o StrictHostKeyChecking=no root@${hostname} 'python3 --version' 2>/dev/null; then
|
6
|
+
echo 'OK'
|
7
|
+
else
|
8
|
+
echo 'Missing'
|
9
|
+
fi
|
10
|
+
else
|
11
|
+
# Install python3
|
12
|
+
ssh -o StrictHostKeyChecking=no root@${hostname} 'apt install -y python3-pip' 2>/dev/null
|
13
|
+
echo 'Installed'
|
14
|
+
fi
|