--- - name: Verify hosts: all become: true tasks: - include_tasks: ../../common/tasks/package_installed.yml vars: package_name: postgresql-server - name: Verify postgresql-server package version ansible.builtin.assert: that: | (ansible_facts.packages['postgresql-server'][0]['version'] | split('.'))[0] == '{{ postgresql_major_version }}' fail_msg: "installed postgresql-server major version is not '{{ postgresql_major_version }}'" success_msg: "installed postgresql-server major version is '{{ postgresql_major_version }}'" - include_tasks: ../../common/tasks/service_enabled_and_running.yml vars: service_name: postgresql - name: Get postgresql service status ansible.builtin.systemd_service: name: postgresql state: started register: postgresql_service - name: Assert that postgresql service is starting after network-online.target ansible.builtin.assert: that: | not postgresql_service.changed and 'network-online.target' in (postgresql_service['status']['After'] | split) fail_msg: 'postgresql service should be starting after network-online.target' success_msg: 'postgresql service is starting after network-online.target' - name: Collect /var/lib/pgsql/data/pg_hba.conf file stats ansible.builtin.stat: path: /var/lib/pgsql/data/pg_hba.conf register: pg_hba - name: Verify /var/lib/pgsql/data/pg_hba.conf stats ansible.builtin.assert: that: | pg_hba.stat.exists and pg_hba.stat.mode == '0600' and pg_hba.stat.pw_name == 'postgres' and pg_hba.stat.gr_name == 'postgres' fail_msg: '/var/lib/pgsql/data/pg_hba.conf does not exist or has incorrect permissions' success_msg: '/var/lib/pgsql/data/pg_hba.conf is verified' - include_tasks: ../../postgresql_server/tasks/postgresql_setting.yml vars: postgresql_setting_name: max_connections postgresql_setting_value: "{{ postgresql_max_connections }}" when: postgresql_max_connections is defined