mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2025-12-25 10:12:38 +01:00
fix(ansible): run task on one master
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Copy metallb namespace manifest to first master
|
- name: Copy metallb namespace manifest to first master
|
||||||
template:
|
template:
|
||||||
@@ -15,7 +16,8 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Copy metallb CRs manifest to first master
|
- name: Copy metallb CRs manifest to first master
|
||||||
template:
|
template:
|
||||||
@@ -24,7 +26,8 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Copy metallb main manifest to first master
|
- name: Copy metallb main manifest to first master
|
||||||
template:
|
template:
|
||||||
@@ -33,36 +36,42 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Apply metallb-system namespace
|
- name: Apply metallb-system namespace
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl apply -f /tmp/k3s/metallb-namespace.yaml
|
k3s kubectl apply -f /tmp/k3s/metallb-namespace.yaml
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Test metallb-system namespace
|
- name: Test metallb-system namespace
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl -n metallb-system
|
k3s kubectl -n metallb-system
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Apply metallb crds and service
|
- name: Apply metallb crds and service
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl apply -f /tmp/k3s/metallb.yaml
|
k3s kubectl apply -f /tmp/k3s/metallb.yaml
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Wait for metallb controller to be running
|
- name: Wait for metallb controller to be running
|
||||||
command: >-
|
command: >-
|
||||||
kubectl wait deployment -n metallb-system controller --for condition=Available=True --timeout=60s
|
kubectl wait deployment -n metallb-system controller --for condition=Available=True --timeout=60s
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Wait for metallb webhook service to be running
|
- name: Wait for metallb webhook service to be running
|
||||||
command: >-
|
command: >-
|
||||||
kubectl wait -n metallb-system --for=jsonpath='{.status.phase}'=Running pods \
|
kubectl wait -n metallb-system --for=jsonpath='{.status.phase}'=Running pods \
|
||||||
--selector component=controller --timeout=60s
|
--selector component=controller --timeout=60s
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
# TODO:// if there is a race condition, we'll have to manually wait here
|
# TODO:// if there is a race condition, we'll have to manually wait here
|
||||||
# - name: Wait for all metallb services to come up
|
# - name: Wait for all metallb services to come up
|
||||||
@@ -73,49 +82,57 @@
|
|||||||
command: >-
|
command: >-
|
||||||
kubectl wait pods -n metallb-system --for condition=Ready \
|
kubectl wait pods -n metallb-system --for condition=Ready \
|
||||||
--selector component=controller,app=metallb --timeout=60s
|
--selector component=controller,app=metallb --timeout=60s
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Wait for the metallb controller readyReplicas
|
- name: Wait for the metallb controller readyReplicas
|
||||||
command: >-
|
command: >-
|
||||||
kubectl wait -n metallb-system --for=jsonpath='{.status.readyReplicas}'=1 replicasets \
|
kubectl wait -n metallb-system --for=jsonpath='{.status.readyReplicas}'=1 replicasets \
|
||||||
--selector component=controller,app=metallb --timeout=60s
|
--selector component=controller,app=metallb --timeout=60s
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Wait for the metallb controller fullyLabeledReplicas
|
- name: Wait for the metallb controller fullyLabeledReplicas
|
||||||
command: >-
|
command: >-
|
||||||
kubectl wait -n metallb-system --for=jsonpath='{.status.fullyLabeledReplicas}'=1 replicasets \
|
kubectl wait -n metallb-system --for=jsonpath='{.status.fullyLabeledReplicas}'=1 replicasets \
|
||||||
--selector component=controller,app=metallb --timeout=60s
|
--selector component=controller,app=metallb --timeout=60s
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Wait for the metallb controller availableReplicas
|
- name: Wait for the metallb controller availableReplicas
|
||||||
command: >-
|
command: >-
|
||||||
kubectl wait -n metallb-system --for=jsonpath='{.status.availableReplicas}'=1 replicasets \
|
kubectl wait -n metallb-system --for=jsonpath='{.status.availableReplicas}'=1 replicasets \
|
||||||
--selector component=controller,app=metallb --timeout=60s
|
--selector component=controller,app=metallb --timeout=60s
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Test metallb-system webhook-service endpoint
|
- name: Test metallb-system webhook-service endpoint
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl -n metallb-system get endpoints webhook-service
|
k3s kubectl -n metallb-system get endpoints webhook-service
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Apply metallb CRs
|
- name: Apply metallb CRs
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl apply -f /tmp/k3s/metallb-crs.yaml
|
k3s kubectl apply -f /tmp/k3s/metallb-crs.yaml
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Test metallb-system IPAddressPool
|
- name: Test metallb-system IPAddressPool
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl -n metallb-system get IPAddressPool
|
k3s kubectl -n metallb-system get IPAddressPool
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Test metallb-system L2Advertisement
|
- name: Test metallb-system L2Advertisement
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl -n metallb-system get L2Advertisement
|
k3s kubectl -n metallb-system get L2Advertisement
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0])
|
with_items: "{{ groups['master'] }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Remove tmp director used for manifests
|
- name: Remove tmp director used for manifests
|
||||||
file:
|
file:
|
||||||
|
|||||||
Reference in New Issue
Block a user