|
| 1 | +--- |
| 2 | +- name: "Check if the repository tarball exists" |
| 3 | + ansible.builtin.stat: |
| 4 | + path: "{{ aap_archive_dest }}" |
| 5 | + register: __aap_archive_tarball_exists |
| 6 | + failed_when: false |
| 7 | + changed_when: false |
| 8 | + |
| 9 | +# If the repository tarball exists, you can force a refresh by setting aap_archive_refresh to true |
| 10 | +- name: "Package AAP configuration repository and serve via HTTP" |
| 11 | + block: |
| 12 | + - name: "Create temporary directory" |
| 13 | + ansible.builtin.file: |
| 14 | + path: "{{ aap_archive_tmp_dir }}" |
| 15 | + state: directory |
| 16 | + mode: "0750" |
| 17 | + |
| 18 | + - name: "Clone the configuration repository" |
| 19 | + ansible.builtin.git: |
| 20 | + repo: "{{ aap_config_repo }}" |
| 21 | + dest: "{{ aap_archive_tmp_dir }}" |
| 22 | + version: "{{ aap_config_version }}" |
| 23 | + |
| 24 | + - name: "Create tarball of the repository" |
| 25 | + ansible.builtin.archive: |
| 26 | + path: "{{ aap_archive_tmp_dir }}" |
| 27 | + dest: "{{ aap_archive_dest }}" |
| 28 | + format: gz |
| 29 | + ignore_errors: "{{ ansible_check_mode }}" |
| 30 | + |
| 31 | + - name: "Set container recreate flag" |
| 32 | + ansible.builtin.set_fact: |
| 33 | + __aap_archive_container_recreate: true |
| 34 | + always: |
| 35 | + - name: "Remove temporary directory" |
| 36 | + ansible.builtin.file: |
| 37 | + path: "{{ aap_archive_tmp_dir }}" |
| 38 | + state: absent |
| 39 | + no_log: true |
| 40 | + when: > |
| 41 | + __aap_archive_tarball_exists.stat.exists is false or |
| 42 | + __aap_archive_tarball_exists.stat.exists is not defined or |
| 43 | + aap_archive_refresh | default(false) | bool |
| 44 | +
|
| 45 | +- name: "Run container to publish the AAP configuration" |
| 46 | + containers.podman.podman_container: |
| 47 | + name: "aap-archive-srv" |
| 48 | + image: "{{ aap_archive_image }}" |
| 49 | + authfile: "{{ aap_archive_authfile }}" |
| 50 | + state: started |
| 51 | + restart_policy: always |
| 52 | + recreate: "{{ __aap_archive_container_recreate | default(false) | bool }}" |
| 53 | + user: "1001" |
| 54 | + command: "/usr/libexec/s2i/run" |
| 55 | + security_opt: |
| 56 | + - no-new-privileges |
| 57 | + cap_drop: |
| 58 | + - ALL |
| 59 | + volumes: |
| 60 | + - "{{ aap_archive_dest }}:/opt/app-root/src/aap-config-archive.tar.gz:Z" |
| 61 | + publish: |
| 62 | + - "{{ aap_archive_port }}:8080" |
0 commit comments