feat(calico_operator): store ansible manifests on node

this provides for ansible diff to confirm if any changes were made.

!17
This commit is contained in:
2024-01-30 19:06:31 +09:30
parent 5ffbd78e2b
commit 5925a26c60
2 changed files with 8 additions and 15 deletions

View File

@ -68,6 +68,9 @@
- name: /var/lib/rancher/k3s/server/manifests - name: /var/lib/rancher/k3s/server/manifests
state: directory state: directory
mode: 700 mode: 700
- name: /var/lib/rancher/k3s/ansible
state: directory
mode: 700
- name: Add sysctl net.ipv4.ip_forward - name: Add sysctl net.ipv4.ip_forward

View File

@ -13,7 +13,6 @@
- FelixConfiguration-manifest-Calico_Cluster.yaml - FelixConfiguration-manifest-Calico_Cluster.yaml
- IPPool-manifest-Calico_Cluster.yaml.j2 - IPPool-manifest-Calico_Cluster.yaml.j2
- APIServer-manifest-Calico_Cluster.yaml - APIServer-manifest-Calico_Cluster.yaml
# - calico.yaml.j2
block: block:
@ -48,12 +47,14 @@
when: file_calico_yaml_metadata.stat.exists when: file_calico_yaml_metadata.stat.exists
# Save the manifests in a dir so that diff's can be shown for changes
- name: Copy Manifest for addition - name: Copy Manifest for addition
ansible.builtin.template: ansible.builtin.template:
src: "{{ item }}" src: "{{ item }}"
dest: "/tmp/{{ item | lower | replace('.j2', '') }}" dest: "/var/lib/rancher/k3s/ansible/{{ item | lower | replace('.j2', '') }}"
mode: '744' mode: '744'
become: true become: true
diff: true
loop: "{{ operator_manifests }}" loop: "{{ operator_manifests }}"
@ -66,7 +67,6 @@
cmd: "kubectl create -f /tmp/{{ item | lower | replace('.j2', '') }}" cmd: "kubectl create -f /tmp/{{ item | lower | replace('.j2', '') }}"
become: true become: true
changed_when: false changed_when: false
diff: true
failed_when: > failed_when: >
{{ 'Error from server' in operator_manifest_stdout.stderr }} {{ 'Error from server' in operator_manifest_stdout.stderr }}
loop: "{{ operator_manifests }}" loop: "{{ operator_manifests }}"
@ -83,10 +83,9 @@
- name: Apply Operator Manifests - "Rescue" - name: Apply Operator Manifests - "Rescue"
ansible.builtin.command: ansible.builtin.command:
cmd: "kubectl replace -f /tmp/{{ item | lower | replace('.j2', '') }}" cmd: "kubectl replace -f /var/lib/rancher/k3s/ansible/{{ item | lower | replace('.j2', '') }}"
become: true become: true
changed_when: false changed_when: false
diff: true
failed_when: > failed_when: >
{{ {{
'Error from server' in operator_manifest_stdout.stderr 'Error from server' in operator_manifest_stdout.stderr
@ -171,7 +170,7 @@
- name: Remove Operator Manifests - name: Remove Operator Manifests
ansible.builtin.command: ansible.builtin.command:
cmd: "kubectl delete -f /tmp/{{ item | lower | replace('.j2', '') }}" cmd: "kubectl delete -f /var/lib/rancher/k3s/ansible/{{ item | lower | replace('.j2', '') }}"
become: true become: true
changed_when: false changed_when: false
failed_when: false failed_when: false
@ -198,15 +197,6 @@
always: always:
- name: Remove Operator Manifests files
ansible.builtin.file:
name: "/tmp/{{ item | lower | replace('.j2', '') }}"
state: absent
become: true
changed_when: false
loop: "{{ operator_manifests }}"
- name: Clean-up Temp File - name: Clean-up Temp File
ansible.builtin.file: ansible.builtin.file:
name: /tmp/calico.yaml name: /tmp/calico.yaml