-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored to separate agent and server runtimes + fixes + review com…
…ments
- Loading branch information
1 parent
aeeca4c
commit e4ff694
Showing
10 changed files
with
96 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
|
||
- name: Template k3s agent env file | ||
when: k3s_bootstrap_token != "" | ||
ansible.builtin.template: | ||
dest: /etc/systemd/system/k3s-agent.service.env | ||
src: k3s-agent.service.env.j2 | ||
register: _k3s_agent_token_result | ||
|
||
- name: Ensure password directory exists | ||
ansible.builtin.file: | ||
path: "/etc/rancher/node" | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: 0640 | ||
|
||
- name: Write node password | ||
ansible.builtin.copy: | ||
dest: /etc/rancher/node/password | ||
content: "{{ vault_k3s_node_password }}" | ||
owner: root | ||
group: root | ||
mode: 0640 # normal k3s install is 644 but that doesn't feel right | ||
|
||
- name: Start/restart k3s agent | ||
when: _k3s_agent_token_result.changed | ||
ansible.builtin.systemd: | ||
name: k3s-agent | ||
daemon_reload: true | ||
state: restarted | ||
enabled: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
|
||
- name: Template k3s env file | ||
ansible.builtin.template: | ||
dest: /etc/systemd/system/k3s.service.env | ||
src: k3s.service.env.j2 | ||
register: _k3s_env_file_status | ||
|
||
- name: Start k3s server | ||
ansible.builtin.systemd: | ||
name: k3s | ||
daemon_reload: "{{ _k3s_env_file_status.changed }}" | ||
state: started | ||
enabled: true | ||
|
||
# Possible race here as there is a delay between agents disconnecting and being registered as down, probably won't be hit in general use though | ||
- name: Check if k3s agents are connected | ||
ignore_errors: true | ||
ansible.builtin.shell: | ||
cmd: kubectl get nodes --no-headers | grep -w Ready | ||
register: _k3s_connected_nodes | ||
retries: 5 # there may be a delay before the server reconnects to itself | ||
delay: 10 | ||
until: not _k3s_connected_nodes.failed | ||
|
||
- name: Generate new bootstrap token | ||
no_log: true | ||
when: _k3s_connected_nodes.stdout_lines | length != groups['k3s'] | length | ||
shell: | ||
cmd: "k3s token create --ttl {{ k3s_bootstrap_token_expiry }}" | ||
register: _k3s_token_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
K3S_NODE_IP={{ access_ip }} | ||
K3S_TOKEN={{ hostvars[groups['control'] | first]._token_output.stdout }} | ||
K3S_NODE_IP={{ ansible_host }} | ||
K3S_TOKEN={{ k3s_bootstrap_token }} | ||
K3S_URL=https://{{ k3s_server_name }}:6443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
K3S_NODE_IP={{ access_ip }} | ||
K3S_NODE_IP={{ ansible_host }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
environments/skeleton/{{cookiecutter.environment}}/tofu/data.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters