ansible-collection-uffd/roles/uffd/tasks/main.yml
Nis Wechselberg 29d7b1c504
First version of the uffd collection
Signed-off-by: Nis Wechselberg <enbewe@enbewe.de>
2024-12-20 17:38:05 +01:00

116 lines
3.1 KiB
YAML

---
- name: 'Install required software'
become: true
ansible.builtin.apt:
name: 'podman'
state: 'present'
- name: 'Prepare uffd network'
become: true
containers.podman.podman_network:
name: '{{ uffd_podman_network }}'
state: 'quadlet'
notify:
- 'Reload uffd services'
- 'Restart uffd network'
- name: 'Prepare uffd volumes'
become: true
containers.podman.podman_volume:
name: '{{ item }}'
state: 'quadlet'
loop:
- '{{ uffd_static_files_volume }}'
- '{{ uffd_data_volume }}'
notify:
- 'Reload uffd services'
- 'Restart uffd volumes'
- name: 'Create uffd config directory'
become: true
ansible.builtin.file:
path: '{{ uffd_conf_dir }}'
state: 'directory'
mode: 'u=rwx,g=rx,o=rx'
- name: 'Generate uffd configuration'
become: true
ansible.builtin.template:
src: 'uffd.cfg.j2'
dest: '{{ uffd_conf_dir }}/uffd.cfg'
owner: 'root'
group: 'root'
mode: 'u=rw,g=r,o=r'
notify: 'Restart uffd container'
- name: 'Create uffd container'
become: true
containers.podman.podman_container:
name: 'uffd-app'
image: '{{ uffd_image_name }}'
network: '{{ uffd_podman_network }}.network'
state: 'quadlet'
volume:
- '{{ uffd_static_files_volume }}.volume:/var/www/uffd'
- '{{ uffd_data_volume }}.volume:/var/lib/uffd'
- '{{ uffd_conf_dir }}/uffd.cfg:/etc/uffd/uffd.cfg:ro'
env:
UFFD_INITIAL_ADMIN_USER: '{{ uffd_initial_admin_user }}'
UFFD_INITIAL_ADMIN_PW: '{{ uffd_initial_admin_pw }}'
UFFD_INITIAL_ADMIN_MAIL: '{{ uffd_initial_admin_mail }}'
ports: []
quadlet_options: |
[Install]
WantedBy=default.target
[Unit]
Requires={{ uffd_podman_network }}-network.service
Requires={{ uffd_static_files_volume }}-volume.service
Requires={{ uffd_data_volume }}-volume.service
After={{ uffd_podman_network }}-network.service
After={{ uffd_static_files_volume }}-volume.service
After={{ uffd_data_volume }}-volume.service
notify:
- 'Reload uffd services'
- 'Restart uffd container'
- name: 'Define uffd-nginx image'
become: true
containers.podman.podman_image:
name: 'docker.io/library/nginx:latest'
quadlet_filename: 'uffd-nginx'
state: 'quadlet'
notify:
- 'Reload uffd services'
- 'Restart uffd-nginx image'
- name: 'Write uffd-nginx config'
become: true
ansible.builtin.template:
src: 'nginx.conf.j2'
dest: '{{ uffd_conf_dir }}/nginx.conf'
owner: 'root'
group: 'root'
mode: 'u=rw,g=r,o=r'
notify:
- 'Restart uffd-nginx container'
- name: 'Create uffd-nginx container'
become: true
containers.podman.podman_container:
name: 'uffd-nginx'
image: 'uffd-nginx.image'
network: '{{ uffd_podman_network }}.network'
state: 'quadlet'
volume:
- '{{ uffd_static_files_volume }}.volume:/var/www/uffd'
- '{{ uffd_conf_dir }}/nginx.conf:/etc/nginx/conf.d/default.conf:ro'
ports: []
quadlet_options: |
[Install]
WantedBy=default.target
[Unit]
Requires=uffd-app.service
After=uffd-app.service
notify:
- 'Reload uffd services'
- 'Restart uffd-nginx container'