Skip to content
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

Lightspeed 101 Red Hat 1 image changes #552

Merged
merged 4 commits into from
Jan 26, 2024
Merged
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
12 changes: 12 additions & 0 deletions images/ansible/common/10_image_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,15 @@
ansible.builtin.file:
path: "~{{ ansible_user }}/.bash_history"
state: absent

- name: Logout of container registries
become: true
become_user: "{{ item }}"
containers.podman.podman_logout:
all: true
no_log: true
loop:
- "{{ student_username }}"
- awx
- root
- "{{ ansible_user }}"
10 changes: 4 additions & 6 deletions images/ansible/common/50_install_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@
until: __controller_setup_async_result.finished
register: __controller_setup_async_result
when: __controller_setup_async.ansible_job_id is defined
rescue:
- name: Print error message
ansible.builtin.fail:
msg: |
"Rescue - Controller installation failed.
"{{ __controller_setup_async_result }}"
always:
- name: Print setup output
ansible.builtin.debug:
var: __controller_setup_async_result

- name: Wait for Automation Controller to be up
ansible.builtin.uri:
Expand Down
2 changes: 1 addition & 1 deletion images/ansible/common/5_configure_users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
line: >-
PasswordAuthentication yes

- name: Configure sudoers for wheel group
- name: Configure sudoers for wheel group # noqa args[module]
community.general.sudoers:
name: wheel_sudoers
state: present
Expand Down
17 changes: 13 additions & 4 deletions images/ansible/common/60_check_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
# Converts environment variables to YAML equivalent and creates facts.
##
- name: Make sure track_slug variable is set
run_once: true
delegate_to: localhost
ansible.builtin.assert:
that: lookup('ansible.builtin.env', 'TRACK_SLUG') or track_slug is defined
quiet: true
fail_msg: "Please set the Ansible 'track_slug' variable or 'TRACK_SLUG' environment variable"

- name: Set track_slug fact from TRACK_SLUG environment variable
run_once: true
delegate_to: localhost
ansible.builtin.set_fact:
track_slug: "{{ lookup('ansible.builtin.env', 'TRACK_SLUG') }}"
when:
Expand All @@ -17,6 +21,7 @@

- name: Include vars file from vars directory
when: (track_slug is defined) and (track_slug | length > 0)
run_once: true
delegate_to: localhost
become: false
no_log: true
Expand All @@ -42,17 +47,23 @@
when: vars_file.stat.exists

- name: Map required variables to facts
run_once: true
delegate_to: localhost
when: (extra_vars is defined) and (extra_vars | length > 0)
no_log: true
ansible.builtin.set_fact:
"{{ __extra_vars_item.name }}": "{{ lookup('ansible.builtin.env', __extra_vars_item.env | default(omit) ) or lookup('ansible.builtin.vars', __extra_vars_item.name | default(omit)) }}" # yamllint disable-line rule:line-length
register: __extra_vars_results
when: (extra_vars is defined) and (extra_vars | length > 0)
loop_control:
loop_var: __extra_vars_item
label: "{{ __extra_vars_item.name }}"
loop: "{{ extra_vars }}"
no_log: true

- name: Check required variables are set
run_once: true
when: (__extra_vars_results.results is defined) and (__extra_vars_results.results | length > 0)
delegate_to: localhost
no_log: true
ansible.builtin.assert:
that:
- lookup('ansible.builtin.vars', __extra_vars_results_item.__extra_vars_item.name) | length > 0
Expand All @@ -61,9 +72,7 @@
- Environment variable - {{ __extra_vars_results_item.__extra_vars_item.env | default('Not applicable - ignore') }}.
- Ansible variable - {{ __extra_vars_results_item.__extra_vars_item.name }}.
quiet: true
when: (__extra_vars_results.results is defined) and (__extra_vars_results.results | length > 0)
loop: "{{ __extra_vars_results.results }}"
loop_control:
loop_var: __extra_vars_results_item
label: "{{ __extra_vars_results_item.__extra_vars_item.name }}"
no_log: true
19 changes: 12 additions & 7 deletions images/ansible/common/70_controller_post_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
controller_password: "{{ controller_password }}"
controller_host: "{{ controller_hostname }}"
validate_certs: "{{ controller_validate_certs }}"
no_log: true

- name: Install EPEL repository
ansible.builtin.yum_repository:
Expand Down Expand Up @@ -71,7 +72,7 @@
# Added for student command line tasks
- name: Copy ansible-navigator.yml template - {{ student_username }}
ansible.builtin.template:
src: "ansible-navigator.yml.j2"
src: "{{ track_slug }}/ansible-navigator.yml.j2"
dest: "~{{ student_username }}/.ansible-navigator.yml"
mode: "644"
owner: "{{ student_username }}"
Expand Down Expand Up @@ -192,16 +193,19 @@
loop:
- "{{ student_username }}"
- awx
- root
- "{{ ansible_user }}"

# TODO: Fix with inner / outer loop for user and controller_execution_environments var
- name: Pull execution environment images - awx
become_user: "awx"
containers.podman.podman_image:
name: "{{ item.image }}"
loop: "{{ controller_execution_environments }}"
register: __podman_pull_supported_awx
until: __podman_pull_supported_awx is not failed
retries: 40
delay: 2
retries: 180
delay: 1

- name: Pull execution environment images - {{ student_username }}
become_user: "{{ student_username }}"
Expand All @@ -210,15 +214,16 @@
loop: "{{ controller_execution_environments }}"
register: __podman_pull_supported_student
until: __podman_pull_supported_student is not failed
retries: 40
delay: 2
retries: 180
delay: 1

# Added for track lifecycle scripts - root
- name: Pull execution environment images - {{ ansible_user_id }}
containers.podman.podman_image:
name: "{{ item.image }}"
become: true
loop: "{{ controller_execution_environments }}"
register: __podman_pull_supported_student
until: __podman_pull_supported_student is not failed
retries: 40
delay: 2
retries: 180
delay: 1
Loading
Loading