summaryrefslogtreecommitdiff
path: root/playbooks/roles/swarm_cluster/tasks
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-05-04 12:17:10 -0700
committerElizabeth Hunt <me@liz.coffee>2025-05-04 12:17:10 -0700
commit7040a443c5973be872cdf5f3a656e9f947650b2b (patch)
tree833dd0a9f2a6b0c5f2523a70b995965c95bd5f21 /playbooks/roles/swarm_cluster/tasks
parentd0d07c491f157bef0174cc05ee3c308fe9f72c9b (diff)
downloadinfra-7040a443c5973be872cdf5f3a656e9f947650b2b.tar.gz
infra-7040a443c5973be872cdf5f3a656e9f947650b2b.zip
Refactor the swarm cluster role a bit
Diffstat (limited to 'playbooks/roles/swarm_cluster/tasks')
-rw-r--r--playbooks/roles/swarm_cluster/tasks/main.yml20
1 files changed, 20 insertions, 0 deletions
diff --git a/playbooks/roles/swarm_cluster/tasks/main.yml b/playbooks/roles/swarm_cluster/tasks/main.yml
new file mode 100644
index 0000000..d2507af
--- /dev/null
+++ b/playbooks/roles/swarm_cluster/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+
+- name: Enable Local Swarm Communications
+ community.general.ufw:
+ rule: allow
+ from: "{{ homelab_network }}"
+ state: enabled
+
+- name: Set swarm initializer variable
+ ansible.builtin.set_fact:
+ swarm_initializer_host: "{{ groups['swarm_cluster'][0] }}"
+
+- name: Initialize the swarm cluster on the first node
+ when: ansible_hostname == swarm_initializer_host
+ ansible.builtin.import_tasks: swarm_init/tasks/main.yml
+
+- name: Join the swarm cluster on all other nodes
+ when: ansible_hostname != swarm_initializer_host
+ ansible.builtin.import_tasks: swarm_join/tasks/main.yml
+