Skip to content

Commit

Permalink
Add molecule test for Oracle Linux 7
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks committed Jun 16, 2021
1 parent f14191a commit e7af72a
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/schedule_pg_oracle_linux7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# yamllint disable rule:truthy

name: scheduled PostgreSQL (OracleLinux 7)

on:
schedule:
- cron: '45 0 * * *'

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: pip3 install molecule[docker] ansible

- name: Run Molecule tests
run: molecule test --scenario-name oraclelinux
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO_TAG: 7

...
36 changes: 36 additions & 0 deletions molecule/oraclelinux/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Converge
hosts: all
gather_facts: true

tasks:
- name: Set variables for molecule
set_fact:
firewall_enable_ipv6: false # Added to prevent test failures in CI.
sysctl_set: false # Added to prevent test failures in CI.
nameservers: ["8.8.8.8", "9.9.9.9"]
cacheable: true

- name: Prepare | Clean yum cache
command: yum clean all
args:
warn: false
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version == '7'

- name: Prepare | Clean dnf cache
command: dnf clean all
args:
warn: false
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version is version('8', '>=')

- name: Prepare | Check that sudo package is exists
package:
name: sudo

- import_playbook: ../../deploy_pgcluster.yml

...
162 changes: 162 additions & 0 deletions molecule/oraclelinux/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
# yamllint disable rule:comments-indentation

dependency:
name: galaxy
enabled: false
driver:
name: docker
platforms:
- name: 10.172.0.17
hostname: etcd01
image: robertdebock/oraclelinux:${MOLECULE_DISTRO_TAG:-7}
# docker_networks: # TODO github.com/ansible-community/molecule/pull/2696
# - name: test_docker_network
# ipam_config:
# - subnet: 10.172.0.0/24
# gateway: 10.172.0.1
networks:
- name: test_docker_network
ipv4_address: 10.172.0.17
exposed_ports:
- 2379/tcp
- 2380/tcp
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
groups:
- etcd_cluster

- name: 10.172.0.18
hostname: etcd02
image: robertdebock/oraclelinux:${MOLECULE_DISTRO_TAG:-7}
networks:
- name: test_docker_network
ipv4_address: 10.172.0.18
exposed_ports:
- 2379/tcp
- 2380/tcp
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
groups:
- etcd_cluster

- name: 10.172.0.19
hostname: etcd03
image: robertdebock/oraclelinux:${MOLECULE_DISTRO_TAG:-7}
networks:
- name: test_docker_network
ipv4_address: 10.172.0.19
exposed_ports:
- 2379/tcp
- 2380/tcp
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
groups:
- etcd_cluster

- name: 10.172.0.20
hostname: pgnode01
image: robertdebock/oraclelinux:${MOLECULE_DISTRO_TAG:-7}
networks:
- name: test_docker_network
ipv4_address: 10.172.0.20
exposed_ports:
- 8008/tcp
- 5432/tcp
- 6432/tcp
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
groups:
- master
- postgres_cluster
- balancers

- name: 10.172.0.21
hostname: pgnode02
image: robertdebock/oraclelinux:${MOLECULE_DISTRO_TAG:-7}
networks:
- name: test_docker_network
ipv4_address: 10.172.0.21
exposed_ports:
- 8008/tcp
- 5432/tcp
- 6432/tcp
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
pre_build_image: true
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
groups:
- replica
- postgres_cluster
- balancers

provisioner:
name: ansible
config_options:
defaults:
display_skipped_hosts: false
remote_tmp: "~/.ansible/tmp"
allow_world_readable_tmpfiles: false
timeout: 60
inventory:
links:
group_vars: ../../group_vars/
playbooks:
prepare: prepare.yml

scenario:
create_sequence:
- prepare
- create
converge_sequence:
- prepare
- create
- converge
destroy_sequence:
- cleanup
- destroy
test_sequence:
- cleanup
- destroy
- syntax
- prepare
- create
- converge
# - idempotence # >> role:patroni,task:"data directory check result"
- verify
- cleanup
- destroy

verifier:
name: ansible
enabled: false # TODO

...
21 changes: 21 additions & 0 deletions molecule/oraclelinux/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: "Update docker network(s)"
hosts: localhost
gather_facts: false
become: false
tasks:
- name: "Create docker network: test_docker_network"
docker_network:
name: test_docker_network
driver: bridge
enable_ipv6: false
internal: false
ipam_config:
- subnet: 10.172.0.0/24
gateway: 10.172.0.1
force: true
state: present
labels:
owner: molecule

...

0 comments on commit e7af72a

Please sign in to comment.