mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2025-12-25 10:12:38 +01:00
Change to FQCN with ansible-lint fixer (#553)
* Change to FQCN with ansible-lint fixer Since ansible-base 2.10 (later ansible-core), FQCN is the new way to go. Updated .ansible-lint with a production profile and removed fqcn in skip_list. Updated .yamllint with rules needed. Ran ansible-lint --fix=all, then manually applied some minor changes. * Changed octal value in molecule/ipv6/prepare.yml
This commit is contained in:
@@ -4,28 +4,28 @@
|
||||
run_once: true
|
||||
block:
|
||||
- name: Create manifests directory on first master
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /tmp/k3s
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
- name: "Download to first master: manifest for Tigera Operator and Calico CRDs"
|
||||
ansible.builtin.get_url:
|
||||
url: "https://raw.githubusercontent.com/projectcalico/calico/{{ calico_tag }}/manifests/tigera-operator.yaml"
|
||||
dest: "/tmp/k3s/tigera-operator.yaml"
|
||||
url: https://raw.githubusercontent.com/projectcalico/calico/{{ calico_tag }}/manifests/tigera-operator.yaml
|
||||
dest: /tmp/k3s/tigera-operator.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
- name: Copy Calico custom resources manifest to first master
|
||||
ansible.builtin.template:
|
||||
src: "calico.crs.j2"
|
||||
src: calico.crs.j2
|
||||
dest: /tmp/k3s/custom-resources.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
- name: Deploy or replace Tigera Operator
|
||||
block:
|
||||
@@ -44,7 +44,7 @@
|
||||
failed_when: "'Error' in replace_operator.stderr"
|
||||
|
||||
- name: Wait for Tigera Operator resources
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
k3s kubectl wait {{ item.type }}/{{ item.name }}
|
||||
--namespace='tigera-operator'
|
||||
--for=condition=Available=True
|
||||
@@ -55,7 +55,7 @@
|
||||
retries: 7
|
||||
delay: 7
|
||||
with_items:
|
||||
- {name: tigera-operator, type: deployment}
|
||||
- { name: tigera-operator, type: deployment }
|
||||
loop_control:
|
||||
label: "{{ item.type }}/{{ item.name }}"
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
failed_when: "'Error' in apply_cr.stderr"
|
||||
|
||||
- name: Wait for Calico system resources to be available
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
{% if item.type == 'daemonset' %}
|
||||
k3s kubectl wait pods
|
||||
--namespace='{{ item.namespace }}'
|
||||
@@ -94,11 +94,17 @@
|
||||
retries: 30
|
||||
delay: 7
|
||||
with_items:
|
||||
- {name: calico-typha, type: deployment, namespace: calico-system}
|
||||
- {name: calico-kube-controllers, type: deployment, namespace: calico-system}
|
||||
- {name: csi-node-driver, type: daemonset, selector: 'k8s-app=csi-node-driver', namespace: calico-system}
|
||||
- {name: calico-node, type: daemonset, selector: 'k8s-app=calico-node', namespace: calico-system}
|
||||
- {name: calico-apiserver, type: deployment, namespace: calico-apiserver}
|
||||
- { name: calico-typha, type: deployment, namespace: calico-system }
|
||||
- { name: calico-kube-controllers, type: deployment, namespace: calico-system }
|
||||
- name: csi-node-driver
|
||||
type: daemonset
|
||||
selector: k8s-app=csi-node-driver
|
||||
namespace: calico-system
|
||||
- name: calico-node
|
||||
type: daemonset
|
||||
selector: k8s-app=calico-node
|
||||
namespace: calico-system
|
||||
- { name: calico-apiserver, type: deployment, namespace: calico-apiserver }
|
||||
loop_control:
|
||||
label: "{{ item.type }}/{{ item.name }}"
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
run_once: true
|
||||
block:
|
||||
- name: Create tmp directory on first master
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /tmp/k3s
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
- name: Check if Cilium CLI is installed
|
||||
ansible.builtin.command: cilium version
|
||||
@@ -19,7 +19,7 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Check for Cilium CLI version in command output
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
installed_cli_version: >-
|
||||
{{
|
||||
cilium_cli_installed.stdout_lines
|
||||
@@ -32,11 +32,11 @@
|
||||
|
||||
- name: Get latest stable Cilium CLI version file
|
||||
ansible.builtin.get_url:
|
||||
url: "https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt"
|
||||
dest: "/tmp/k3s/cilium-cli-stable.txt"
|
||||
url: https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt
|
||||
dest: /tmp/k3s/cilium-cli-stable.txt
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
- name: Read Cilium CLI stable version from file
|
||||
ansible.builtin.command: cat /tmp/k3s/cilium-cli-stable.txt
|
||||
@@ -52,7 +52,7 @@
|
||||
msg: "Latest Cilium CLI version: {{ cli_ver.stdout }}"
|
||||
|
||||
- name: Determine if Cilium CLI needs installation or update
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
cilium_cli_needs_update: >-
|
||||
{{
|
||||
cilium_cli_installed.rc != 0 or
|
||||
@@ -70,15 +70,15 @@
|
||||
- name: Download Cilium CLI and checksum
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ cilium_base_url }}/cilium-linux-{{ cli_arch }}{{ item }}"
|
||||
dest: "/tmp/k3s/cilium-linux-{{ cli_arch }}{{ item }}"
|
||||
dest: /tmp/k3s/cilium-linux-{{ cli_arch }}{{ item }}
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
loop:
|
||||
- ".tar.gz"
|
||||
- ".tar.gz.sha256sum"
|
||||
- .tar.gz
|
||||
- .tar.gz.sha256sum
|
||||
vars:
|
||||
cilium_base_url: "https://github.com/cilium/cilium-cli/releases/download/{{ cli_ver.stdout }}"
|
||||
cilium_base_url: https://github.com/cilium/cilium-cli/releases/download/{{ cli_ver.stdout }}
|
||||
|
||||
- name: Verify the downloaded tarball
|
||||
ansible.builtin.shell: |
|
||||
@@ -89,7 +89,7 @@
|
||||
|
||||
- name: Extract Cilium CLI to /usr/local/bin
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||
src: /tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz
|
||||
dest: /usr/local/bin
|
||||
remote_src: true
|
||||
|
||||
@@ -98,8 +98,8 @@
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "/tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||
- "/tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz.sha256sum"
|
||||
- /tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz
|
||||
- /tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz.sha256sum
|
||||
|
||||
- name: Wait for connectivity to kube VIP
|
||||
ansible.builtin.command: ping -c 1 {{ apiserver_endpoint }}
|
||||
@@ -112,7 +112,7 @@
|
||||
|
||||
- name: Fail if kube VIP not reachable
|
||||
ansible.builtin.fail:
|
||||
msg: "API endpoint {{ apiserver_endpoint }} is not reachable"
|
||||
msg: API endpoint {{ apiserver_endpoint }} is not reachable
|
||||
when: ping_result.rc != 0
|
||||
|
||||
- name: Test for existing Cilium install
|
||||
@@ -125,7 +125,6 @@
|
||||
- name: Check existing Cilium install
|
||||
when: cilium_installed.rc == 0
|
||||
block:
|
||||
|
||||
- name: Check Cilium version
|
||||
ansible.builtin.command: cilium version
|
||||
register: cilium_version
|
||||
@@ -134,7 +133,7 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Parse installed Cilium version
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
installed_cilium_version: >-
|
||||
{{
|
||||
cilium_version.stdout_lines
|
||||
@@ -145,7 +144,7 @@
|
||||
}}
|
||||
|
||||
- name: Determine if Cilium needs update
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
cilium_needs_update: >-
|
||||
{{ 'v' + installed_cilium_version != cilium_tag }}
|
||||
|
||||
@@ -191,7 +190,7 @@
|
||||
when: cilium_installed.rc != 0 or cilium_needs_update
|
||||
|
||||
- name: Wait for Cilium resources
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
{% if item.type == 'daemonset' %}
|
||||
k3s kubectl wait pods
|
||||
--namespace=kube-system
|
||||
@@ -209,10 +208,10 @@
|
||||
retries: 30
|
||||
delay: 7
|
||||
with_items:
|
||||
- {name: cilium-operator, type: deployment}
|
||||
- {name: cilium, type: daemonset, selector: 'k8s-app=cilium'}
|
||||
- {name: hubble-relay, type: deployment, check_hubble: true}
|
||||
- {name: hubble-ui, type: deployment, check_hubble: true}
|
||||
- { name: cilium-operator, type: deployment }
|
||||
- { name: cilium, type: daemonset, selector: k8s-app=cilium }
|
||||
- { name: hubble-relay, type: deployment, check_hubble: true }
|
||||
- { name: hubble-ui, type: deployment, check_hubble: true }
|
||||
loop_control:
|
||||
label: "{{ item.type }}/{{ item.name }}"
|
||||
when: >-
|
||||
@@ -221,14 +220,13 @@
|
||||
- name: Configure Cilium BGP
|
||||
when: cilium_bgp
|
||||
block:
|
||||
|
||||
- name: Copy BGP manifests to first master
|
||||
ansible.builtin.template:
|
||||
src: "cilium.crs.j2"
|
||||
src: cilium.crs.j2
|
||||
dest: /tmp/k3s/cilium-bgp.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
- name: Apply BGP manifests
|
||||
ansible.builtin.command:
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
---
|
||||
- name: Deploy calico
|
||||
include_tasks: calico.yml
|
||||
ansible.builtin.include_tasks: calico.yml
|
||||
tags: calico
|
||||
when: calico_iface is defined and cilium_iface is not defined
|
||||
|
||||
- name: Deploy cilium
|
||||
include_tasks: cilium.yml
|
||||
ansible.builtin.include_tasks: cilium.yml
|
||||
tags: cilium
|
||||
when: cilium_iface is defined
|
||||
|
||||
- name: Deploy metallb pool
|
||||
include_tasks: metallb.yml
|
||||
ansible.builtin.include_tasks: metallb.yml
|
||||
tags: metallb
|
||||
when: kube_vip_lb_ip_range is not defined and (not cilium_bgp or cilium_iface is not defined)
|
||||
|
||||
- name: Remove tmp directory used for manifests
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /tmp/k3s
|
||||
state: absent
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
---
|
||||
- name: Create manifests directory for temp configuration
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /tmp/k3s
|
||||
state: directory
|
||||
owner: "{{ ansible_user_id }}"
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
with_items: "{{ groups[group_name_master | default('master')] }}"
|
||||
run_once: true
|
||||
|
||||
- name: Delete outdated metallb replicas
|
||||
shell: |-
|
||||
ansible.builtin.shell: |-
|
||||
set -o pipefail
|
||||
|
||||
REPLICAS=$(k3s kubectl --namespace='metallb-system' get replicasets \
|
||||
@@ -30,23 +30,23 @@
|
||||
with_items: "{{ groups[group_name_master | default('master')] }}"
|
||||
|
||||
- name: Copy metallb CRs manifest to first master
|
||||
template:
|
||||
src: "metallb.crs.j2"
|
||||
dest: "/tmp/k3s/metallb-crs.yaml"
|
||||
ansible.builtin.template:
|
||||
src: metallb.crs.j2
|
||||
dest: /tmp/k3s/metallb-crs.yaml
|
||||
owner: "{{ ansible_user_id }}"
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
with_items: "{{ groups[group_name_master | default('master')] }}"
|
||||
run_once: true
|
||||
|
||||
- name: Test metallb-system namespace
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
k3s kubectl -n metallb-system
|
||||
changed_when: false
|
||||
with_items: "{{ groups[group_name_master | default('master')] }}"
|
||||
run_once: true
|
||||
|
||||
- name: Wait for MetalLB resources
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
k3s kubectl wait {{ item.resource }}
|
||||
--namespace='metallb-system'
|
||||
{% if item.name | default(False) -%}{{ item.name }}{%- endif %}
|
||||
@@ -84,7 +84,7 @@
|
||||
label: "{{ item.description }}"
|
||||
|
||||
- name: Set metallb webhook service name
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
metallb_webhook_service_name: >-
|
||||
{{
|
||||
(
|
||||
@@ -98,14 +98,14 @@
|
||||
}}
|
||||
|
||||
- name: Test metallb-system webhook-service endpoint
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
k3s kubectl -n metallb-system get endpoints {{ metallb_webhook_service_name }}
|
||||
changed_when: false
|
||||
with_items: "{{ groups[group_name_master | default('master')] }}"
|
||||
run_once: true
|
||||
|
||||
- name: Apply metallb CRs
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
k3s kubectl apply -f /tmp/k3s/metallb-crs.yaml
|
||||
--timeout='{{ metal_lb_available_timeout }}'
|
||||
register: this
|
||||
@@ -115,7 +115,7 @@
|
||||
retries: 5
|
||||
|
||||
- name: Test metallb-system resources for Layer 2 configuration
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
k3s kubectl -n metallb-system get {{ item }}
|
||||
changed_when: false
|
||||
run_once: true
|
||||
@@ -125,7 +125,7 @@
|
||||
- L2Advertisement
|
||||
|
||||
- name: Test metallb-system resources for BGP configuration
|
||||
command: >-
|
||||
ansible.builtin.command: >-
|
||||
k3s kubectl -n metallb-system get {{ item }}
|
||||
changed_when: false
|
||||
run_once: true
|
||||
|
||||
Reference in New Issue
Block a user