diff --git a/roles/k3s/master/tasks/main.yml b/roles/k3s/master/tasks/main.yml index 2efb265..5eced8f 100644 --- a/roles/k3s/master/tasks/main.yml +++ b/roles/k3s/master/tasks/main.yml @@ -40,6 +40,25 @@ mode: 0644 when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0]) +# these will be copied and installed now, then tested later and apply config +- name: Copy metallb namespace to first master + template: + src: "metallb.namespace.j2" + dest: "/var/lib/rancher/k3s/server/manifests/metallb-namespace.yaml" + owner: root + group: root + mode: 0644 + when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0]) + +- name: Copy metallb namespace to first master + template: + src: "metallb.crds.j2" + dest: "/var/lib/rancher/k3s/server/manifests/metallb-crds.yaml" + owner: root + group: root + mode: 0644 + when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0]) + - name: Init cluster inside the transient k3s-init service command: cmd: "systemd-run -p RestartSec=2 \ diff --git a/roles/k3s/post/tasks/templates/metallb.yaml.j2 b/roles/k3s/master/templates/metallb.crds.j2 similarity index 100% rename from roles/k3s/post/tasks/templates/metallb.yaml.j2 rename to roles/k3s/master/templates/metallb.crds.j2 diff --git a/roles/k3s/post/tasks/templates/metallb.namespace.j2 b/roles/k3s/master/templates/metallb.namespace.j2 similarity index 100% rename from roles/k3s/post/tasks/templates/metallb.namespace.j2 rename to roles/k3s/master/templates/metallb.namespace.j2 diff --git a/roles/k3s/post/tasks/main.yml b/roles/k3s/post/tasks/main.yml index 918de8e..b889874 100644 --- a/roles/k3s/post/tasks/main.yml +++ b/roles/k3s/post/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Create manifests directory +- name: Create manifests directory for temp configuration file: path: /tmp/k3s state: directory @@ -9,16 +9,6 @@ with_items: "{{ groups['master'] }}" run_once: true -- name: Copy metallb namespace manifest to first master - template: - src: "metallb.namespace.j2" - dest: "/tmp/k3s/metallb-namespace.yaml" - owner: root - group: root - mode: 0644 - with_items: "{{ groups['master'] }}" - run_once: true - - name: Copy metallb CRs manifest to first master template: src: "metallb.crs.j2" @@ -29,23 +19,6 @@ with_items: "{{ groups['master'] }}" run_once: true -- name: Copy metallb main manifest to first master - template: - src: "metallb.yaml.j2" - dest: "/tmp/k3s/metallb.yaml" - owner: root - group: root - mode: 0644 - with_items: "{{ groups['master'] }}" - run_once: true - -- name: Apply metallb-system namespace - command: >- - k3s kubectl apply -f /tmp/k3s/metallb-namespace.yaml - changed_when: false - with_items: "{{ groups['master'] }}" - run_once: true - - name: Test metallb-system namespace command: >- k3s kubectl -n metallb-system @@ -53,13 +26,6 @@ with_items: "{{ groups['master'] }}" run_once: true -- name: Apply metallb crds and service - command: >- - k3s kubectl apply -f /tmp/k3s/metallb.yaml - changed_when: false - with_items: "{{ groups['master'] }}" - run_once: true - - name: Wait for metallb controller to be running command: >- kubectl wait deployment -n metallb-system controller --for condition=Available=True --timeout=60s @@ -107,11 +73,6 @@ with_items: "{{ groups['master'] }}" run_once: true -# TODO:// if there is a race condition, we'll have to manually wait here -- name: Wait for all metallb services to come up - wait_for: - timeout: 60 - - name: Test metallb-system webhook-service endpoint command: >- k3s kubectl -n metallb-system get endpoints webhook-service