From 7040a443c5973be872cdf5f3a656e9f947650b2b Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 4 May 2025 12:17:10 -0700 Subject: Refactor the swarm cluster role a bit --- playbooks/roles/swarm_cluster/tasks/main.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 playbooks/roles/swarm_cluster/tasks/main.yml (limited to 'playbooks/roles/swarm_cluster/tasks') 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 + -- cgit v1.2.3-70-g09d2