diff --git a/handlers/main.yml b/handlers/main.yml index d07c5b4..629eb1b 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,6 +1,6 @@ --- - name: Restart PostgreSQL - service: + ansible.builtin.service: name: postgres state: restarted daemon_reload: True diff --git a/tasks/main.yml b/tasks/main.yml index d6efdf1..375743c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,65 +1,62 @@ --- -- block: - - name: Create network specs - template: - src: etc/containers/systemd/postgres.network.j2 - dest: "/etc/containers/systemd/postgres.network" - owner: root - group: root - mode: "0640" - when: postgres_network | splitext | last == ".network" - notify: __postgres_restart +- name: Create network specs + ansible.builtin.template: + src: etc/containers/systemd/postgres.network.j2 + dest: "/etc/containers/systemd/postgres.network" + owner: root + group: root + mode: "0640" + when: postgres_network | splitext | last == ".network" + notify: __postgres_restart - - name: Create container volumes - containers.podman.podman_volume: - name: "{{ item.name }}" - options: "{{ item.options | default(omit) }}" - state: "{{ item.state | default('present') }}" - loop: "{{ postgres_volumes }}" - loop_control: - label: "{{ item.name }}" - when: item.type | default("volume") | lower == "volume" - register: __postgres_volumes_raw +- name: Create container volumes + containers.podman.podman_volume: + name: "{{ item.name }}" + options: "{{ item.options | default(omit) }}" + state: "{{ item.state | default('present') }}" + loop: "{{ postgres_volumes }}" + loop_control: + label: "{{ item.name }}" + when: item.type | default("volume") | lower == "volume" + register: __postgres_volumes_raw - - name: Register container volumes map - set_fact: - __postgres_volumes_map: "{{ __postgres_volumes_raw.results | json_query('[].volume') | items2dict(key_name='Name', value_name='Mountpoint') }}" +- name: Register container volumes map + ansible.builtin.set_fact: + __postgres_volumes_map: "{{ __postgres_volumes_raw.results | json_query('[].volume') | items2dict(key_name='Name', value_name='Mountpoint') }}" - - name: Deploy postgres env files - template: - src: "etc/containers/systemd/{{ item }}.j2" - dest: "/etc/containers/systemd/{{ item }}" - owner: root - group: root - mode: "0640" - loop: - - postgres.env - - postgres.sys.env - notify: __postgres_restart +- name: Deploy postgres env files + ansible.builtin.template: + src: "etc/containers/systemd/{{ item }}.j2" + dest: "/etc/containers/systemd/{{ item }}" + owner: root + group: root + mode: "0640" + loop: + - postgres.env + - postgres.sys.env + notify: __postgres_restart - - name: Create container specs - template: - src: etc/containers/systemd/postgres.container.j2 - dest: "/etc/containers/systemd/postgres.container" - owner: root - group: root - mode: "0640" - notify: __postgres_restart +- name: Create container specs + ansible.builtin.template: + src: etc/containers/systemd/postgres.container.j2 + dest: "/etc/containers/systemd/postgres.container" + owner: root + group: root + mode: "0640" + notify: __postgres_restart - - name: Deploy init-user-db - ansible.builtin.copy: - src: init-user-db.sh - dest: "{{ __postgres_volumes_map['postgres-initdb'] }}" - owner: "{{ postgres_uid }}" - group: "{{ postgres_gid }}" - mode: "0644" - when: "'postgres-initdb' in __postgres_volumes_map" +- name: Deploy init-user-db + ansible.builtin.copy: + src: init-user-db.sh + dest: "{{ __postgres_volumes_map['postgres-initdb'] }}" + owner: "{{ postgres_uid }}" + group: "{{ postgres_gid }}" + mode: "0644" + when: "'postgres-initdb' in __postgres_volumes_map" - - name: Ensure service state - systemd: - name: "postgres.service" - state: started - daemon_reload: True - enabled: True - become: True - become_user: root +- name: Ensure service state + ansible.builtin.service: + name: "postgres.service" + state: started + daemon_reload: True + enabled: True