|
| 1 | +--- |
| 2 | +- name: Pull Vulnerability Frontend container image |
| 3 | + containers.podman.podman_image: |
| 4 | + name: "{{ iop_vulnerability_frontend_container_image }}:{{ iop_vulnerability_frontend_container_tag }}" |
| 5 | + state: present |
| 6 | + |
| 7 | +- name: Ensure parent assets directory exists |
| 8 | + ansible.builtin.file: |
| 9 | + path: /var/lib/foreman/public/assets/apps |
| 10 | + state: directory |
| 11 | + owner: foreman |
| 12 | + group: foreman |
| 13 | + mode: '0755' |
| 14 | + |
| 15 | +- name: Ensure assets directory exists |
| 16 | + ansible.builtin.file: |
| 17 | + path: "{{ iop_vulnerability_frontend_assets_path }}" |
| 18 | + state: directory |
| 19 | + owner: foreman |
| 20 | + group: foreman |
| 21 | + mode: '0755' |
| 22 | + |
| 23 | +- name: Create temporary container for asset extraction |
| 24 | + containers.podman.podman_container: |
| 25 | + name: iop-vulnerability-frontend-temp |
| 26 | + image: "{{ iop_vulnerability_frontend_container_image }}:{{ iop_vulnerability_frontend_container_tag }}" |
| 27 | + state: created |
| 28 | + |
| 29 | +- name: Extract vulnerability frontend assets from container |
| 30 | + containers.podman.podman_container_copy: |
| 31 | + container: iop-vulnerability-frontend-temp |
| 32 | + src: "{{ iop_vulnerability_frontend_source_path }}" |
| 33 | + dest: "{{ iop_vulnerability_frontend_assets_path }}" |
| 34 | + from_container: true |
| 35 | + |
| 36 | +- name: Remove temporary container |
| 37 | + containers.podman.podman_container: |
| 38 | + name: iop-vulnerability-frontend-temp |
| 39 | + state: absent |
| 40 | + |
| 41 | +- name: Set ownership of vulnerability frontend assets |
| 42 | + ansible.builtin.file: |
| 43 | + path: "{{ iop_vulnerability_frontend_assets_path }}" |
| 44 | + owner: foreman |
| 45 | + group: foreman |
| 46 | + recurse: true |
| 47 | + |
| 48 | +- name: Set SELinux context for vulnerability frontend assets |
| 49 | + ansible.builtin.command: |
| 50 | + cmd: "chcon -R -t httpd_exec_t {{ iop_vulnerability_frontend_assets_path }}" |
| 51 | + changed_when: true |
| 52 | + |
| 53 | +- name: Ensure Apache SSL config directory exists |
| 54 | + ansible.builtin.file: |
| 55 | + path: /etc/httpd/conf.d/05-foreman-ssl.d |
| 56 | + state: directory |
| 57 | + mode: '0755' |
| 58 | + |
| 59 | +- name: Configure Apache for vulnerability frontend assets |
| 60 | + ansible.builtin.copy: |
| 61 | + dest: /etc/httpd/conf.d/05-foreman-ssl.d/vulnerability-frontend.conf |
| 62 | + content: | |
| 63 | + # IOP Vulnerability Frontend Assets Configuration |
| 64 | + Alias /assets/apps/vulnerability {{ iop_vulnerability_frontend_assets_path }} |
| 65 | + ProxyPass /assets/apps/vulnerability ! |
| 66 | +
|
| 67 | + <LocationMatch "^/assets/apps/vulnerability"> |
| 68 | + Options SymLinksIfOwnerMatch |
| 69 | + AllowOverride None |
| 70 | + Require all granted |
| 71 | +
|
| 72 | + # Use standard http expire header for assets instead of ETag |
| 73 | + <IfModule mod_expires.c> |
| 74 | + Header unset ETag |
| 75 | + FileETag None |
| 76 | + ExpiresActive On |
| 77 | + ExpiresDefault "access plus 1 year" |
| 78 | + </IfModule> |
| 79 | +
|
| 80 | + # Return compressed assets if they are precompiled |
| 81 | + RewriteEngine On |
| 82 | + # Make sure the browser supports gzip encoding and file with .gz added |
| 83 | + # does exist on disc before we rewrite with the extension |
| 84 | + RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b |
| 85 | + RewriteCond %{REQUEST_FILENAME} \.(css|js|svg)$ |
| 86 | + RewriteCond %{REQUEST_FILENAME}.gz -s |
| 87 | + RewriteRule ^(.+) $1.gz [L] |
| 88 | + </LocationMatch> |
| 89 | + mode: '0644' |
| 90 | + notify: "httpd : Restart httpd" |
0 commit comments