-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53981a3
commit 8494c00
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[all] | ||
debian ansible_host=142.93.193.106 ansible_user=root | ||
ubuntu ansible_host=143.198.115.57 ansible_user=root | ||
rockylinux ansible_host=178.128.150.243 ansible_user=root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
- name: Install Percona Distribution for PostgreSQL | ||
hosts: all | ||
become: yes | ||
vars_files: | ||
- ../vars.yml | ||
tasks: | ||
- name: Detect Operating System | ||
ansible.builtin.set_fact: | ||
is_debian: "{{ ansible_os_family == 'Debian' }}" | ||
is_redhat: "{{ ansible_os_family == 'RedHat' }}" | ||
|
||
- name: Install curl | ||
ansible.builtin.package: | ||
name: curl | ||
state: present | ||
|
||
# Debian/Ubuntu: Install Percona release package | ||
- name: Download Percona release package (Debian/Ubuntu) | ||
ansible.builtin.get_url: | ||
url: "{{ percona_repo_url }}/apt/{{ percona_release_package }}.{{ ansible_lsb.codename }}_all.deb" | ||
dest: "/tmp/{{ percona_release_package }}.{{ ansible_lsb.codename }}_all.deb" | ||
when: is_debian | ||
|
||
- name: Install Percona release package (Debian/Ubuntu) | ||
ansible.builtin.apt: | ||
deb: "/tmp/{{ percona_release_package }}.{{ ansible_lsb.codename }}_all.deb" | ||
state: present | ||
when: is_debian | ||
|
||
# RedHat/CentOS: Install Percona release package | ||
- name: Download Percona release package (RedHat/CentOS) | ||
ansible.builtin.get_url: | ||
url: "{{ percona_repo_url }}/yum/{{ percona_release_package }}.noarch.rpm" | ||
dest: "/tmp/{{ percona_release_package }}.noarch.rpm" | ||
when: is_redhat | ||
|
||
- name: Install Percona release package (RedHat/CentOS) | ||
ansible.builtin.yum: | ||
name: "/tmp/{{ percona_release_package }}.noarch.rpm" | ||
state: present | ||
when: is_redhat | ||
|
||
# Configure Percona repository | ||
- name: Configure Percona repository (RedHat/CentOS) | ||
ansible.builtin.command: | ||
cmd: percona-release setup ppg-{{ percona_version }} | ||
creates: "/etc/yum.repos.d/percona-ppg-{{ percona_version }}.repo" | ||
when: is_redhat | ||
|
||
# Update package cache | ||
- name: Update package cache (Debian/Ubuntu) | ||
ansible.builtin.apt: | ||
update_cache: yes | ||
when: is_debian | ||
|
||
- name: Update package cache (RedHat/CentOS) | ||
ansible.builtin.yum: | ||
name: "*" | ||
state: latest | ||
when: is_redhat | ||
|
||
# Install Percona PostgreSQL packages | ||
- name: Install Percona PostgreSQL packages (Debian/Ubuntu) | ||
ansible.builtin.apt: | ||
name: "{{ debian_packages }}" | ||
state: present | ||
when: is_debian | ||
|
||
- name: Install Percona PostgreSQL packages (RedHat/CentOS) | ||
ansible.builtin.yum: | ||
name: "{{ redhat_packages }}" | ||
state: present | ||
when: is_redhat | ||
|
||
# Start and enable PostgreSQL service | ||
- name: Start and enable PostgreSQL service | ||
ansible.builtin.service: | ||
name: "{{ 'postgresql' if is_debian else 'postgresql-{{ percona_version }}' }}" | ||
state: started | ||
enabled: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
percona_repo_url: "https://repo.percona.com" | ||
percona_release_package: "percona-release_latest" | ||
percona_version: "17" | ||
debian_packages: | ||
- "percona-ppg-server-17" | ||
redhat_packages: | ||
- "percona-ppg-server17" |