mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2025-12-25 18:23:05 +01:00
Fix CI (#332)
* Update pre-commit actions This was done by running "pre-commit autoupdate --freeze". * Remove pre-commit only dependencies from requirements.in Including them in the file would create the illusion that those were the versions actually used in CI, but they are not. The exact versions are determined by the pre-commit hooks which are pinned in .pre-commit-config.yaml. * Ansible Lint: Fix role-name[path] * Ansible Lint: Fix name[play] * Ansible Lint: Fix key-order[task] * Ansible Lint: Fix jinja[spacing] * Ansible Lint: Fix no-free-form * Ansible Lint: Fix var-naming[no-reserved] * Ansible Lint: Fix yaml[comments] * Ansible Lint: Fix yaml[line-length] * Ansible Lint: Fix name[casing] * Ansible Lint: Fix no-changed-when * Ansible Lint: Fix fqcn[action] * Ansible Lint: Fix args[module] * Improve task naming
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
---
|
||||
|
||||
- name: Clean previous runs of k3s-init
|
||||
- name: Stop k3s-init
|
||||
systemd:
|
||||
name: k3s-init
|
||||
state: stopped
|
||||
failed_when: false
|
||||
|
||||
- name: Clean previous runs of k3s-init
|
||||
- name: Clean previous runs of k3s-init # noqa command-instead-of-module
|
||||
# The systemd module does not support "reset-failed", so we need to resort to command.
|
||||
command: systemctl reset-failed k3s-init
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
args:
|
||||
warn: false # The ansible systemd module does not support reset-failed
|
||||
|
||||
- name: Deploy vip manifest
|
||||
include_tasks: vip.yml
|
||||
@@ -28,6 +27,7 @@
|
||||
creates: "{{ systemd_dir }}/k3s.service"
|
||||
|
||||
- name: Verification
|
||||
when: not ansible_check_mode
|
||||
block:
|
||||
- name: Verify that all nodes actually joined (check k3s-init.service if this fails)
|
||||
command:
|
||||
@@ -49,7 +49,6 @@
|
||||
name: k3s-init
|
||||
state: stopped
|
||||
failed_when: false
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Copy K3s service file
|
||||
register: k3s_service
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
- name: "Download to first master: manifest for metallb-{{ metal_lb_type }}"
|
||||
ansible.builtin.get_url:
|
||||
url: "https://raw.githubusercontent.com/metallb/metallb/{{ metal_lb_controller_tag_version }}/config/manifests/metallb-{{metal_lb_type}}.yaml" # noqa yaml[line-length]
|
||||
url: "https://raw.githubusercontent.com/metallb/metallb/{{ metal_lb_controller_tag_version }}/config/manifests/metallb-{{ metal_lb_type }}.yaml" # noqa yaml[line-length]
|
||||
dest: "/var/lib/rancher/k3s/server/manifests/metallb-crds.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
@@ -1,4 +1,4 @@
|
||||
---
|
||||
- name: reboot server
|
||||
- name: Reboot server
|
||||
become: true
|
||||
reboot:
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
---
|
||||
- name: Set same timezone on every Server
|
||||
timezone:
|
||||
community.general.timezone:
|
||||
name: "{{ system_timezone }}"
|
||||
when: (system_timezone is defined) and (system_timezone != "Your/Timezone")
|
||||
|
||||
- name: Set SELinux to disabled state
|
||||
selinux:
|
||||
ansible.posix.selinux:
|
||||
state: disabled
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- name: Enable IPv4 forwarding
|
||||
sysctl:
|
||||
ansible.posix.sysctl:
|
||||
name: net.ipv4.ip_forward
|
||||
value: "1"
|
||||
state: present
|
||||
reload: yes
|
||||
|
||||
- name: Enable IPv6 forwarding
|
||||
sysctl:
|
||||
ansible.posix.sysctl:
|
||||
name: net.ipv6.conf.all.forwarding
|
||||
value: "1"
|
||||
state: present
|
||||
reload: yes
|
||||
|
||||
- name: Enable IPv6 router advertisements
|
||||
sysctl:
|
||||
ansible.posix.sysctl:
|
||||
name: net.ipv6.conf.all.accept_ra
|
||||
value: "2"
|
||||
state: present
|
||||
@@ -38,13 +38,13 @@
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- name: Load br_netfilter
|
||||
modprobe:
|
||||
community.general.modprobe:
|
||||
name: br_netfilter
|
||||
state: present
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- name: Set bridge-nf-call-iptables (just to be sure)
|
||||
sysctl:
|
||||
ansible.posix.sysctl:
|
||||
name: "{{ item }}"
|
||||
value: "1"
|
||||
state: present
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
---
|
||||
- name: reboot containers
|
||||
command:
|
||||
"pct reboot {{ item }}"
|
||||
loop: "{{ proxmox_lxc_filtered_ids }}"
|
||||
- name: Reboot containers
|
||||
block:
|
||||
- name: Get container ids from filtered files
|
||||
set_fact:
|
||||
proxmox_lxc_filtered_ids: >-
|
||||
{{ proxmox_lxc_filtered_files | map("split", "/") | map("last") | map("split", ".") | map("first") }}
|
||||
- name: Reboot container
|
||||
command: "pct reboot {{ item }}"
|
||||
loop: "{{ proxmox_lxc_filtered_ids }}"
|
||||
changed_when: true
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
---
|
||||
- name: check for container files that exist on this host
|
||||
- name: Check for container files that exist on this host
|
||||
stat:
|
||||
path: "/etc/pve/lxc/{{ item }}.conf"
|
||||
loop: "{{ proxmox_lxc_ct_ids }}"
|
||||
register: stat_results
|
||||
|
||||
- name: filter out files that do not exist
|
||||
- name: Filter out files that do not exist
|
||||
set_fact:
|
||||
proxmox_lxc_filtered_files:
|
||||
'{{ stat_results.results | rejectattr("stat.exists", "false") | map(attribute="stat.path") }}'
|
||||
|
||||
# used for the reboot handler
|
||||
- name: get container ids from filtered files
|
||||
set_fact:
|
||||
proxmox_lxc_filtered_ids:
|
||||
'{{ proxmox_lxc_filtered_files | map("split", "/") | map("last") | map("split", ".") | map("first") }}'
|
||||
|
||||
# https://gist.github.com/triangletodd/02f595cd4c0dc9aac5f7763ca2264185
|
||||
- name: Ensure lxc config has the right apparmor profile
|
||||
lineinfile:
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
---
|
||||
- name: reboot
|
||||
- name: Reboot
|
||||
reboot:
|
||||
|
||||
@@ -47,20 +47,16 @@
|
||||
- raspberry_pi|default(false)
|
||||
- ansible_facts.lsb.description|default("") is match("Debian.*bullseye")
|
||||
|
||||
- name: execute OS related tasks on the Raspberry Pi - {{ action }}
|
||||
- name: Execute OS related tasks on the Raspberry Pi - {{ action_ }}
|
||||
include_tasks: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ action }}/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml"
|
||||
- "{{ action }}/{{ detected_distribution }}.yml"
|
||||
- "{{ action }}/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||
- "{{ action }}/{{ ansible_distribution }}.yml"
|
||||
- "{{ action }}/default.yml"
|
||||
- "{{ action_ }}/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml"
|
||||
- "{{ action_ }}/{{ detected_distribution }}.yml"
|
||||
- "{{ action_ }}/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||
- "{{ action_ }}/{{ ansible_distribution }}.yml"
|
||||
- "{{ action_ }}/default.yml"
|
||||
vars:
|
||||
action: >-
|
||||
{% if state == "present" -%}
|
||||
setup
|
||||
{%- else -%}
|
||||
teardown
|
||||
{%- endif %}
|
||||
action_: >-
|
||||
{% if state == "present" %}setup{% else %}teardown{% endif %}
|
||||
when:
|
||||
- raspberry_pi|default(false)
|
||||
|
||||
@@ -8,20 +8,22 @@
|
||||
notify: reboot
|
||||
|
||||
- name: Install iptables
|
||||
apt: name=iptables state=present
|
||||
apt:
|
||||
name: iptables
|
||||
state: present
|
||||
|
||||
- name: Flush iptables before changing to iptables-legacy
|
||||
iptables:
|
||||
flush: true
|
||||
|
||||
- name: Changing to iptables-legacy
|
||||
alternatives:
|
||||
community.general.alternatives:
|
||||
path: /usr/sbin/iptables-legacy
|
||||
name: iptables
|
||||
register: ip4_legacy
|
||||
|
||||
- name: Changing to ip6tables-legacy
|
||||
alternatives:
|
||||
community.general.alternatives:
|
||||
path: /usr/sbin/ip6tables-legacy
|
||||
name: ip6tables
|
||||
register: ip6_legacy
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
check_mode: false
|
||||
|
||||
- name: Umount filesystem
|
||||
mount:
|
||||
ansible.posix.mount:
|
||||
path: "{{ item }}"
|
||||
state: unmounted
|
||||
with_items:
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
- name: reboot containers
|
||||
command:
|
||||
"pct reboot {{ item }}"
|
||||
loop: "{{ proxmox_lxc_filtered_ids }}"
|
||||
1
roles/reset_proxmox_lxc/handlers/main.yml
Symbolic link
1
roles/reset_proxmox_lxc/handlers/main.yml
Symbolic link
@@ -0,0 +1 @@
|
||||
../../proxmox_lxc/handlers/main.yml
|
||||
@@ -1,21 +1,15 @@
|
||||
---
|
||||
- name: check for container files that exist on this host
|
||||
- name: Check for container files that exist on this host
|
||||
stat:
|
||||
path: "/etc/pve/lxc/{{ item }}.conf"
|
||||
loop: "{{ proxmox_lxc_ct_ids }}"
|
||||
register: stat_results
|
||||
|
||||
- name: filter out files that do not exist
|
||||
- name: Filter out files that do not exist
|
||||
set_fact:
|
||||
proxmox_lxc_filtered_files:
|
||||
'{{ stat_results.results | rejectattr("stat.exists", "false") | map(attribute="stat.path") }}'
|
||||
|
||||
# used for the reboot handler
|
||||
- name: get container ids from filtered files
|
||||
set_fact:
|
||||
proxmox_lxc_filtered_ids:
|
||||
'{{ proxmox_lxc_filtered_files | map("split", "/") | map("last") | map("split", ".") | map("first") }}'
|
||||
|
||||
- name: Remove LXC apparmor profile
|
||||
lineinfile:
|
||||
dest: "{{ item }}"
|
||||
|
||||
Reference in New Issue
Block a user