From 79adac839f6821800463085de82e8b1a22473607 Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Thu, 22 May 2025 10:41:01 +0200 Subject: [PATCH] Improve deploy-crc-cloud role What changed: - improve condition that is veryfing if cluster is healthy - move htpasswd container image to be created task before to avoid multiple time rebuilding same image - add "no_log" to avoid display users passwords Signed-off-by: Daniel Pawlik --- .../deploy-crc-cloud/tasks/get_htpasswd.yaml | 22 ------------------ .../tasks/set_credentials.yaml | 23 +++++++++++++++++++ .../tasks/wait_cluster_become_healthy.yaml | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ansible/roles/deploy-crc-cloud/tasks/get_htpasswd.yaml b/ansible/roles/deploy-crc-cloud/tasks/get_htpasswd.yaml index 26289d4b..8d3c65c3 100644 --- a/ansible/roles/deploy-crc-cloud/tasks/get_htpasswd.yaml +++ b/ansible/roles/deploy-crc-cloud/tasks/get_htpasswd.yaml @@ -1,26 +1,4 @@ --- -- name: Create temporary directory - ansible.builtin.tempfile: - state: directory - register: _temp_dir - -- name: Create Dockerfile - ansible.builtin.copy: - content: | - FROM quay.io/centos/centos:stream9-minimal - RUN microdnf --setopt=tsflags=nodocs --setopt=install_weak_deps=0 install -y httpd-tools - ENTRYPOINT ["htpasswd", "-Bbn"] - dest: "{{ _temp_dir.path }}/Dockerfile" - -- name: Build container image for htpasswd - ansible.builtin.command: | - podman build -t localhost/htpasswd:latest -f {{ _temp_dir.path }}/Dockerfile - - name: "Get htpasswd for {{ user.name }}" ansible.builtin.shell: | podman run --rm -ti localhost/htpasswd:latest {{ user.name }} {{ user.password }} >> htpasswd.txt - -- name: Remove temporary directory - ansible.builtin.file: - path: "{{ _temp_dir.path }}" - state: absent diff --git a/ansible/roles/deploy-crc-cloud/tasks/set_credentials.yaml b/ansible/roles/deploy-crc-cloud/tasks/set_credentials.yaml index b8ec27f3..4f78d9d6 100644 --- a/ansible/roles/deploy-crc-cloud/tasks/set_credentials.yaml +++ b/ansible/roles/deploy-crc-cloud/tasks/set_credentials.yaml @@ -5,11 +5,29 @@ path: htpasswd.txt state: absent +- name: Create temporary directory + ansible.builtin.tempfile: + state: directory + register: _temp_dir + +- name: Create Dockerfile + ansible.builtin.copy: + content: | + FROM quay.io/centos/centos:stream9-minimal + RUN microdnf --setopt=tsflags=nodocs --setopt=install_weak_deps=0 install -y httpd-tools + ENTRYPOINT ["htpasswd", "-Bbn"] + dest: "{{ _temp_dir.path }}/Dockerfile" + +- name: Build container image for htpasswd + ansible.builtin.command: | + podman build -t localhost/htpasswd:latest -f {{ _temp_dir.path }}/Dockerfile + - name: Get htpasswd ansible.builtin.include_tasks: get_htpasswd.yaml loop: "{{ users }}" loop_control: loop_var: user + no_log: true - name: Cleanup htpasswd.txt file ansible.builtin.shell: | @@ -25,3 +43,8 @@ - name: Replace htpass-secret ansible.builtin.command: oc replace -f /tmp/htpass-secret.yaml + +- name: Remove temporary directory + ansible.builtin.file: + path: "{{ _temp_dir.path }}" + state: absent diff --git a/ansible/roles/deploy-crc-cloud/tasks/wait_cluster_become_healthy.yaml b/ansible/roles/deploy-crc-cloud/tasks/wait_cluster_become_healthy.yaml index cd45ca20..453fe3fc 100644 --- a/ansible/roles/deploy-crc-cloud/tasks/wait_cluster_become_healthy.yaml +++ b/ansible/roles/deploy-crc-cloud/tasks/wait_cluster_become_healthy.yaml @@ -9,7 +9,7 @@ retries: "{{ max_retries }}" delay: "{{ retry_delay }}" until: "'False' not in component_status.stdout_lines" - failed_when: "'False' in component_status.stdout_lines and retry_count >= max_retries" + failed_when: "'False' in component_status.stdout_lines" ignore_errors: true - name: Output success message if components are healthy