-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-slurm.yml
41 lines (36 loc) · 1.33 KB
/
deploy-slurm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
- name: Setup Docker Swarm Cluster and Overlay Network
hosts: base_machines
become: yes
vars_files:
- secure.yml
- containers.yml
gather_facts: yes
tasks:
# Initialize Docker Swarm on aegypti (Manager Node)
- name: Initialize Docker Swarm (on manager node)
command: docker swarm init
when: inventory_hostname == 'aegypti'
register: swarm_init
ignore_errors: yes
# Retrieve Swarm Join Token
- name: Get Docker Swarm join-token for worker
command: docker swarm join-token -q worker
register: join_token
when: inventory_hostname == 'aegypti'
changed_when: false
# Debug: Print Join Token
- name: Debug join_token
debug:
var: join_token
when: inventory_hostname == 'aegypti'
# Join Worker Nodes to Swarm
- name: Join Docker Swarm (on worker nodes)
command: "docker swarm join --token {{ hostvars['aegypti']['join_token'].stdout }} {{ hostvars['aegypti']['ansible_default_ipv4']['address'] }}:2377"
when: inventory_hostname in ['sycorax', 'prospero'] and 'join_token' in hostvars['aegypti']
ignore_errors: yes
# Create Overlay Network
- name: Create Docker Overlay Network
command: docker network create --driver overlay --attachable test
when: inventory_hostname == 'aegypti'
run_once: true