From 88f552de45401e968eb89405c4b267b590342220 Mon Sep 17 00:00:00 2001 From: Adam Leiner Date: Fri, 12 Apr 2024 15:33:05 -0400 Subject: [PATCH] initial pass at resolving linting --- roles/rke2_agent/tasks/main.yml | 2 +- roles/rke2_common/tasks/add-registry-config.yml | 4 ++-- roles/rke2_common/tasks/calculate_rke2_version.yml | 3 ++- roles/rke2_common/tasks/cis-hardening.yml | 5 ++++- roles/rke2_common/tasks/previous_install.yml | 2 +- roles/rke2_common/tasks/rpm_install.yml | 8 ++++++-- roles/rke2_common/tasks/tarball_install.yml | 2 +- roles/rke2_server/tasks/first_server.yml | 2 +- roles/rke2_server/tasks/main.yml | 2 +- roles/rke2_server/tasks/other_servers.yml | 2 +- 10 files changed, 20 insertions(+), 12 deletions(-) diff --git a/roles/rke2_agent/tasks/main.yml b/roles/rke2_agent/tasks/main.yml index 07654f83..4d9cfdeb 100644 --- a/roles/rke2_agent/tasks/main.yml +++ b/roles/rke2_agent/tasks/main.yml @@ -2,7 +2,7 @@ - name: RKE2 agent and server tasks vars: - caller_role_name: agent + rke2_common_caller_role_name: agent ansible.builtin.include_role: name: rke2_common tasks_from: main diff --git a/roles/rke2_common/tasks/add-registry-config.yml b/roles/rke2_common/tasks/add-registry-config.yml index 9af0add6..664afe84 100644 --- a/roles/rke2_common/tasks/add-registry-config.yml +++ b/roles/rke2_common/tasks/add-registry-config.yml @@ -12,7 +12,7 @@ mode: '0640' owner: root group: root - when: caller_role_name == "server" + when: rke2_common_caller_role_name == "server" notify: Restart rke2-server - name: Add registry configuration file @@ -22,5 +22,5 @@ mode: '0640' owner: root group: root - when: caller_role_name == "agent" + when: rke2_common_caller_role_name == "agent" notify: Restart rke2-agent diff --git a/roles/rke2_common/tasks/calculate_rke2_version.yml b/roles/rke2_common/tasks/calculate_rke2_version.yml index 783484a9..e18ae9c5 100644 --- a/roles/rke2_common/tasks/calculate_rke2_version.yml +++ b/roles/rke2_common/tasks/calculate_rke2_version.yml @@ -24,7 +24,8 @@ - name: Set rke2_full_version fact ansible.builtin.set_fact: - rke2_full_version: "{{ rke2_full_version.stdout if ((install_rke2_version is not defined) or (install_rke2_version|length == 0)) else install_rke2_version }}" # yamllint disable-line rule:line-length + rke2_full_version: "{{ rke2_full_version.stdout if ((install_rke2_version is not defined) or + (install_rke2_version | length == 0)) else install_rke2_version }}" - name: Set dot version ansible.builtin.shell: diff --git a/roles/rke2_common/tasks/cis-hardening.yml b/roles/rke2_common/tasks/cis-hardening.yml index 7a65add5..24fdaf3a 100644 --- a/roles/rke2_common/tasks/cis-hardening.yml +++ b/roles/rke2_common/tasks/cis-hardening.yml @@ -52,4 +52,7 @@ - name: Reboot the machine (Wait for 5 min) ansible.builtin.reboot: reboot_timeout: 300 - when: (sysctl_operation_yum.changed or sysctl_operation_tarball.changed) and rke2_running is defined and rke2_running + when: + - (sysctl_operation_yum.changed or sysctl_operation_tarball.changed) + - rke2_running is defined + - rke2_running diff --git a/roles/rke2_common/tasks/previous_install.yml b/roles/rke2_common/tasks/previous_install.yml index 6242c646..c00f2f18 100644 --- a/roles/rke2_common/tasks/previous_install.yml +++ b/roles/rke2_common/tasks/previous_install.yml @@ -60,5 +60,5 @@ - name: Determine if current version differs what what is being installed ansible.builtin.set_fact: - installed_rke2_version: "{{installed_rke2_version_tmp.stdout}}" + installed_rke2_version: "{{ installed_rke2_version_tmp.stdout }}" when: rke2_binary.stat.exists diff --git a/roles/rke2_common/tasks/rpm_install.yml b/roles/rke2_common/tasks/rpm_install.yml index 4a9fcffb..e9d5f230 100644 --- a/roles/rke2_common/tasks/rpm_install.yml +++ b/roles/rke2_common/tasks/rpm_install.yml @@ -18,7 +18,9 @@ when: - not stat_rke2_common_repo.stat.exists - ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == "Rocky" - - ansible_facts['distribution_major_version'] == "7" or ansible_facts['distribution_major_version'] == "8" or ansible_facts['distribution_major_version'] == "9" + - ansible_facts['distribution_major_version'] == "7" or + ansible_facts['distribution_major_version'] == "8" or + ansible_facts['distribution_major_version'] == "9" # Does the Rancher RKE2 versioned repo exist already - name: Check to see if rke2 versioned repo exists @@ -38,7 +40,9 @@ when: - not stat_rke2_common_repo.stat.exists - ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == "Rocky" - - ansible_facts['distribution_major_version'] == "7" or ansible_facts['distribution_major_version'] == "8" or ansible_facts['distribution_major_version'] == "9" + - ansible_facts['distribution_major_version'] == "7" or + ansible_facts['distribution_major_version'] == "8" or + ansible_facts['distribution_major_version'] == "9" - name: YUM-Based | Install rke2-server ansible.builtin.yum: diff --git a/roles/rke2_common/tasks/tarball_install.yml b/roles/rke2_common/tasks/tarball_install.yml index 0c2df29f..ba1c6f92 100644 --- a/roles/rke2_common/tasks/tarball_install.yml +++ b/roles/rke2_common/tasks/tarball_install.yml @@ -66,7 +66,7 @@ - name: Set tarball RKE2 version var ansible.builtin.set_fact: - tarball_rke2_version: "{{tarball_rke2_version_tmp.stdout}}" + tarball_rke2_version: "{{ tarball_rke2_version_tmp.stdout }}" - name: Determine if current version differs what what is being installed ansible.builtin.set_fact: diff --git a/roles/rke2_server/tasks/first_server.yml b/roles/rke2_server/tasks/first_server.yml index 0b85d8a6..0b71ea88 100644 --- a/roles/rke2_server/tasks/first_server.yml +++ b/roles/rke2_server/tasks/first_server.yml @@ -32,7 +32,7 @@ - name: Extract the hostname-override parameter from the kubelet process ansible.builtin.set_fact: - kubelet_hostname_override_parameter: "{{ kubelet_check.stdout |\ + kubelet_hostname_override_parameter: "{{ kubelet_check.stdout | \ regex_search('\\s--hostname-override=((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]))\\s',\ '\\1') }}" diff --git a/roles/rke2_server/tasks/main.yml b/roles/rke2_server/tasks/main.yml index fb7f4111..e0efd786 100644 --- a/roles/rke2_server/tasks/main.yml +++ b/roles/rke2_server/tasks/main.yml @@ -2,7 +2,7 @@ - name: RKE2 agent and server tasks vars: - caller_role_name: server + rke2_common_caller_role_name: server ansible.builtin.include_role: name: rke2_common tasks_from: main diff --git a/roles/rke2_server/tasks/other_servers.yml b/roles/rke2_server/tasks/other_servers.yml index dce57c49..664e0e83 100644 --- a/roles/rke2_server/tasks/other_servers.yml +++ b/roles/rke2_server/tasks/other_servers.yml @@ -57,7 +57,7 @@ - name: Extract the hostname-override parameter from the kubelet process ansible.builtin.set_fact: - kubelet_hostname_override_parameter: "{{ kubelet_check.stdout |\ + kubelet_hostname_override_parameter: "{{ kubelet_check.stdout | \ regex_search('\\s--hostname-override=((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]))\\s',\ '\\1') }}"