mirror of
https://gitea.0xace.cc/ansible-galaxy/postgresql.git
synced 2024-11-25 08:16:43 +00:00
58 lines
1.9 KiB
YAML
58 lines
1.9 KiB
YAML
- name: Install deps packages
|
|
apt:
|
|
name: "{{ postgresql_deps_packages }}"
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: Add gpg keys for PostgreSQL repo
|
|
ansible.builtin.apt_key:
|
|
url: "{{ item.url }}"
|
|
keyring: "{{ item.keyring }}"
|
|
loop: "{{ postgresql_apt_key }}"
|
|
|
|
- name: Add PostgreSQL repository
|
|
ansible.builtin.apt_repository:
|
|
repo: "{{ item.repo }}"
|
|
state: present
|
|
filename: "{{ item.filename }}"
|
|
update_cache: yes
|
|
loop: "{{ postgresql_apt_repository }}"
|
|
|
|
- name: Gather packages
|
|
package_facts:
|
|
manager: auto
|
|
|
|
- name: Set fact about PostgreSQL package
|
|
set_fact:
|
|
postgresql_installed_package: "{{ ansible_facts.packages[postgresql_package_name][0]['name'] }}"
|
|
when: postgresql_package_name in ansible_facts.packages
|
|
|
|
- name: Print installed PostgreSQL version
|
|
debug:
|
|
msg: "{{ ansible_facts.packages[postgresql_package_name][0]['version'] }}"
|
|
verbosity: 2
|
|
when: postgresql_installed_package is defined
|
|
|
|
- name: Mask PostgreSQL before install
|
|
ansible.builtin.systemd:
|
|
name: "{{ postgresql_unit_name }}"
|
|
masked: yes
|
|
when: postgresql_package_name not in ansible_facts.packages or ansible_facts.packages[postgresql_package_name][0]['version'] != (postgresql_version + "-" + postgresql_version_build)
|
|
|
|
- name: "Install {{ postgresql_package_name }}-{{ postgresql_version }}-{{ postgresql_version_build }}"
|
|
apt:
|
|
name: "{{ postgresql_package }}"
|
|
update_cache: yes
|
|
register: postgresql_setup
|
|
when: postgresql_package_name not in ansible_facts.packages
|
|
|
|
- name: "Update {{ postgresql_package_name }}-{{ postgresql_version }}-{{ postgresql_version_build }}"
|
|
apt:
|
|
name: "{{ postgresql_package }}"
|
|
update_cache: yes
|
|
register: postgresql_update
|
|
notify: Restart PostgreSQL
|
|
when:
|
|
- postgresql_package_name in ansible_facts.packages
|
|
- ansible_facts.packages[postgresql_package_name][0]['version'] != (postgresql_version + "-" + postgresql_version_build)
|