Skip to content

Improve deploy-crc-cloud role #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions ansible/roles/deploy-crc-cloud/tasks/get_htpasswd.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions ansible/roles/deploy-crc-cloud/tasks/set_credentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading