Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provision of resources in a popular cloud providers for PostgreSQL cluster deployment #464

Merged
merged 351 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
351 commits
Select commit Hold shift + click to select a range
f7236dd
Hetzner: Add network zone to the network name
vitabaks Oct 4, 2023
640ea09
Hetzner: add the ability to redefine the network name and ip range
vitabaks Oct 4, 2023
950e931
Update ansible.cfg
vitabaks Oct 4, 2023
a377272
Merge branch 'master' into cloud
vitabaks Oct 5, 2023
497ebd8
install perf and postgres dbgsym/debuginfo packages
vitabaks Oct 5, 2023
60480c0
Build perf from source code if it was not installed from packages
vitabaks Oct 6, 2023
9c450c8
Update perf.yml
vitabaks Oct 6, 2023
102a1ee
Download 'FlameGraph' to /var/opt/
vitabaks Oct 6, 2023
f1487c0
Extension Auto-Setup: pg_repack
vitabaks Oct 6, 2023
5ec8db5
Update deploy_pgcluster.yml
vitabaks Oct 6, 2023
d2ec775
Extension Auto-Setup: pg_cron
vitabaks Oct 6, 2023
0b75133
Update molecule.yml
vitabaks Oct 6, 2023
d827747
Extension Auto-Setup: pgaudit
vitabaks Oct 6, 2023
89f0ed6
Extension Auto-Setup: pgvector
vitabaks Oct 6, 2023
c9cc20b
Update main.yml
vitabaks Oct 7, 2023
8a24d76
Update extensions.yml
vitabaks Oct 7, 2023
73cc874
Update extensions.yml
vitabaks Oct 7, 2023
54b8fea
Extension Auto-Setup: postgis
vitabaks Oct 8, 2023
d3f315b
Extension Auto-Setup: pgrouting
vitabaks Oct 8, 2023
a91695b
Update extensions.yml
vitabaks Oct 8, 2023
7f16472
Extension Auto-Setup: pg_stat_kcache
vitabaks Oct 9, 2023
d95228a
Extension Auto-Setup: pg_wait_sampling
vitabaks Oct 9, 2023
e045d5b
extensions.yml: Add pgaudit for Postgres 16
vitabaks Oct 9, 2023
101b21d
Update extensions.yml
vitabaks Oct 9, 2023
f24c470
packages.yml: Update condition for timescaledb
vitabaks Oct 9, 2023
35f0998
extensions.yml: Update condition for timescaledb
vitabaks Oct 9, 2023
4073479
Extension Auto-Setup: pg_partman
vitabaks Oct 9, 2023
917f535
Extension Auto-Setup: citus
vitabaks Oct 9, 2023
4f1d37c
Refactoring of "deploy-finish" tasks
vitabaks Oct 10, 2023
d215aa0
Disable connection string (libpq) for pgbouncer
vitabaks Oct 10, 2023
6d0ac7e
Update main.yml
vitabaks Oct 10, 2023
728a032
mount: create ZFS pool (if mount.fstype is 'zfs')
vitabaks Oct 10, 2023
c98d348
Update task "Install zfs" for Debian
vitabaks Oct 11, 2023
32d8e19
Merge branch 'master' into cloud
vitabaks Oct 11, 2023
ad54396
Update main.yml
vitabaks Oct 11, 2023
a7db1e3
fix typo
vitabaks Oct 12, 2023
446f5aa
AWS: Set backup variables
vitabaks Oct 20, 2023
393b881
Update Debian.yml
vitabaks Oct 20, 2023
0b6e758
Update RedHat.yml
vitabaks Oct 20, 2023
1904d57
Add the ability to execute pre and post-deploy command
vitabaks Oct 20, 2023
d9d80f0
Add moreutils package
vitabaks Oct 20, 2023
c4ad2fa
improve pre_deploy_command, post_deploy_command tasks
vitabaks Oct 26, 2023
6903f0e
Merge branch 'master' into cloud
vitabaks Nov 7, 2023
67237fc
Merge branch 'master' into cloud
vitabaks Nov 7, 2023
dd55050
Refactoring Security Group/Firewall tasks
vitabaks Nov 11, 2023
7b9e6aa
Update aws.yml
vitabaks Nov 13, 2023
1e285fb
Update consul.yml
vitabaks Nov 19, 2023
0a817bb
Merge branch 'master' into cloud
vitabaks Nov 19, 2023
68fd76e
Update config_pgcluster.yml
vitabaks Nov 19, 2023
712125a
cloud-resources: Include main variables
vitabaks Nov 19, 2023
08b7326
Merge branch 'master' into cloud
vitabaks Nov 24, 2023
b2056e7
AWS: Automatic setup of the backup configuration
vitabaks Nov 26, 2023
f7e8bc8
Update auto_conf.yml
vitabaks Nov 26, 2023
108a483
GCP: Automatic setup of the backup configuration
vitabaks Nov 27, 2023
25ed8a4
Azure: Fix public source_address_prefix
vitabaks Nov 28, 2023
3137bc7
Azure: Automatic setup of the backup configuration
vitabaks Nov 28, 2023
ae47ae4
Add retry for Netdata install
vitabaks Dec 1, 2023
cb438b5
DigitalOcean: Automatic setup of the backup configuration
vitabaks Dec 1, 2023
14e32c8
Do not delete the bucket by default
vitabaks Dec 1, 2023
68c7b7a
Update pre and post deploy commands
vitabaks Dec 4, 2023
72e9cba
Get the log of the pre and post-deploy command in case of an error
vitabaks Dec 4, 2023
a741fde
Fix typo in task "Stop if post-deploy command failed"
vitabaks Dec 6, 2023
ea25796
Merge branch 'master' into cloud
vitabaks Dec 8, 2023
52db824
Update maintenance_disable.yml
vitabaks Dec 9, 2023
66aad28
Update extensions.yml
vitabaks Dec 9, 2023
ddc23bb
Update extensions.yml
vitabaks Dec 9, 2023
23a66f8
fix typo
vitabaks Dec 9, 2023
ec5a63d
compatibility with the pg_upgrade
vitabaks Dec 9, 2023
4be23d3
Set "wal_level=logical"
vitabaks Dec 13, 2023
e8dd09b
Merge branch 'master' into cloud
vitabaks Dec 14, 2023
bb2252e
Rename "provision" to "cloud_provider"
vitabaks Dec 18, 2023
b67570d
Merge branch 'master' into cloud
vitabaks Dec 18, 2023
b000ffc
GCP: Add support for GCP_SERVICE_ACCOUNT_CONTENTS in base64 encoding
vitabaks Dec 22, 2023
b5d6a25
Add "preemptible" option for GCP compute (default: false)
vitabaks Dec 22, 2023
e5c8b96
Merge branch 'master' into cloud
vitabaks Dec 22, 2023
eb0334a
Merge branch 'master' into cloud
vitabaks Dec 26, 2023
e0aa15c
Merge branch 'master' into cloud
vitabaks Jan 4, 2024
3f4c8ed
Update main.yml
vitabaks Jan 4, 2024
15fcc0d
Update auto_conf.yml
vitabaks Jan 4, 2024
03705d1
Update RedHat.yml
vitabaks Jan 4, 2024
3d89e06
Update Debian.yml
vitabaks Jan 4, 2024
e32fd63
Update auto_conf.yml
vitabaks Jan 4, 2024
79ec920
Update auto_conf.yml
vitabaks Jan 4, 2024
fb7f7ab
AWS: Add support for spot instances
vitabaks Jan 11, 2024
51f7cf8
Merge branch 'master' into cloud
vitabaks Jan 11, 2024
5997130
Dockerfile: Update dependencies
vitabaks Jan 12, 2024
1131768
Merge branch 'master' into cloud
vitabaks Jan 18, 2024
74d2789
Update condition for packages tasks
vitabaks Jan 25, 2024
49d3399
remove "sysctl" role from consul.yml and etcd_cluster.yml
vitabaks Jan 25, 2024
69a9d2a
Merge branch 'master' into cloud
vitabaks Jan 25, 2024
12b6622
AWS: Create a Elastic Load Balancer (ELB)
vitabaks Jan 26, 2024
aa0c104
Update aws.yml
vitabaks Jan 26, 2024
ae9a4ca
AWS: fix typo (spot instances)
vitabaks Jan 26, 2024
d5ec364
AWS: Update condition for spot instances
vitabaks Jan 28, 2024
e9e0bc6
Azure: Load Balancer
vitabaks Feb 2, 2024
197bf92
Merge branch 'master' into cloud
vitabaks Feb 2, 2024
9836e81
Merge branch 'master' into cloud
vitabaks Feb 3, 2024
319f3ae
Merge branch 'master' into cloud
vitabaks Feb 9, 2024
bec3bfa
Rename servers_count to server_count
vitabaks Feb 9, 2024
443ecdf
Update packages tasks
vitabaks Feb 9, 2024
87a1d1a
Refactoring the packages tasks
vitabaks Feb 9, 2024
dbce833
Fix typo in 'Install Citus package' task
vitabaks Feb 9, 2024
1addc0d
Azure loadbalancer: database_public_access support
vitabaks Feb 9, 2024
5614d58
Update azure.yml
vitabaks Feb 9, 2024
740f8b3
Update main.yml
vitabaks Feb 13, 2024
46337ef
Update hetzner.yml
vitabaks Feb 14, 2024
89b9ab4
Merge branch 'master' into cloud
vitabaks Feb 19, 2024
d2abd02
Update requirements in Dockerfile
vitabaks Feb 19, 2024
e549c12
Merge branch 'master' into cloud
vitabaks Feb 20, 2024
b482d03
fix 'yaml[trailing-spaces]: Trailing spaces'
vitabaks Feb 20, 2024
87c93f1
Merge branch 'master' into cloud
vitabaks Feb 21, 2024
55fd8e5
DigitalOcean: Load Balancer
vitabaks Feb 28, 2024
9f95b16
DigitalOcean: Postgres Cluster connection info
vitabaks Feb 28, 2024
37ca344
Update main.yml
vitabaks Feb 28, 2024
33fa881
Update digitalocean.yml
vitabaks Feb 28, 2024
7d89e04
DigitalOcean: Load Balancer size 'lb-medium' and size_unit '3' by def…
vitabaks Feb 29, 2024
757bf4c
Merge branch 'master' into cloud
vitabaks Mar 3, 2024
c0d0f2f
Update Dockerfile
vitabaks Mar 12, 2024
cb9f88d
Update main.yml
vitabaks Mar 12, 2024
5d152b9
Merge branch 'master' into cloud
vitabaks Mar 14, 2024
a5d15eb
Merge branch 'cloud' of https://github.com/vitabaks/postgresql_cluste…
vitabaks Mar 14, 2024
43022ca
Hetzner Cloud: Load Balancer
vitabaks Mar 15, 2024
33c93a3
Hetzner Cloud: Postgres Cluster connection info
vitabaks Mar 15, 2024
28e32ed
Update hetzner.yml
vitabaks Mar 15, 2024
909cf07
Merge branch 'master' into cloud
vitabaks Mar 20, 2024
f0ce052
Update consul.yml
vitabaks Mar 20, 2024
2e02191
Merge branch 'master' into cloud
vitabaks Mar 25, 2024
d7f5833
Merge branch 'master' into cloud
vitabaks Mar 28, 2024
6135c93
Merge branch 'master' into cloud
vitabaks Apr 3, 2024
455d691
Update main.yml
vitabaks Apr 9, 2024
2ee2af3
Update inventory.yml
vitabaks Apr 9, 2024
6ad2264
Merge branch 'master' into cloud
vitabaks Apr 9, 2024
339f44a
Merge branch 'master' into cloud
vitabaks Apr 9, 2024
43e1784
Update list of required libraries for Perf
vitabaks Apr 9, 2024
9464038
Merge branch 'master' into cloud
vitabaks Apr 16, 2024
06dd697
Merge branch 'master' into cloud
vitabaks May 6, 2024
cb8194e
Azure: Add 'break-system-packages' for collection requirements
vitabaks May 6, 2024
6254787
Do not install perf by default
vitabaks May 6, 2024
3d4504e
Dockerfile: Update ansible and cloud requirements
vitabaks May 6, 2024
9c43d4b
Describe cloud collections in requirements.yml
vitabaks May 6, 2024
1c78e42
Add system_volume_type variable
vitabaks May 15, 2024
0a7cc34
GCP: Fix disk type option
vitabaks May 23, 2024
aac73a2
gcp: disk_type
vitabaks May 23, 2024
e136431
Merge branch 'master' into cloud
vitabaks May 24, 2024
2418305
Add variables: PGBACKREST_BACKUP_HOUR and WALG_BACKUP_HOUR
vitabaks May 24, 2024
f98c4a7
Create an inventory.json file if the ANSIBLE_INVENTORY_JSON variable …
vitabaks May 27, 2024
47e3f8e
Merge branch 'master' into cloud
vitabaks May 27, 2024
dddddcb
Check if SSH_PRIVATE_KEY_CONTENT is set and create the SSH private ke…
vitabaks May 27, 2024
ba0ba94
Add 'int' filter for postgresql_version variable
vitabaks May 27, 2024
13ebf1b
Add variable 'server_spot'
vitabaks May 28, 2024
b8ef090
Azure: Add support for Spot instance
vitabaks May 28, 2024
c25748a
Add azure_admin_username variable
vitabaks May 28, 2024
c1a0d89
Azure: Add eviction_policy option
vitabaks May 28, 2024
853d6b1
Add "json_log" callback plugin
vitabaks May 30, 2024
a920bce
Update json_log.py
vitabaks May 30, 2024
3d7a12e
Update json_log.py
vitabaks May 30, 2024
1306891
Add timestamp to json_log
vitabaks May 30, 2024
57d6f18
Do not record the result of a skipped task item
vitabaks May 30, 2024
dd99f1a
json_log.py: Add DETAIL level
vitabaks May 30, 2024
5cd3a36
fix flake8 linter warning
vitabaks May 30, 2024
51b6927
cloud-resources: Update "Server info" task
vitabaks Jun 2, 2024
ee43914
rename task "System information" to "System info"
vitabaks Jun 2, 2024
260db30
Update task "System info"
vitabaks Jun 2, 2024
2b96de2
Update main.yml
vitabaks Jun 3, 2024
6101e33
Update main.yml
vitabaks Jun 3, 2024
da2c3a1
Update main.yml
vitabaks Jun 3, 2024
a8a29ac
Update main.yml
vitabaks Jun 3, 2024
b7d7205
deploy-finish: fix typo for Hetzner "Connection info" task
vitabaks Jun 3, 2024
7b4be48
Merge branch 'master' into cloud
vitabaks Jun 13, 2024
2b98634
GCP: Load Balancer
vitabaks Jun 14, 2024
0fdb300
Add gcp_compute_backend_service_log_enable variable
vitabaks Jun 14, 2024
ca4f5da
GCP: reduce check_interval_sec and timeout_sec
vitabaks Jun 14, 2024
4b8ec54
GCP Load Balancer: allow tuning timeouts
vitabaks Jun 14, 2024
3c1b92f
Update gcp.yml
vitabaks Jul 1, 2024
25eb884
Update requirements.yml
vitabaks Jul 1, 2024
7ea7ecc
minimal_ansible_version: 2.15.0
vitabaks Jul 1, 2024
b104908
Update azure.yml
vitabaks Jul 1, 2024
7377d5e
Update Dockerfile
vitabaks Jul 1, 2024
176c574
json_log.py: Add summary with status
vitabaks Jul 2, 2024
4827f7a
entrypoint.sh: Add support for base64 encoded input
vitabaks Jul 9, 2024
2df8699
entrypoint.sh: Update comments
vitabaks Jul 9, 2024
ea59e93
Remove no_log option from authorized-keys
vitabaks Jul 11, 2024
fc4eeda
Add array support for ssh_public_keys
vitabaks Jul 11, 2024
c693d2c
Update main.yml
vitabaks Jul 11, 2024
d1b1287
Update system.yml
vitabaks Jul 11, 2024
f9e3b48
System info: Add server_name, server_location, ip_address
vitabaks Jul 15, 2024
1f8604a
Merge branch 'master' into cloud
vitabaks Jul 15, 2024
7075ed1
deploy-finish: update condition for clouds
vitabaks Jul 20, 2024
b744021
Merge branch 'master' into cloud
vitabaks Jul 20, 2024
620dc8b
Update main.yml
vitabaks Jul 20, 2024
4673a3d
Update ssh_public_keys_list
vitabaks Jul 23, 2024
19f19e2
Fix trailing spaces
vitabaks Jul 23, 2024
c2089ff
ssh_public_keys_list: remove quotes
vitabaks Jul 23, 2024
9be6c65
Update ansible.cfg
vitabaks Jul 23, 2024
9d2ef33
Update ansible.cfg
vitabaks Jul 23, 2024
822450e
Update entrypoint.sh
vitabaks Jul 31, 2024
7dc6269
Update entrypoint.sh
vitabaks Jul 31, 2024
2f3b285
Merge branch 'master' into cloud
vitabaks Aug 2, 2024
9a45b4b
Update gcp.yml
vitabaks Aug 6, 2024
fa7ee25
DigitalOcean: Create a VPC network if no default VPC
vitabaks Aug 6, 2024
e55567c
aws: Move task "Wait for host to be available via SSH"
vitabaks Aug 6, 2024
da5e477
Update azure.yml
vitabaks Aug 6, 2024
1a6d653
Update digitalocean.yml
vitabaks Aug 6, 2024
ecc3c53
Update hetzner.yml
vitabaks Aug 6, 2024
372873d
make sure PostgreSQL config directory exists
vitabaks Aug 6, 2024
adb2bc7
Update main.yml
vitabaks Aug 6, 2024
0922848
Merge branch 'master' into cloud
vitabaks Aug 8, 2024
ba63e25
Merge branch 'master' into cloud
vitabaks Aug 12, 2024
7c4eff7
Update Dockerfile and requirements
vitabaks Aug 12, 2024
e509eaa
Add PIP_BREAK_SYSTEM_PACKAGES for pip module
vitabaks Aug 12, 2024
ddf349e
Add 'keyring' option to apt_key module
vitabaks Aug 12, 2024
2f9be92
Fix ANSIBLE_COLLECTIONS_PATH
vitabaks Aug 12, 2024
6364cd6
fix typo in keyring
vitabaks Aug 12, 2024
def3f83
Update converge.yml
vitabaks Aug 12, 2024
b9e2bcc
increase pgbouncer_default_pool_size and conn limit
vitabaks Aug 12, 2024
de02fc3
fix test for pgbouncer_total_pool_size
vitabaks Aug 12, 2024
f66aea0
Generate a password for patroni restapi
vitabaks Aug 13, 2024
ec8441f
exclude "temporary SSH key" for config_pgcluster.yml
vitabaks Aug 13, 2024
50bc8b6
Update deploy_pgcluster.yml
vitabaks Aug 13, 2024
4c25879
Merge branch 'master' into cloud
vitabaks Aug 13, 2024
ad0fa03
Use ansible_python_interpreter from group_vars/all
vitabaks Aug 13, 2024
e6a6ce4
firewall -> cloud_firewall
vitabaks Aug 13, 2024
07c5612
Update aws.yml
vitabaks Aug 14, 2024
67fc9bd
Update azure.yml
vitabaks Aug 14, 2024
0aae78d
Update digitalocean.yml
vitabaks Aug 14, 2024
b58a287
Update gcp.yml
vitabaks Aug 14, 2024
7808215
Merge branch 'master' into cloud
vitabaks Aug 14, 2024
3850898
Update install_linux_repo.yml
vitabaks Aug 14, 2024
9b41fb0
Merge branch 'cloud' of https://github.com/vitabaks/postgresql_cluste…
vitabaks Aug 14, 2024
d8f0f25
Set variable: 'pgbackrest_install' to configure Postgres backups
vitabaks Aug 14, 2024
ec6fea7
set_fact: 'pgbackrest_install' to configure Postgres backups
vitabaks Aug 14, 2024
a593737
Update bucket name
vitabaks Aug 14, 2024
0c490fe
more variables to configure azure blob storage
vitabaks Aug 14, 2024
b502c73
Update auto_conf.yml
vitabaks Aug 14, 2024
40007c3
Update auto_conf.yml
vitabaks Aug 14, 2024
945d4e3
Update repository tasks for extensions
vitabaks Aug 14, 2024
f84944b
remove extra files
vitabaks Aug 14, 2024
570fd66
Delete consul_1.19.1_SHA256SUMS
vitabaks Aug 14, 2024
e1f648f
Update cache before install packages
vitabaks Aug 14, 2024
ac64c16
Disable citus repo for RedHat based
vitabaks Aug 14, 2024
2a88c69
Update main.yml
vitabaks Aug 15, 2024
0508d98
Update main.yml
vitabaks Aug 15, 2024
25187bd
Add aws_s3_bucket_block_public_acls, aws_s3_bucket_ignore_public_acls…
vitabaks Aug 15, 2024
50fe848
Update gcp.yml
vitabaks Aug 15, 2024
f959af1
Update postgresql_pg_hba
vitabaks Aug 15, 2024
a8b9635
Update main.yml
vitabaks Aug 15, 2024
0775fb0
Update main.yml
vitabaks Aug 15, 2024
c6edd10
Azure Load Balancer
vitabaks Aug 17, 2024
b840a8b
Update Dockerfile
vitabaks Aug 17, 2024
4eed986
Update azure.yml
vitabaks Aug 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .config/make/docker.mak
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
## —— Docker —————————————————————————————————————————————————————————————————————————————————————
TAG ?= local
DOCKER_REGISTRY ?= vitabaks

.PHONY: docker-build
docker-build: ## Run docker build image in local
docker build --tag postgresql_cluster:local --file .config/gitpod/Dockerfile .
docker-build: ## Run docker build image (example: make docker-build TAG=my_tag)
@echo "Building container image with tag $(TAG)";
docker build --no-cache --tag postgresql_cluster:$(TAG) --file Dockerfile .

.PHONY: docker-push
docker-push: ## Push image to Dockerhub (example: make docker-push TAG=my_tag DOCKER_REGISTRY=my_repo DOCKER_REGISTRY_USER="my_username" DOCKER_REGISTRY_PASSWORD="my_password")
@echo "Pushing container image with tag $(TAG)";
echo "$(DOCKER_REGISTRY_PASSWORD)" | docker login --username "$(DOCKER_REGISTRY_USER)" --password-stdin
docker tag postgresql_cluster:$(TAG) $(DOCKER_REGISTRY)/postgresql_cluster:$(TAG)
docker push $(DOCKER_REGISTRY)/postgresql_cluster:$(TAG)

.PHONY: docker-lint
docker-lint: ## Run hadolint command to lint Dokerfile
docker run --rm -i hadolint/hadolint < .config/gitpod/Dockerfile
docker run --rm -i -v ./Dockerfile:/Dockerfile \
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 /Dockerfile

.PHONY: docker-tests
docker-tests: ## Run tests for docker
Expand Down
52 changes: 21 additions & 31 deletions .config/make/molecule.mak
Original file line number Diff line number Diff line change
@@ -1,66 +1,56 @@
# Activate virtual environment
ACTIVATE_VENV = . .venv/bin/activate

## —— Molecule ———————————————————————————————————————————————————————————————————————————————————

.PHONY: molecule-test
molecule-test: ## Run test sequence for default scenario
source .venv/bin/activate
molecule test
$(ACTIVATE_VENV) && molecule test

.PHONY: molecule-destroy
molecule-destroy: ## Run destroy sequence for default scenario
source .venv/bin/activate
molecule destroy
$(ACTIVATE_VENV) && molecule destroy

.PHONY: molecule-converge
molecule-converge: ## Run converge sequence for default scenario
source .venv/bin/activate
molecule converge
$(ACTIVATE_VENV) && molecule converge

.PHONY: molecule-reconverge
molecule-reconverge: ## Run destroy and converge sequence for default scenario
source .venv/bin/activate
molecule destroy
molecule converge
$(ACTIVATE_VENV) && molecule destroy && molecule converge

.PHONY: molecule-test-all
molecule-test-all: ## Run test sequence for all scenarios
source .venv/bin/activate
molecule test --all
$(ACTIVATE_VENV) && molecule test --all

.PHONY: molecule-destroy-all
molecule-destroy-all: ## Run destroy sequence for all scenarios
source .venv/bin/activate
molecule destroy --all
$(ACTIVATE_VENV) && molecule destroy --all

.PHONY: molecule-test-scenario
molecule-test-scenario: ## Run molecule test with specific scenario (example: make molecule-test-scenario MOLECULE_SCENARIO="postgrespro")
source .venv/bin/activate
molecule test --scenario-name $(MOLECULE_SCENARIO)
molecule-test-scenario: ## Run molecule test with specific scenario (example: make molecule-test-scenario MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule test --scenario-name $(MOLECULE_SCENARIO)

.PHONY: molecule-destroy-scenario
molecule-destroy-scenario: ## Run molecule destroy with specific scenario (example: make molecule-destroy-scenario MOLECULE_SCENARIO="postgrespro")
source .venv/bin/activate
molecule destroy --scenario-name $(MOLECULE_SCENARIO)
molecule-destroy-scenario: ## Run molecule destroy with specific scenario (example: make molecule-destroy-scenario MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule destroy --scenario-name $(MOLECULE_SCENARIO)

.PHONY: molecule-converge-scenario
molecule-converge-scenario: ## Run molecule converge with specific scenario (example: make molecule-converge-scenario MOLECULE_SCENARIO="postgrespro")
source .venv/bin/activate
molecule converge --scenario-name $(MOLECULE_SCENARIO)
molecule-converge-scenario: ## Run molecule converge with specific scenario (example: make molecule-converge-scenario MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule converge --scenario-name $(MOLECULE_SCENARIO)

.PHONY: molecule-dependency
molecule-dependency: ## Run dependency sequence
source .venv/bin/activate
molecule dependency
$(ACTIVATE_VENV) && molecule dependency

.PHONY: molecule-verify
molecule-verify: ## Run verify sequence
source .venv/bin/activate
molecule verify
$(ACTIVATE_VENV) && molecule verify

.PHONY: molecule-login
molecule-login: ## Log in to one instance using custom host IP (example: make molecule-login MOLECULE_HOST="10.172.0.20")
source .venv/bin/activate
molecule login --host $(MOLECULE_HOST)
$(ACTIVATE_VENV) && molecule login --host $(MOLECULE_HOST)

.PHONY: molecule-login-scenario
molecule-login-scenario: ## Log in to one instance using custom host IP and scenario name (example: make molecule-login-scenario MOLECULE_HOST="10.172.1.20" MOLECULE_SCENARIO="postgrespro")
source .venv/bin/activate
molecule login --host $(MOLECULE_HOST) --scenario-name $(MOLECULE_SCENARIO)
molecule-login-scenario: ## Log in to one instance using custom host IP and scenario name (example: make molecule-login-scenario MOLECULE_HOST="10.172.1.20" MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule login --host $(MOLECULE_HOST) --scenario-name $(MOLECULE_SCENARIO)
43 changes: 20 additions & 23 deletions .config/make/python.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ python_launcher ?= python3.10
python_requirements_file ?= requirements.txt
python_requirements_dev_file ?= .config/python/dev/requirements.txt

# Activate virtual environment
ACTIVATE_VENV = . .venv/bin/activate

## —— Python —————————————————————————————————————————————————————————————————————————————————————
.PHONY: python-bootstrap
python-bootstrap: ## Bootstrap python
Expand All @@ -20,56 +23,50 @@ python-bootstrap-dev: ## Bootstrap python for dev env
# ===============================================================================================
.PHONY: python-venv-init
python-venv-init: ## Create venv ".venv/" if not exist
if [ ! -d .venv ] ; then
$(python_launcher) -m venv .venv
fi
@echo "Checking if .venv directory exists..."; \
if [ ! -d .venv ]; then echo "Creating virtual environment using $(python_launcher)..."; $(python_launcher) -m venv .venv; else echo ".venv directory already exists. Skipping creation."; fi

.PHONY: python-venv-upgrade
python-venv-upgrade: ## Upgrade venv with pip, setuptools and wheel
source .venv/bin/activate
pip install --upgrade pip setuptools wheel
@echo "Upgrading virtual environment..."
$(ACTIVATE_VENV) && pip install --upgrade pip setuptools wheel

.PHONY: python-venv-requirements
python-venv-requirements: ## Install or upgrade from $(python_requirements_file)
source .venv/bin/activate
pip install --upgrade --requirement $(python_requirements_file)
@echo "Installing or upgrading requirements from $(python_requirements_file)..."
$(ACTIVATE_VENV) && pip install --upgrade --requirement $(python_requirements_file)

.PHONY: python-venv-requirements-dev
python-venv-requirements-dev: ## Install or upgrade from $(python_requirements_dev_file)
source .venv/bin/activate
pip install --upgrade --requirement $(python_requirements_dev_file)
@echo "Installing or upgrading dev requirements from $(python_requirements_dev_file)..."
$(ACTIVATE_VENV) && pip install --upgrade --requirement $(python_requirements_dev_file)

.PHONY: python-venv-linters-install
python-venv-linters-install: ## Install or upgrade linters
source .venv/bin/activate
pip install --upgrade flake8
@echo "Installing or upgrading linters..."
$(ACTIVATE_VENV) && pip install --upgrade flake8

.PHONY: python-venv-purge
python-venv-purge: ## Remove venv ".venv/" folder
rm -rf .venv
@echo "Removing .venv directory..."
@rm -rf .venv

# ===============================================================================================
# Utils
# ===============================================================================================
.PHONY: python-purge-cache
python-purge-cache: ## Purge cache to avoid used cached files
if [ -d .venv ] ; then
source .venv/bin/activate
pip cache purge
fi
@echo "Purging pip cache..."
@if [ -d .venv ] ; then $(ACTIVATE_VENV) && pip cache purge; fi

.PHONY: python-version
python-version: ## Displays the python version used for the .venv
source .venv/bin/activate
$(python_launcher) --version
$(ACTIVATE_VENV) && $(python_launcher) --version

.PHONY: python-flake8
python-flake8: ## Run flake8 linter for python
source .venv/bin/activate
flake8 --config .config/.flake8
$(ACTIVATE_VENV) && flake8 --config .config/.flake8

.PHONY: python-pytest
python-pytest: ## Run pytest to test python scripts
source .venv/bin/activate
cd scripts/
$(python_launcher) -m pytest
$(ACTIVATE_VENV) && cd scripts/ && $(python_launcher) -m pytest
37 changes: 35 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
Expand All @@ -17,6 +19,25 @@ jobs:
- name: Set TERM environment variable
run: echo "TERM=xterm" >> $GITHUB_ENV

- name: Extract branch or tag name
shell: bash
run: |
REF_NAME=""
if [[ -n "${GITHUB_HEAD_REF}" ]]; then
# This is a PR, use the source branch name
REF_NAME="${GITHUB_HEAD_REF}"
else
# This is a push, use the branch or tag name from GITHUB_REF
REF_NAME="${GITHUB_REF##*/}"
fi

# If this is the master branch, use 'latest' as the tag, otherwise use the REF_NAME
if [[ "$REF_NAME" == "master" ]]; then
echo "TAG=latest" >> $GITHUB_ENV
else
echo "TAG=$REF_NAME" >> $GITHUB_ENV
fi

- name: Checkout
uses: actions/checkout@v3

Expand All @@ -28,5 +49,17 @@ jobs:
- name: Install dependencies
run: make bootstrap-dev

- name: Run Docker tests
run: make docker-tests
- name: Run Docker lint
run: make docker-lint

- name: Run Docker build
run: make docker-build
env:
TAG: ${{ env.TAG }}

- name: Run Docker push
run: make docker-push
env:
TAG: ${{ env.TAG }}
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM debian:bookworm-slim
LABEL maintainer="Vitaliy Kukharik [email protected]"

USER root

# Set SHELL to Bash to ensure pipefail is supported
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Copy postgresql_cluster repository
COPY . /postgresql_cluster

# Install required packages, Python dependencies, Ansible requirements, and perform cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/partial \
&& apt-get update -o Acquire::CompressionTypes::Order::=gz \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
ca-certificates gnupg git python3 python3-dev python3-pip keychain ssh-client sshpass\
gcc g++ cmake make libssl-dev curl apt-transport-https lsb-release gnupg \
&& pip3 install --break-system-packages --no-cache-dir -r \
/postgresql_cluster/requirements.txt \
&& ansible-galaxy install --force -r \
/postgresql_cluster/requirements.yml \
&& ansible-galaxy install --force -r \
/postgresql_cluster/roles/consul/requirements.yml \
&& ansible-galaxy collection list \
&& pip3 install --break-system-packages --no-cache-dir -r \
/root/.ansible/collections/ansible_collections/azure/azcollection/requirements.txt \
&& curl -sLS https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null \
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/azure-cli.list \
&& apt-get update && apt-get install --no-install-recommends -y azure-cli \
&& apt-get autoremove -y --purge gnupg git python3-dev gcc g++ cmake make libssl-dev \
&& apt-get clean -y autoclean \
&& rm -rf /var/lib/apt/lists/* /tmp/* \
&& chmod +x /postgresql_cluster/entrypoint.sh

# Set environment variable for Ansible collections paths
ENV ANSIBLE_COLLECTIONS_PATH=/root/.ansible/collections/ansible_collections:/usr/local/lib/python3.11/dist-packages/ansible_collections
ENV USER=root

WORKDIR /postgresql_cluster

ENTRYPOINT ["./entrypoint.sh"]
38 changes: 20 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,7 @@ python_launcher := python$(shell cat .config/python_version.config | cut -d '='

-include $(addsuffix /*.mak, $(shell find .config/make -type d))

## —— Tests collection ———————————————————————————————————————————————————————————————————————
.PHONY: tests
tests: ## tests Ansible collection
$(MAKE) docker-tests
$(MAKE) lint
$(MAKE) molecule-test-all

.PHONY: tests-fast
tests-fast: ## tests Ansible collection quickly
$(MAKE) lint
$(MAKE) molecule-converge

## —— Bootstrap collection ———————————————————————————————————————————————————————————————————————
## —— Bootstrap ——————————————————————————————————————————————————————————————————————————————————
.PHONY: bootstrap
bootstrap: ## Bootstrap Ansible collection
$(MAKE) python-bootstrap
Expand All @@ -60,19 +48,33 @@ bootstrap-dev: ## Bootstrap Ansible collection for development
$(MAKE) bootstrap
$(MAKE) python-bootstrap-dev

## —— Virtualenv ————————————————————————————————————————————————————————————————————————————————
## —— Virtualenv ————————————————————————————————————————————————————————————————————————————————
.PHONY: reinitialization
reinitialization: ## Return to an initial state of Bootstrap Ansible collection
reinitialization: ## Return to initial state of Bootstrap Ansible collection
$(MAKE) clean
$(MAKE) bootstrap

.PHONY: reinitialization-dev
reinitialization-dev: ## Return to an initial state of Bootstrap Ansible collection for development
reinitialization-dev: ## Return to initial state of Bootstrap Ansible collection for development
$(MAKE) reinitialization
$(MAKE) bootstrap-dev

## —— Tests ——————————————————————————————————————————————————————————————————————————————————————
.PHONY: tests
tests: ## tests Ansible
$(MAKE) docker-tests
$(MAKE) lint
$(MAKE) molecule-test-all

.PHONY: tests-fast
tests-fast: ## tests Ansible quickly
$(MAKE) lint
$(MAKE) molecule-converge

## —— Clean ——————————————————————————————————————————————————————————————————————————————————————
.PHONY: clean
clean: ## Clean collection
$(MAKE) clean
clean: ## Clean
rm -rf .venv/
rm -rf vendor/
rm -f *.mak
Expand All @@ -81,4 +83,4 @@ clean: ## Clean collection
rm -rf scripts/tests/__pycache__/
rm -rf scripts/modules/__pycache__/
rm -rf scripts/modules/services/__pycache__/
rm -rf scripts/modules/utils/__pycache__/
rm -rf scripts/modules/utils/__pycache__/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Minimum supported Ansible version: 8.0.0 (ansible-core 2.15.0)
## Requirements
This playbook requires root privileges or sudo.

Ansible ([What is Ansible](https://www.ansible.com/resources/videos/quick-start-video)?)
Ansible ([What is Ansible](https://www.ansible.com/how-ansible-works/)?)

if dcs_type: "consul", please install consul role requirements on the control node:

Expand Down
Loading
Loading