Skip to content

Commit 078b031

Browse files
authored
fix: make the roles work even when hosts are aliased in the inventory (#399)
Signed-off-by: Michal Stanke <[email protected]>
1 parent c383279 commit 078b031

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

roles/airgap/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
skip: true
9898

9999
- name: Run K3s Install [server]
100-
when: inventory_hostname in groups['server']
100+
when: inventory_hostname in groups['server'] or ansible_host in groups['server']
101101
ansible.builtin.command:
102102
cmd: /usr/local/bin/k3s-install.sh
103103
environment:
@@ -106,7 +106,7 @@
106106
changed_when: true
107107

108108
- name: Run K3s Install [agent]
109-
when: inventory_hostname in groups['agent']
109+
when: inventory_hostname in groups['agent'] or ansible_host in groups['agent']
110110
ansible.builtin.command:
111111
cmd: /usr/local/bin/k3s-install.sh
112112
environment:

roles/k3s_server/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
register: _server_config_result
5858

5959
- name: Init first server node
60-
when: inventory_hostname == groups[server_group][0]
60+
when: inventory_hostname == groups[server_group][0] or ansible_host == groups[server_group][0]
6161
block:
6262
- name: Copy K3s service file [Single]
6363
when: groups[server_group] | length == 1 or use_external_database
@@ -205,7 +205,7 @@
205205
- name: Start other server if any and verify status
206206
when:
207207
- (groups[server_group] | length) > 1
208-
- inventory_hostname != groups[server_group][0]
208+
- inventory_hostname != groups[server_group][0] and ansible_host != groups[server_group][0]
209209
block:
210210
- name: Get the token from the first server
211211
ansible.builtin.set_fact:

0 commit comments

Comments
 (0)