Skip to content

Commit b6cc998

Browse files
authored
Merge pull request #7 from fidanf/ansible-lint-v5
Ansible lint v5 + CI refactoring
2 parents b9cae89 + 3165d5f commit b6cc998

9 files changed

+120
-121
lines changed

.ansible-lint

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
---
12
# https://docs.ansible.com/ansible-lint/rules/default_rules.html
3+
exclude_paths:
4+
- ../.ansible/roles/
5+
- .cache/
6+
- .github/
7+
verbosity: 1
28
use_default_rules: true
39
skip_list:
4-
- '106' # Role names are now limited to contain only lowercase alphanumeric characters, plus ‘_’ and start with an alpha character
5-
- '204' # Lines should be no longer than 160 chars
6-
- '201' # Trailing whitespace
7-
- '301' # Commands should not change things if nothing needs doing
8-
- '303' # Using command rather than module
9-
- '305' # Use shell only when shell functionality is required
10-
- '501' # become_user requires become to work as expected
11-
- '701' # meta/main.yml should contain relevant info
12-
- '503' # Tasks that run when changed should likely be handlers
13-
- '602' # Don't compare to empty string
14-
verbosity: 1
15-
exclude_paths:
16-
- ../.ansible/roles
17-
- tasks/main.yml
10+
- command-instead-of-shell
11+
- no-changed-when
12+
- no-handler
13+
- empty-string-compare
14+
- ignore-errors
15+
- var-naming
16+
warn_list:
17+
- no-log-password

.travis.yml

+16-23
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
11
---
22
os: linux
3-
dist: bionic
4-
language: shell
3+
dist: focal
4+
language: python
5+
python:
6+
- 3.8
57

68
env:
79
global:
8-
- VAGRANT_DEFAULT_PROVIDER=libvirt
9-
- ROLE_PATH=$TRAVIS_BUILD_DIR
10-
- PY_COLORS=1
10+
- VAGRANT_DEFAULT_PROVIDER: libvirt
11+
- PY_COLORS: 1
1112
jobs:
1213
- MOLECULE_DISTRO: generic/ubuntu1804
1314
- MOLECULE_DISTRO: generic/debian10
1415

15-
services:
16-
- docker
17-
1816
cache:
1917
directories:
2018
- /home/travis/.vagrant.d/boxes
21-
- /home/travis/.cache/pipenv
19+
- /home/travis/.cache/pip
2220

2321
before_install:
2422
- |
25-
curl -Os https://releases.hashicorp.com/vagrant/2.2.14/vagrant_2.2.14_x86_64.deb
26-
curl -Os https://releases.hashicorp.com/vagrant/2.2.14/vagrant_2.2.14_SHA256SUMS
27-
curl -Os https://releases.hashicorp.com/vagrant/2.2.14/vagrant_2.2.14_SHA256SUMS.sig
28-
gpg --receive-key 51852D87348FFC4C
29-
gpg --verify vagrant_2.2.14_SHA256SUMS.sig vagrant_2.2.14_SHA256SUMS
30-
sha256sum -c vagrant_2.2.14_SHA256SUMS 2>&1 | grep OK
31-
sudo apt-get update && sudo apt-get install -y bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev
32-
sudo dpkg -i vagrant_2.2.14_x86_64.deb
33-
sudo vagrant plugin install vagrant-libvirt
34-
rm -rf vagrant_2.2.14_*
23+
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
24+
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
25+
sudo apt-get update && sudo apt-get install vagrant
26+
sudo apt-get install -y build-essential qemu-kvm qemu-utils libvirt-dev libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager dnsmasq
27+
CONFIGURE_ARGS="with-libvirt-include=/usr/share/libvirt with-libvirt-lib=/usr/lib64" sudo vagrant plugin install vagrant-libvirt
28+
- |
29+
sudo -H pip install --upgrade pip
30+
sudo -H pip install --upgrade --ignore-installed --requirement requirements.txt
3531
- |
36-
sudo apt-get -y purge python3-openssl && sudo apt-get -y autoremove
37-
sudo apt-get update && sudo apt-get install -y ca-certificates curl gcc iproute2 pwgen python3 python3-dev sudo
38-
curl -skL https://bootstrap.pypa.io/get-pip.py | sudo -H python3
39-
sudo -H pip3 install --upgrade --ignore-installed --requirement requirements.txt
32+
molecule --version
4033
4134
script:
4235
- sudo -E molecule test

meta/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
galaxy_info:
33
author: Frank FIDANZA
44
company: RG
5+
namespace: fidanf
56
role_name: pgpool
67
description: Installs and configures Pgpool-II
78
min_ansible_version: 2.8

molecule/default/collections.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
collections:
3+
- community.crypto

molecule/default/converge.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
hosts: pgpool
44
gather_facts: yes
55
become: yes
6-
vars:
7-
ansible_python_interpreter: /usr/bin/python3
8-
role_path: "{{ lookup('env', 'ROLE_PATH') }}"
6+
97
roles:
10-
- name: "{{ role_path if role_path is defined and role_path else lookup('env', 'HOME') + '/ansible-role-pgpool' }}"
8+
- name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}"
119
vars:
1210
pgpool_postgresql_version: 12
1311
# .pcpass file

molecule/default/molecule.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
dependency:
33
name: galaxy
4+
options:
5+
role-file: ${MOLECULE_PROJECT_DIRECTORY}/molecule/default/requirements.yml
6+
requirements-file: ${MOLECULE_PROJECT_DIRECTORY}/molecule/default/collections.yml
47
lint: |
58
set -e
69
yamllint .
@@ -12,7 +15,7 @@ driver:
1215
platforms:
1316
- name: pgsql01
1417
box: ${MOLECULE_DISTRO:-"generic/debian10"}
15-
groups:
18+
groups:
1619
- pgpool
1720
config_options:
1821
ssh.keep_alive: yes
@@ -29,7 +32,7 @@ platforms:
2932
config_options:
3033
ssh.keep_alive: yes
3134
ssh.remote_user: "'vagrant'"
32-
groups:
35+
groups:
3336
- pgpool
3437
memory: 1024
3538
cpus: 1
@@ -41,25 +44,20 @@ platforms:
4144
provisioner:
4245
name: ansible
4346
log: true
44-
config_options:
45-
defaults:
46-
callback_whitelist: "profile_tasks,timer"
47-
allow_world_readable_tmpfiles: true
48-
ansible_python_interpreter: /usr/bin/python3
4947
inventory:
5048
host_vars:
5149
pgsql01:
5250
# ansible
5351
ansible_host: 192.168.30.10
5452
# repmgr
55-
repmgr_node_id: 1
53+
repmgr_node_id: 1
5654
# pgpool
5755
pgpool_wd_hostname: pgsql01
5856
pgpool_wd_priority: 1
5957
# watchdog
6058
pgpool_heartbeat_destination:
6159
- hostname: pgsql02
62-
pgpool_other_settings:
60+
pgpool_other_settings:
6361
- hostname: pgsql02
6462
pgsql02:
6563
# ansible
@@ -71,5 +69,11 @@ provisioner:
7169
# watchdog
7270
pgpool_heartbeat_destination:
7371
- hostname: pgsql01
74-
pgpool_other_settings:
72+
pgpool_other_settings:
7573
- hostname: pgsql01
74+
config_options:
75+
defaults:
76+
callback_whitelist: "profile_tasks,timer"
77+
allow_world_readable_tmpfiles: true
78+
interpreter_python: /usr/bin/python3
79+
pipelining: true

molecule/default/prepare.yml

+62-63
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,6 @@
44
gather_facts: no
55
become: yes
66

7-
vars:
8-
ansible_python_interpreter: /usr/bin/python3
9-
repmgr_version: "5.1"
10-
repmgr_master: pgsql01
11-
repmgr_target_group: pgpool
12-
repmgr_promote_command: /usr/bin/repmgr standby promote -f /etc/repmgr.conf --log-to-file
13-
repmgr_follow_command: /usr/bin/repmgr standby follow -f /etc/repmgr.conf --log-to-file --upstream-node-id=%n
14-
repmgr_monitoring_history: "yes"
15-
repmgr_connection_check_type: query
16-
repmgr_log_level: INFO
17-
postgresql_version: 12
18-
postgresql_listen_addresses: "*"
19-
postgresql_port: 5432
20-
postgresql_max_connections: 128
21-
postgresql_wal_level: "replica"
22-
postgresql_max_wal_senders: 10
23-
postgresql_max_replication_slots: 10
24-
postgresql_wal_keep_segments: 100
25-
postgresql_hot_standby: on
26-
postgresql_data_checksums: true
27-
postgresql_wal_compression: on
28-
postgresql_wal_log_hints: on
29-
postgresql_ext_install_repmgr: yes
30-
postgresql_shared_preload_libraries:
31-
- repmgr
32-
postgresql_log_checkpoints: on
33-
postgresql_log_connections: on
34-
postgresql_log_disconnections: on
35-
postgresql_log_temp_files: 0
36-
# pg_hba.conf
37-
postgresql_pg_hba_custom:
38-
- { type: "host", database: "replication", user: "{{ repmgr_user }}", address: "192.168.30.0/24", method: "trust" }
39-
- { type: "host", database: "replication", user: "{{ repmgr_user }}", address: "127.0.0.1/32", method: "trust" }
40-
- { type: "host", database: "{{ repmgr_database }}", user: "{{ repmgr_user }}", address: "127.0.0.1/32", method: "trust" }
41-
- { type: "host", database: "{{ repmgr_database }}", user: "{{ repmgr_user }}", address: "192.168.30.0/24", method: "trust" }
42-
- { type: "host", database: "all", user: "postgres", address: "192.168.30.0/24", method: "trust" }
43-
- { type: "host", database: "testdb", user: "all", address: "192.168.0.0/16", method: "trust" }
44-
# Databases
45-
postgresql_databases:
46-
- name: "{{ repmgr_database }}"
47-
owner: "{{ repmgr_user }}"
48-
encoding: "UTF-8"
49-
- name: testdb
50-
owner: admin
51-
encoding: "UTF-8"
52-
# Users
53-
postgresql_users:
54-
- name: "{{ repmgr_user }}"
55-
pass: "{{ repmgr_password }}"
56-
- name: admin
57-
pass: secret # postgresql >=10 does not accept unencrypted passwords
58-
encrypted: yes
59-
# Roles
60-
postgresql_user_privileges:
61-
- name: "{{ repmgr_user }}"
62-
db: "{{ repmgr_database }}"
63-
priv: "ALL"
64-
role_attr_flags: "SUPERUSER,REPLICATION"
65-
- name: admin
66-
db: testdb
67-
role_attr_flags: "SUPERUSER"
68-
697
pre_tasks:
708
- name: Wait for SSH
719
wait_for_connection:
@@ -97,4 +35,65 @@
9735
loop: "{{ groups[repmgr_target_group] }}"
9836

9937
roles:
100-
- name: fidanf.postgresql-ha
38+
- name: fidanf.postgresql_ha
39+
vars:
40+
repmgr_version: 5.2
41+
repmgr_version_debian: 5.2.1-1.pgdg100+1
42+
repmgr_master: pgsql01
43+
repmgr_target_group: pgpool
44+
repmgr_promote_command: /usr/bin/repmgr standby promote -f /etc/repmgr.conf --log-to-file
45+
repmgr_follow_command: /usr/bin/repmgr standby follow -f /etc/repmgr.conf --log-to-file --upstream-node-id=%n
46+
repmgr_monitoring_history: "yes"
47+
repmgr_connection_check_type: query
48+
repmgr_log_level: INFO
49+
postgresql_version: 12
50+
postgresql_listen_addresses: "*"
51+
postgresql_port: 5432
52+
postgresql_max_connections: 128
53+
postgresql_wal_level: "replica"
54+
postgresql_max_wal_senders: 10
55+
postgresql_max_replication_slots: 10
56+
postgresql_wal_keep_segments: 100
57+
postgresql_hot_standby: on
58+
postgresql_data_checksums: true
59+
postgresql_wal_compression: on
60+
postgresql_wal_log_hints: on
61+
postgresql_ext_install_repmgr: yes
62+
postgresql_shared_preload_libraries:
63+
- repmgr
64+
postgresql_log_checkpoints: on
65+
postgresql_log_connections: on
66+
postgresql_log_disconnections: on
67+
postgresql_log_temp_files: 0
68+
# pg_hba.conf
69+
postgresql_pg_hba_custom:
70+
- { type: "host", database: "replication", user: "{{ repmgr_user }}", address: "192.168.30.0/24", method: "trust" }
71+
- { type: "host", database: "replication", user: "{{ repmgr_user }}", address: "127.0.0.1/32", method: "trust" }
72+
- { type: "host", database: "{{ repmgr_database }}", user: "{{ repmgr_user }}", address: "127.0.0.1/32", method: "trust" }
73+
- { type: "host", database: "{{ repmgr_database }}", user: "{{ repmgr_user }}", address: "192.168.30.0/24", method: "trust" }
74+
- { type: "host", database: "all", user: "postgres", address: "192.168.30.0/24", method: "trust" }
75+
- { type: "host", database: "testdb", user: "all", address: "192.168.0.0/16", method: "trust" }
76+
# Databases
77+
postgresql_databases:
78+
- name: "{{ repmgr_database }}"
79+
owner: "{{ repmgr_user }}"
80+
encoding: "UTF-8"
81+
- name: testdb
82+
owner: admin
83+
encoding: "UTF-8"
84+
# Users
85+
postgresql_users:
86+
- name: "{{ repmgr_user }}"
87+
pass: "{{ repmgr_password }}"
88+
- name: admin
89+
pass: secret # postgresql >=10 does not accept unencrypted passwords
90+
encrypted: yes
91+
# Roles
92+
postgresql_user_privileges:
93+
- name: "{{ repmgr_user }}"
94+
db: "{{ repmgr_database }}"
95+
priv: "ALL"
96+
role_attr_flags: "SUPERUSER,REPLICATION"
97+
- name: admin
98+
db: testdb
99+
role_attr_flags: "SUPERUSER"

molecule/default/requirements.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2-
- src: https://github.com/fidanf/ansible-role-postgresql-ha
3-
name: fidanf.postgresql-ha
4-
version: master
2+
roles:
3+
- src: https://github.com/fidanf/ansible-role-postgresql-ha
4+
name: fidanf.postgresql_ha
5+
version: 2.4.2

requirements.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
ansible>=2.10.7,<2.11.0
2-
molecule==3.2.0
2+
molecule
33
molecule-vagrant==0.6.1
4-
ansible-lint==4.3.7
5-
yamllint==1.26.0
4+
pyyaml<6,>=5.1
5+
ansible-lint
6+
yamllint
67
python-vagrant
78
docker
89
docker-compose
910
netaddr
1011
dnspython
1112
cryptography
1213
jsondiff
13-
pyyaml
1414
pyOpenSSL

0 commit comments

Comments
 (0)