Skip to content

Commit

Permalink
apt_repository_and_key -> apt_repository
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks committed Mar 12, 2024
1 parent e686930 commit 64fac31
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ _Table of results of daily automated testing of cluster deployment:_


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

## Requirements
This playbook requires root privileges or sudo.
Expand Down
31 changes: 10 additions & 21 deletions roles/add-repository/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
delay: 5
retries: 3

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

- name: Update apt cache
ansible.builtin.apt:
Expand Down Expand Up @@ -188,25 +188,14 @@
# timescaledb (if enable_timescale is defined)
- block:
# Debian based
- 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 TimescaleDB repository
ansible.builtin.deb822_repository:
name: "{{ timescale_repository | replace('.', '-') | replace('/', '-') }}"
name: "timescaledb"
types: [deb]
uris: "{{ timescale_repository.split(' ')[1] }}"
signed_by: "{{ timescale_repository_key }}"
suites: "{{ timescale_repository.split(' ')[2] }}"
components: "{{ timescale_repository.split(' ')[3] }}"
uris: "https://packagecloud.io/timescale/timescaledb"
signed_by: "https://packagecloud.io/timescale/timescaledb/gpgkey"
suites: "{{ ansible_distribution_release }}"
components: "[main]"
state: present
enabled: true
when: ansible_os_family == "Debian"
Expand Down
20 changes: 5 additions & 15 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,13 @@ postgresql_home_dir: "/var/lib/postgresql"
postgresql_stats_temp_directory_path: "/var/lib/pgsql_stats_tmp" # or 'none'
postgresql_stats_temp_directory_size: "1024m"

# Repository and key for Debian >= 12 version
apt_repository_and_key:
- repo: "deb https://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" # postgresql apt repository
key: "https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc" # postgresql repository apt key

# Repository and key for Debian < 12 version
apt_repository_keys:
- key: "https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc" # postgresql repository apt key
# Repository
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)

timescale_server: "https://packagecloud.io/timescale/timescaledb"
timescale_repository: "deb {{ timescale_server }}/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main"
timescale_repository_key: "{{ timescale_server }}/gpgkey"
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 (for apt repo)
os_specific_packages:
Expand Down

0 comments on commit 64fac31

Please sign in to comment.