Skip to content

Commit

Permalink
Use inventory_hostname instead of ansible_hostname
Browse files Browse the repository at this point in the history
Signed-off-by: Xiangkun Liu <[email protected]>
  • Loading branch information
pallxk committed Dec 11, 2023
1 parent 1c11767 commit e83a585
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions roles/k3s_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
mode: 0644

- name: Init first server node
# Handle both hostname OR ip address being supplied in inventory
when: ansible_hostname == groups['server'][0] or groups['server'][0] in ansible_facts['all_ipv4_addresses']
when: inventory_hostname == groups['server'][0]
block:
- name: Copy K3s service file [Single]
when: groups['server'] | length == 1
Expand Down Expand Up @@ -143,7 +142,7 @@
- name: Start other server if any and verify status
when:
- (groups['server'] | length) > 1
- ansible_hostname != groups['server'][0]
- inventory_hostname != groups['server'][0]
block:
- name: Copy K3s service file [HA]
when: groups['server'] | length > 1
Expand Down

0 comments on commit e83a585

Please sign in to comment.