Skip to content

Commit

Permalink
created shared image storage role
Browse files Browse the repository at this point in the history
  • Loading branch information
adworjan committed Nov 20, 2023
1 parent 0771a39 commit a5d749f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ansiblesharedimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Set up shared images storage
hosts: all
become: true

vars:
# username for private automation hub for EE or to password protected registry
registry_user: "USERNAME"
# password for private automation hub for EE or to password protected registry
registry_pass: "PASSWORD"
# specific image to pull
ansible_image: "registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:latest"
# location of additional image store for shared storage
additionalimagestores: "/var/lib/mycontainers-shared"

roles:
- shadowman_dev_shared_image_store
3 changes: 3 additions & 0 deletions roles/shadowman_dev_shared_image_store/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
ansible_image: "registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel8:latest"
additionalimagestores: "/var/lib/mycontainers-shared"
27 changes: 27 additions & 0 deletions roles/shadowman_dev_shared_image_store/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

- name: Ensure shared image directory exists
ansible.builtin.file:
path: "{{ additionalimagestores }}"
state: directory
owner: root
group: root
mode: a+rx
recurse: true

- name: Install podman
ansible.builtin.dnf:
name: podman
state: present

- name: Check if EE present
ansible.builtin.command: "podman --root {{ additionalimagestores }} image exists {{ ansible_image }}"
register: exists
changed_when: exists.rc == 1
failed_when: exists.rc > 1

- name: Pull EE only if not present
ansible.builtin.command: "podman pull --root {{ additionalimagestores }} --creds={{ registry_user }}:{{ registry_pass }} {{ ansible_image }}"
register: ee
changed_when: ee.rc == 0
when: exists.rc == 1

0 comments on commit a5d749f

Please sign in to comment.