--- - block: - name: install the postgresql packages apt: pkg={{ postgresql_pkgs }} state={{ psql_pkg_state }} cache_valid_time=3600 notify: Restart postgresql when: ansible_distribution_file_variety == "Debian" tags: [ 'postgresql', 'postgres' ] - name: EL block: - name: install the postgresql packages from the pgdg repository yum: pkg={{ psql_el_pgdg_packages }} state={{ psql_pkg_state }} - name: Init the db if needed command: /usr/pgsql-{{ psql_version }}/bin/postgresql-{{ psql_version }}-setup initdb args: creates: '{{ psql_data_dir }}/postgresql.conf' when: - not psql_install_scl_version - ansible_distribution_file_variety == "RedHat" tags: [ 'postgresql', 'postgres' ] - name: EL from SCL block: - name: install the postgresql scl packages yum: pkg={{ psql_el_scl_packages }} state={{ psql_pkg_state }} - name: Init the db if needed command: /opt/rh/rh-postgresql{{ psql_version }}/root/usr/bin/postgresql-setup --initdb args: creates: '{{ psql_data_dir }}/postgresql.conf' when: - psql_install_scl_version - ansible_distribution_file_variety == "RedHat" tags: [ 'scl', 'postgresql', 'postgres' ]