Skip to content

Commit

Permalink
feat: update egde playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydesl committed Dec 14, 2023
1 parent 28aa97c commit 8cfe524
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions playbook/project/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
src: /var/lib/rancher/k3s/server/node-token
register: k3s_token

- name: (registries) Check for registries.yaml
ansible.builtin.stat:
path: /etc/rancher/k3s/registries.yaml
register: registries_file

- name: (registries) Slurp registries.yaml
ansible.builtin.slurp:
src: /etc/rancher/k3s/registries.yaml
register: registries_content
when: registries_file.stat.exists

- name: Join agents
hosts: agents
gather_facts: False
Expand Down
15 changes: 14 additions & 1 deletion playbook/project/roles/micado_agent/tasks/join.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
- name: Join k3s cluster
shell: curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent" sh -s -
--server "https://{{ hostvars['micado']['ansible_host'] }}:6443"
--node-label "micado.eu/node_type={{ inventory_hostname }}"
--node-name "{{ inventory_hostname | lower }}"
--token "{{ hostvars['micado']['k3s_token']['content'] | b64decode | trim }}"
--node-external-ip "{{ ansible_host }}"

- name: (registries) Ensure /etc/rancher/k3s directory
file:
path: /etc/rancher/k3s
state: directory
mode: '0755'
when: hostvars['micado']['registries_file'].stat.exists

- name: (registries) Copy registries.yaml
copy:
content: "{{ hostvars['micado']['registries_content']['content'] | b64decode }}"
dest: /etc/rancher/k3s/registries.yaml
when: hostvars['micado']['registries_file'].stat.exists

0 comments on commit 8cfe524

Please sign in to comment.