Skip to content

Commit

Permalink
Merge pull request #40 from vitabaks/dev
Browse files Browse the repository at this point in the history
add support pgbackrest
  • Loading branch information
vitabaks authored Jun 23, 2020
2 parents 52c225d + 5d894d2 commit c2de3da
Show file tree
Hide file tree
Showing 19 changed files with 1,572 additions and 36 deletions.
28 changes: 26 additions & 2 deletions add_pgnode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
- vars/main.yml
- vars/system.yml
- "vars/{{ ansible_os_family }}.yml"
vars:
existing_pgcluster: true

pre_tasks:
- name: Checking Linux distribution
Expand Down Expand Up @@ -64,6 +62,7 @@

- role: hostname
- role: resolv_conf
- role: etc_hosts
- role: add-repository
- role: packages
- role: sudo
Expand All @@ -76,6 +75,31 @@
- role: ntp
- role: ssh-keys

- hosts: pgbackrest:postgres_cluster
become: true
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- "vars/{{ ansible_os_family }}.yml"
roles:
- role: pgbackrest
when: pgbackrest_install|bool

- hosts: replica
become: true
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- vars/system.yml
- "vars/{{ ansible_os_family }}.yml"
vars:
existing_pgcluster: true

roles:
- role: wal-g
when: wal_g_install|bool

Expand Down
24 changes: 24 additions & 0 deletions deploy_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

- role: hostname
- role: resolv_conf
- role: etc_hosts
- role: add-repository
- role: packages
- role: sudo
Expand All @@ -89,6 +90,29 @@
- role: ntp
- role: ssh-keys

- hosts: pgbackrest:postgres_cluster
become: true
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- "vars/{{ ansible_os_family }}.yml"
roles:
- role: pgbackrest
when: pgbackrest_install|bool

- hosts: postgres_cluster
become: true
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- vars/system.yml
- "vars/{{ ansible_os_family }}.yml"

roles:
- role: wal-g
when: wal_g_install|bool

Expand Down
3 changes: 2 additions & 1 deletion files/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
urllib3>=1.24.2,<1.25
boto
PyYAML
requests
six >= 1.7
kazoo>=1.3.1
python-etcd>=0.4.3,<0.5
Expand All @@ -12,3 +11,5 @@ tzlocal
python-dateutil
psutil>=2.0.0
cdiff
pexpect>=4.8.0
ruamel.yaml>=0.16.10
14 changes: 11 additions & 3 deletions inventory
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Please specify the ip addresses and connection settings for your environment
# The specified ip addresses will be used to listen by the cluster components.

# "postgresql_exists='true'" if PostgreSQL is already exists and runing
# "postgresql_exists='true'" if PostgreSQL is already exists and running on master (for initial deployment only)
# "hostname=" variable is optional (used to change the server name)

# if dcs_exists: false and dcs_type: "etcd" (in vars/main.yml)
Expand Down Expand Up @@ -36,12 +36,20 @@ replica
# You can deploy the etcd cluster and the haproxy balancers on other dedicated servers.


# if pgbackrest_install: true and "repo_host" is set (in vars/main.yml)
[pgbackrest] # optional (Dedicated Repository Host)


# Connection settings
[all:vars]
ansible_connection='ssh'
ansible_ssh_port='22'
ansible_user='root'
ansible_ssh_pass='testpas' # "sshpass" package is required for use "ansible_ssh_pass"
#ansible_ssh_private_key_file=
ansible_ssh_pass='secretpassword' # "sshpass" package is required for use "ansible_ssh_pass"
# ansible_ssh_private_key_file=
# ansible_python_interpreter='/usr/bin/python3' # is required for use python3

[pgbackrest:vars]
ansible_user='postgres'
ansible_ssh_pass='secretpassword'

7 changes: 0 additions & 7 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
sysctl_set: false # Added to prevent test failures in CI.
cacheable: true

- name: Prepare | Remove epel-release package
package:
name: epel-release
state: absent
when:
- ansible_os_family == "RedHat"

- name: Prepare | Clean yum cache
command: yum clean all
args:
Expand Down
7 changes: 0 additions & 7 deletions molecule/postgrespro/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
sysctl_set: false # Added to prevent test failures in CI.
cacheable: true

- name: Prepare | Remove epel-release package
package:
name: epel-release
state: absent
when:
- ansible_os_family == "RedHat"

- name: Prepare | Clean yum cache
command: yum clean all
args:
Expand Down
6 changes: 4 additions & 2 deletions roles/deploy-finish/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
debug:
var: patronictl_result.stdout_lines
ignore_errors: true
tags: patroni_status, cluster_info, cluster_status
tags: patroni_status, cluster_info, cluster_status, point_in_time_recovery

- block:
- name: Get postgresql database list
run_once: true
become: true
become_user: postgres
command:
"{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U postgres -c
\"
Expand Down Expand Up @@ -53,7 +55,7 @@
debug:
var: dbs_result.stdout_lines
ignore_errors: true
tags: databases, db_list, cluster_info, cluster_status
tags: databases, db_list, cluster_info, cluster_status, point_in_time_recovery

- block:
- name: PostgreSQL Cluster connection info
Expand Down
15 changes: 15 additions & 0 deletions roles/etc_hosts/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---

- name: Add entries into /etc/hosts file
lineinfile:
path: /etc/hosts
regexp: "^{{ item }}"
line: "{{ item }}"
unsafe_writes: true # to prevent failures in CI
loop: "{{ etc_hosts }}"
when:
- etc_hosts is defined
- etc_hosts | length > 0
tags: etc_hosts

...
Loading

0 comments on commit c2de3da

Please sign in to comment.