patroni/tasks/Debian/main.yaml
2023-02-08 02:39:20 +03:00

70 lines
1.9 KiB
YAML

- name: Add gpg package
apt:
name: gpg
- name: Add gpg keys for patroni
ansible.builtin.apt_key:
url: "{{ item.url }}"
keyring: "{{ item.keyring }}"
loop: "{{ patroni_apt_key }}"
- name: Add Patroni repository
apt_repository:
repo: "{{ item.repo }}"
state: present
filename: "{{ item.filename }}"
update_cache: yes
loop: "{{ patroni_apt_repository }}"
- name: Check if PostgreSQL is installed
ansible.builtin.shell: dpkg-query -l {{ patroni_postgresql_package_name }} 2>&1 | grep {{ patroni_postgresql_version }}
ignore_errors: True
register: is_patroni_postgresql
changed_when: is_patroni_postgresql.rc != 0
failed_when: False
- name: Mask PostgreSQL before install
ansible.builtin.systemd:
name: "{{ patroni_postgresql_package_name }}"
masked: yes
when: is_patroni_postgresql.rc != 0
- name: "Install {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}"
apt:
name: "{{ patroni_postgresql_package }}"
update_cache: yes
register: patroni_postgresql_setup
when: is_patroni_postgresql.rc != 0
- name: Unmask PostgreSQL after install
ansible.builtin.systemd:
name: "{{ patroni_postgresql_package_name }}"
masked: no
when: is_patroni_postgresql.rc != 0
- name: Check if Patroni is installed
ansible.builtin.shell: dpkg-query -l {{ patroni_package_name }} 2>&1 | grep {{ patroni_version }}
ignore_errors: True
register: is_patroni
changed_when: is_patroni.rc != 0
failed_when: False
- name: Mask Patroni before install
ansible.builtin.systemd:
name: "{{ patroni_package_name }}"
masked: yes
when: is_patroni.rc != 0
- name: "Install {{ patroni_package_name }}-{{ patroni_version }}"
apt:
name: "{{ patroni_package }}"
update_cache: yes
register: patroni_setup
when: is_patroni.rc != 0
- name: Unmask Patroni after install
ansible.builtin.systemd:
name: "{{ patroni_package_name }}"
masked: no
when: is_patroni.rc != 0