Skip to content

Commit

Permalink
Using deb822_repository module instead of apt_key and apt_repository (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FactorT authored Aug 14, 2024
1 parent cd180bb commit 9473b4a
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ _Table of results of daily automated testing of cluster deployment:_


###### Ansible version
Minimum supported Ansible version: 2.11.0
Minimum supported Ansible version: 8.0.0 (ansible-core 2.15.0)

## Requirements
This playbook requires root privileges or sudo.
Expand Down
2 changes: 1 addition & 1 deletion config_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
roles:
- role: pre-checks
vars:
minimal_ansible_version: 2.11.0
minimal_ansible_version: 2.15.0
timescale_minimal_pg_version: 12 # if enable_timescale is defined
tags:
- always
Expand Down
2 changes: 1 addition & 1 deletion deploy_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
roles:
- role: pre-checks
vars:
minimal_ansible_version: 2.11.0
minimal_ansible_version: 2.15.0
timescale_minimal_pg_version: 12 # if enable_timescale is defined
tags: always

Expand Down
54 changes: 39 additions & 15 deletions roles/add-repository/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
---

- block: # Debian/Ubuntu
- name: Add repository apt-key
ansible.builtin.apt_key:
url: "{{ item.key }}"
- name: Make sure the python3-debian package is present
ansible.builtin.apt:
pkg:
- python3-debian
state: present
loop: "{{ apt_repository_keys }}"
when: apt_repository_keys | length > 0
register: apt_status
until: apt_status is success
delay: 5
retries: 3

- name: Add repository
ansible.builtin.apt_repository:
repo: "{{ item.repo }}"
ansible.builtin.deb822_repository:
name: "{{ item.name | default(item.repo.split('//')[1].split('/')[0] | replace('.', '-')) }}"
types: "{{ item.types | default(['deb']) }}"
uris: "{{ item.uris | default(item.repo.split(' ')[1]) }}"
signed_by: "{{ item.signed_by | default(item.key | default(omit)) }}"
suites: "{{ item.suites | default(item.repo.split(' ')[2]) }}"
components: "{{ item.components | default(item.repo.split(' ')[3]) }}"
enabled: "{{ item.enabled | default(true) }}"
state: present
update_cache: true
loop: "{{ apt_repository }}"
when: apt_repository | length > 0

- name: Update apt cache
ansible.builtin.apt:
update_cache: true
register: apt_status
until: apt_status is success
delay: 5
retries: 3
environment: "{{ proxy_env | default({}) }}"
when: installation_method == "repo" and ansible_os_family == "Debian"
tags: add_repo
Expand Down Expand Up @@ -112,17 +128,25 @@
# timescaledb (if enable_timescale is defined)
- block:
# Debian based
- name: Add TimescaleDB repository apt-key
ansible.builtin.apt_key:
url: "https://packagecloud.io/timescale/timescaledb/gpgkey"
- name: Add TimescaleDB repository
ansible.builtin.deb822_repository:
name: "timescaledb"
types: [deb]
uris: "https://packagecloud.io/timescale/timescaledb/{{ ansible_distribution | lower }}"
signed_by: "https://packagecloud.io/timescale/timescaledb/gpgkey"
suites: "{{ ansible_distribution_release }}"
components: [main]
state: present
enabled: true
when: ansible_os_family == "Debian"

- name: Add TimescaleDB repository
ansible.builtin.apt_repository:
repo: "deb https://packagecloud.io/timescale/timescaledb/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main"
state: present
- name: Update apt cache
ansible.builtin.apt:
update_cache: true
register: apt_status
until: apt_status is success
delay: 5
retries: 3
when: ansible_os_family == "Debian"

# RedHat based
Expand Down
35 changes: 27 additions & 8 deletions roles/consul/tasks/install_linux_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,37 @@
ansible_distribution|lower == 'rocky' or
ansible_distribution|lower == 'almalinux'
- name: Add an Apt signing key, uses whichever key is at the URL
ansible.builtin.apt_key:
url: "{{ consul_repo_url }}/gpg"
- name: Make sure the python3-debian package is present
ansible.builtin.apt:
pkg:
- python3-debian
state: present
register: apt_status
until: apt_status is success
delay: 5
retries: 3
when: ansible_os_family == "Debian"

- name: Add hashicorp repository and an apt signing key, uses whichever key is at the URL
ansible.builtin.deb822_repository:
name: "{{ consul_repo_url.split('//')[1] | replace('.', '-') }}"
types: "deb"
uris: "{{ consul_repo_url }}"
signed_by: "{{ consul_repo_url }}/gpg"
suites: "{{ ansible_distribution_release }}"
components: "main"
enabled: true
state: present
when: "ansible_os_family|lower == 'debian'"

- name: Add hashicorp repository
ansible.builtin.apt_repository:
repo: "deb {{ consul_repo_url }} {{ ansible_distribution_release }} main"
state: present
- name: Update apt cache
ansible.builtin.apt:
update_cache: true
when: "ansible_os_family|lower == 'debian'"
register: apt_status
until: apt_status is success
delay: 5
retries: 3
when: ansible_os_family == "Debian"

when: "ansible_os_family|lower in [ 'debian', 'redhat' ]"
become: true
Expand Down
22 changes: 13 additions & 9 deletions roles/pg_probackup/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
---

- block: # Debian family
- name: Make sure the gnupg and apt-transport-https packages are present
- name: Make sure the gnupg, apt-transport-https and python3-debian packages are present
ansible.builtin.apt:
pkg:
- gnupg
- apt-transport-https
- python3-debian
state: present
register: apt_status
until: apt_status is success
delay: 5
retries: 3

- name: Make sure pgdg apt key is installed
ansible.builtin.apt_key:
id: 636D717E
url: https://repo.postgrespro.ru/pg_probackup/keys/GPG-KEY-PG_PROBACKUP

- name: Make sure pgdg repository is installed
ansible.builtin.apt_repository:
repo: "deb [arch=amd64] http://repo.postgrespro.ru/pg_probackup/deb/ {{ ansible_distribution_release }} main-{{ ansible_distribution_release }}"
- name: Add pgdg repository and signing key
ansible.builtin.deb822_repository:
name: "{{ pg_probackup_repo_name | default('pg_probackup') }}"
types: [deb]
uris: "http://repo.postgrespro.ru/pg_probackup/deb/"
signed_by: "https://repo.postgrespro.ru/pg_probackup/keys/GPG-KEY-PG-PROBACKUP"
suites: "{{ ansible_distribution_release }}"
components: "main-{{ ansible_distribution_release }}"
state: present
enabled: true
when: ansible_os_family == "Debian"

- name: Update apt cache
ansible.builtin.apt:
Expand Down
22 changes: 13 additions & 9 deletions roles/pgbackrest/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
---

- block: # Debian pgdg repo
- name: Make sure the gnupg and apt-transport-https packages are present
- name: Make sure the gnupg, apt-transport-https and python3-debian packages are present
ansible.builtin.apt:
pkg:
- gnupg
- apt-transport-https
- python3-debian
state: present
register: apt_status
until: apt_status is success
delay: 5
retries: 3

- name: Make sure pgdg apt key is installed
ansible.builtin.apt_key:
id: ACCC4CF8
url: https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc

- name: Make sure pgdg repository is installed
ansible.builtin.apt_repository:
repo: "deb https://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main"
- name: Add pgdg repository and signing key
ansible.builtin.deb822_repository:
name: "{{ pgbackrest_repo_name | default('apt-postgresql-org') }}"
types: [deb]
uris: "https://apt.postgresql.org/pub/repos/apt/"
signed_by: "https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc"
suites: "{{ ansible_distribution_release }}-pgdg"
components: [main]
state: present
enabled: true
when: ansible_os_family == "Debian"

- name: Update apt cache
ansible.builtin.apt:
Expand Down
9 changes: 4 additions & 5 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ postgresql_stats_temp_directory_path: "/var/lib/pgsql_stats_tmp" # or 'none'
postgresql_stats_temp_directory_size: "1024m"

# Repository
apt_repository_keys:
- key: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" # postgresql repository apt key
apt_repository:
- repo: "deb https://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" # postgresql apt repository
# - repo: "deb https://deb.debian.org/debian/ {{ ansible_distribution_release }} main" # debian repo (optional)
# - repo: "deb https://deb.debian.org/debian/ {{ ansible_distribution_release }}-updates main" # debian repo (optional)
# - repo: "deb https://security.debian.org/debian-security/ {{ ansible_distribution_release }}/updates main" # debian repo (optional)
key: "https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc" # postgresql apt repository key
# - repo: "deb https://deb.debian.org/debian/ {{ ansible_distribution_release }} main"
# - repo: "deb https://deb.debian.org/debian/ {{ ansible_distribution_release }}-updates main"
# - repo: "deb https://security.debian.org/debian-security/ {{ ansible_distribution_release }}/updates main"

# Packages
system_packages:
Expand Down

0 comments on commit 9473b4a

Please sign in to comment.