80 lines
2.2 KiB
YAML
80 lines
2.2 KiB
YAML
---
|
|
# tasks file for podman
|
|
|
|
- name: Enable lingering for podman user
|
|
ansible.builtin.command:
|
|
cmd: "loginctl enable-linger {{ podman_user }}"
|
|
creates: /var/lib/systemd/linger/podman
|
|
become: true
|
|
|
|
- name: Create subvolumes paths
|
|
ansible.builtin.file:
|
|
path: "{{ item.1 | split(':') | first }}"
|
|
state: directory
|
|
mode: u=rwX,g=rX,o=rX
|
|
become: true
|
|
loop: "{{ q('ansible.builtin.subelements', podman_containers, 'volumes', {'skip_missing': True}) }}"
|
|
loop_control:
|
|
label: "{{ item.0.name }}"
|
|
register: folders
|
|
notify: Set default permissions on volumes folders
|
|
|
|
- name: Exécuter les handlers
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: Deploy pods
|
|
containers.podman.podman_pod: "{{ pod }}"
|
|
become: true
|
|
become_user: "{{ podman_user }}"
|
|
loop: "{{ podman_pods }}"
|
|
loop_control:
|
|
label: "{{ item.name }}"
|
|
register: deployed_pods
|
|
vars:
|
|
pod: "{{ podman_pods_defaults | ansible.builtin.combine(item) }}"
|
|
|
|
- name: Start or restart pods
|
|
ansible.builtin.systemd_service:
|
|
name: "{{ item.item.name }}-pod.service"
|
|
state: "{{ 'restarted' if item.changed else 'started' }}"
|
|
daemon_reload: true
|
|
scope: user
|
|
become: true
|
|
become_user: "{{ podman_user }}"
|
|
loop: "{{ deployed_pods.results }}"
|
|
loop_control:
|
|
label: "{{ item.item.name }}"
|
|
|
|
- name: Deploy containers
|
|
containers.podman.podman_container: "{{ container }}"
|
|
become: true
|
|
become_user: "{{ podman_user }}"
|
|
loop: "{{ podman_containers }}"
|
|
loop_control:
|
|
label: "{{ item.name }}"
|
|
register: deployed_containers
|
|
vars:
|
|
container: "{{ podman_containers_defaults | ansible.builtin.combine(item) }}"
|
|
|
|
- name: Start or restart containers
|
|
ansible.builtin.systemd_service:
|
|
name: "{{ item.item.name }}.service"
|
|
state: "{{ 'restarted' if item.changed else 'started' }}"
|
|
daemon_reload: true
|
|
scope: user
|
|
become: true
|
|
become_user: "{{ podman_user }}"
|
|
loop: "{{ deployed_containers.results }}"
|
|
loop_control:
|
|
label: "{{ item.item.name }}"
|
|
|
|
- name: Enable containers auto-update service
|
|
ansible.builtin.systemd_service:
|
|
name: podman-auto-update.timer
|
|
daemon_reload: true
|
|
enabled: true
|
|
scope: user
|
|
when: podman_auto_update
|
|
become: true
|
|
become_user: "{{ podman_user }}"
|