Loading .gitignore +2 −0 Original line number Diff line number Diff line .vscode .vagrant No newline at end of file reset.yml +2 −1 Original line number Diff line number Diff line --- - hosts: k3s_cluster - name: Reset K3s cluster hosts: k3s_cluster gather_facts: yes become: yes roles: Loading roles/download/tasks/main.yml +3 −3 Original line number Diff line number Diff line --- - name: Download k3s binary x64 get_url: ansible.builtin.get_url: url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-amd64.txt timeout: 120 Loading @@ -12,7 +12,7 @@ when: ansible_facts.architecture == "x86_64" - name: Download k3s binary arm64 get_url: ansible.builtin.get_url: url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s-arm64 checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-arm64.txt timeout: 120 Loading @@ -26,7 +26,7 @@ ansible_facts.architecture is search("aarch64") - name: Download k3s binary armhf get_url: ansible.builtin.get_url: url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s-armhf checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-arm.txt timeout: 120 Loading roles/k3s/master/tasks/main.yml +13 −13 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ - name: Copy K3s service file register: k3s_service template: ansible.builtin.template: src: "k3s.service.j2" dest: "{{ systemd_dir }}/k3s.service" owner: root Loading @@ -10,49 +10,49 @@ mode: 0644 - name: Enable and check K3s service systemd: ansible.builtin.systemd: name: k3s daemon_reload: yes state: restarted enabled: yes - name: Wait for node-token wait_for: ansible.builtin.wait_for: path: "{{ k3s_server_location }}/server/node-token" - name: Register node-token file access mode stat: ansible.builtin.stat: path: "{{ k3s_server_location }}/server/node-token" register: p - name: Change file access node-token file: ansible.builtin.file: path: "{{ k3s_server_location }}/server/node-token" mode: "g+rx,o+rx" - name: Read node-token from master slurp: ansible.builtin.slurp: path: "{{ k3s_server_location }}/server/node-token" register: node_token - name: Store Master node-token set_fact: ansible.builtin.set_fact: token: "{{ node_token.content | b64decode | regex_replace('\n', '') }}" - name: Restore node-token file access file: ansible.builtin.file: path: "{{ k3s_server_location }}/server/node-token" mode: "{{ p.stat.mode }}" - name: Create directory .kube file: ansible.builtin.file: path: ~{{ ansible_user }}/.kube state: directory owner: "{{ ansible_user }}" mode: "u=rwx,g=rx,o=" - name: Copy config file to user home directory copy: ansible.builtin.copy: src: /etc/rancher/k3s/k3s.yaml dest: ~{{ ansible_user }}/.kube/config remote_src: yes Loading @@ -60,20 +60,20 @@ mode: "u=rw,g=,o=" - name: Replace https://localhost:6443 by https://master-ip:6443 command: >- ansible.builtin.command: >- /usr/local/bin/k3s kubectl config set-cluster default --server=https://{{ master_ip }}:6443 --kubeconfig ~{{ ansible_user }}/.kube/config changed_when: true - name: Create kubectl symlink file: ansible.builtin.file: src: /usr/local/bin/k3s dest: /usr/local/bin/kubectl state: link - name: Create crictl symlink file: ansible.builtin.file: src: /usr/local/bin/k3s dest: /usr/local/bin/crictl state: link roles/k3s/node/tasks/main.yml +2 −2 Original line number Diff line number Diff line --- - name: Copy K3s service file template: ansible.builtin.template: src: "k3s.service.j2" dest: "{{ systemd_dir }}/k3s-node.service" owner: root Loading @@ -9,7 +9,7 @@ mode: 0755 - name: Enable and check K3s service systemd: ansible.builtin.systemd: name: k3s-node daemon_reload: yes state: restarted Loading Loading
.gitignore +2 −0 Original line number Diff line number Diff line .vscode .vagrant No newline at end of file
reset.yml +2 −1 Original line number Diff line number Diff line --- - hosts: k3s_cluster - name: Reset K3s cluster hosts: k3s_cluster gather_facts: yes become: yes roles: Loading
roles/download/tasks/main.yml +3 −3 Original line number Diff line number Diff line --- - name: Download k3s binary x64 get_url: ansible.builtin.get_url: url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-amd64.txt timeout: 120 Loading @@ -12,7 +12,7 @@ when: ansible_facts.architecture == "x86_64" - name: Download k3s binary arm64 get_url: ansible.builtin.get_url: url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s-arm64 checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-arm64.txt timeout: 120 Loading @@ -26,7 +26,7 @@ ansible_facts.architecture is search("aarch64") - name: Download k3s binary armhf get_url: ansible.builtin.get_url: url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s-armhf checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-arm.txt timeout: 120 Loading
roles/k3s/master/tasks/main.yml +13 −13 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ - name: Copy K3s service file register: k3s_service template: ansible.builtin.template: src: "k3s.service.j2" dest: "{{ systemd_dir }}/k3s.service" owner: root Loading @@ -10,49 +10,49 @@ mode: 0644 - name: Enable and check K3s service systemd: ansible.builtin.systemd: name: k3s daemon_reload: yes state: restarted enabled: yes - name: Wait for node-token wait_for: ansible.builtin.wait_for: path: "{{ k3s_server_location }}/server/node-token" - name: Register node-token file access mode stat: ansible.builtin.stat: path: "{{ k3s_server_location }}/server/node-token" register: p - name: Change file access node-token file: ansible.builtin.file: path: "{{ k3s_server_location }}/server/node-token" mode: "g+rx,o+rx" - name: Read node-token from master slurp: ansible.builtin.slurp: path: "{{ k3s_server_location }}/server/node-token" register: node_token - name: Store Master node-token set_fact: ansible.builtin.set_fact: token: "{{ node_token.content | b64decode | regex_replace('\n', '') }}" - name: Restore node-token file access file: ansible.builtin.file: path: "{{ k3s_server_location }}/server/node-token" mode: "{{ p.stat.mode }}" - name: Create directory .kube file: ansible.builtin.file: path: ~{{ ansible_user }}/.kube state: directory owner: "{{ ansible_user }}" mode: "u=rwx,g=rx,o=" - name: Copy config file to user home directory copy: ansible.builtin.copy: src: /etc/rancher/k3s/k3s.yaml dest: ~{{ ansible_user }}/.kube/config remote_src: yes Loading @@ -60,20 +60,20 @@ mode: "u=rw,g=,o=" - name: Replace https://localhost:6443 by https://master-ip:6443 command: >- ansible.builtin.command: >- /usr/local/bin/k3s kubectl config set-cluster default --server=https://{{ master_ip }}:6443 --kubeconfig ~{{ ansible_user }}/.kube/config changed_when: true - name: Create kubectl symlink file: ansible.builtin.file: src: /usr/local/bin/k3s dest: /usr/local/bin/kubectl state: link - name: Create crictl symlink file: ansible.builtin.file: src: /usr/local/bin/k3s dest: /usr/local/bin/crictl state: link
roles/k3s/node/tasks/main.yml +2 −2 Original line number Diff line number Diff line --- - name: Copy K3s service file template: ansible.builtin.template: src: "k3s.service.j2" dest: "{{ systemd_dir }}/k3s-node.service" owner: root Loading @@ -9,7 +9,7 @@ mode: 0755 - name: Enable and check K3s service systemd: ansible.builtin.systemd: name: k3s-node daemon_reload: yes state: restarted Loading