Merge pull request #315 from myii/feat/update-all-platforms-for-postgresql-13-inc-CI

feat: update all platforms for PostgreSQL 13 (inc. `use_upstream_repo` in CI)
This commit is contained in:
Imran Iqbal 2021-07-20 19:34:57 +01:00 committed by GitHub
commit 18d3df43ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 405 additions and 84 deletions

View file

@ -15,8 +15,11 @@ jobs:
matrix:
instance:
- default-freebsd-130-master-py3
# - freebsd-130-master-py3
- default-freebsd-122-master-py3
# - freebsd-122-master-py3
- default-freebsd-114-master-py3
# - freebsd-114-master-py3
# - default-freebsd-130-3002-6-py3
# - default-freebsd-122-3002-6-py3
# - default-freebsd-114-3002-6-py3

View file

@ -102,7 +102,7 @@ rubocop:
###############################################################################
# Define `test` template
###############################################################################
.test_instance:
.test_instance: &test_instance
stage: *stage_test
image: *image_dindruby
services: *services_docker_dind
@ -117,6 +117,13 @@ rubocop:
# Alternative value to consider: `${CI_JOB_NAME}`
- 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"'
###############################################################################
# Define `test` template (`allow_failure: true`)
###############################################################################
.test_instance_failure_permitted:
<<: *test_instance
allow_failure: true
###############################################################################
# `test` stage: each instance below uses the `test` template above
###############################################################################
@ -135,26 +142,62 @@ rubocop:
# default-oraclelinux-7-tiamat-py3: {extends: '.test_instance'}
# default-almalinux-8-tiamat-py3: {extends: '.test_instance'}
# default-rockylinux-8-tiamat-py3: {extends: '.test_instance'}
default-debian-11-master-py3: {extends: '.test_instance'}
default-debian-10-master-py3: {extends: '.test_instance'}
default-debian-9-master-py3: {extends: '.test_instance'}
default-ubuntu-2004-master-py3: {extends: '.test_instance'}
default-ubuntu-1804-master-py3: {extends: '.test_instance'}
default-centos-8-master-py3: {extends: '.test_instance'}
default-centos-7-master-py3: {extends: '.test_instance'}
default-fedora-34-master-py3: {extends: '.test_instance'}
default-fedora-33-master-py3: {extends: '.test_instance'}
default-opensuse-leap-153-master-py3: {extends: '.test_instance'}
default-opensuse-leap-152-master-py3: {extends: '.test_instance'}
# default-debian-11-master-py3: {extends: '.test_instance'}
# repo-debian-11-master-py3: {extends: '.test_instance'}
debian-11-master-py3: {extends: '.test_instance'}
# default-debian-10-master-py3: {extends: '.test_instance'}
# repo-debian-10-master-py3: {extends: '.test_instance'}
debian-10-master-py3: {extends: '.test_instance'}
# default-debian-9-master-py3: {extends: '.test_instance'}
# repo-debian-9-master-py3: {extends: '.test_instance'}
debian-9-master-py3: {extends: '.test_instance'}
# default-ubuntu-2004-master-py3: {extends: '.test_instance'}
# repo-ubuntu-2004-master-py3: {extends: '.test_instance'}
ubuntu-2004-master-py3: {extends: '.test_instance'}
# default-ubuntu-1804-master-py3: {extends: '.test_instance'}
# repo-ubuntu-1804-master-py3: {extends: '.test_instance'}
ubuntu-1804-master-py3: {extends: '.test_instance'}
# default-centos-8-master-py3: {extends: '.test_instance'}
# repo-centos-8-master-py3: {extends: '.test_instance'}
centos-8-master-py3: {extends: '.test_instance'}
# default-centos-7-master-py3: {extends: '.test_instance'}
# repo-centos-7-master-py3: {extends: '.test_instance'}
centos-7-master-py3: {extends: '.test_instance'}
# default-fedora-34-master-py3: {extends: '.test_instance'}
# repo-fedora-34-master-py3: {extends: '.test_instance'}
fedora-34-master-py3: {extends: '.test_instance'}
# default-fedora-33-master-py3: {extends: '.test_instance'}
# repo-fedora-33-master-py3: {extends: '.test_instance'}
fedora-33-master-py3: {extends: '.test_instance'}
# default-opensuse-leap-153-master-py3: {extends: '.test_instance'}
# repo-opensuse-leap-153-master-py3: {extends: '.test_instance'}
opensuse-leap-153-master-py3: {extends: '.test_instance'}
# default-opensuse-leap-152-master-py3: {extends: '.test_instance'}
# repo-opensuse-leap-152-master-py3: {extends: '.test_instance_failure_permitted'}
opensuse-leap-152-master-py3: {extends: '.test_instance_failure_permitted'}
default-opensuse-tmbl-latest-master-py3: {extends: '.test_instance'}
default-amazonlinux-2-master-py3: {extends: '.test_instance'}
default-oraclelinux-8-master-py3: {extends: '.test_instance'}
default-oraclelinux-7-master-py3: {extends: '.test_instance'}
# opensuse-tmbl-latest-master-py3: {extends: '.test_instance'}
# default-amazonlinux-2-master-py3: {extends: '.test_instance'}
# repo-amazonlinux-2-master-py3: {extends: '.test_instance'}
amazonlinux-2-master-py3: {extends: '.test_instance'}
# default-oraclelinux-8-master-py3: {extends: '.test_instance'}
# repo-oraclelinux-8-master-py3: {extends: '.test_instance'}
oraclelinux-8-master-py3: {extends: '.test_instance'}
# default-oraclelinux-7-master-py3: {extends: '.test_instance'}
# repo-oraclelinux-7-master-py3: {extends: '.test_instance'}
oraclelinux-7-master-py3: {extends: '.test_instance'}
default-arch-base-latest-master-py3: {extends: '.test_instance'}
# arch-base-latest-master-py3: {extends: '.test_instance'}
# default-gentoo-stage3-latest-master-py3: {extends: '.test_instance'}
# gentoo-stage3-latest-master-py3: {extends: '.test_instance'}
# default-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'}
default-almalinux-8-master-py3: {extends: '.test_instance'}
default-rockylinux-8-master-py3: {extends: '.test_instance'}
# gentoo-stage3-systemd-master-py3: {extends: '.test_instance'}
# default-almalinux-8-master-py3: {extends: '.test_instance'}
# repo-almalinux-8-master-py3: {extends: '.test_instance'}
almalinux-8-master-py3: {extends: '.test_instance'}
# default-rockylinux-8-master-py3: {extends: '.test_instance'}
# repo-rockylinux-8-master-py3: {extends: '.test_instance'}
rockylinux-8-master-py3: {extends: '.test_instance'}
# default-debian-11-3003-1-py3: {extends: '.test_instance'}
# default-debian-10-3003-1-py3: {extends: '.test_instance'}
# default-debian-9-3003-1-py3: {extends: '.test_instance'}

View file

@ -95,26 +95,62 @@ jobs:
# - env: INSTANCE=default-oraclelinux-7-tiamat-py3
# - env: INSTANCE=default-almalinux-8-tiamat-py3
# - env: INSTANCE=default-rockylinux-8-tiamat-py3
- env: INSTANCE=default-debian-11-master-py3
- env: INSTANCE=default-debian-10-master-py3
- env: INSTANCE=default-debian-9-master-py3
- env: INSTANCE=default-ubuntu-2004-master-py3
- env: INSTANCE=default-ubuntu-1804-master-py3
- env: INSTANCE=default-centos-8-master-py3
- env: INSTANCE=default-centos-7-master-py3
- env: INSTANCE=default-fedora-34-master-py3
- env: INSTANCE=default-fedora-33-master-py3
- env: INSTANCE=default-opensuse-leap-153-master-py3
- env: INSTANCE=default-opensuse-leap-152-master-py3
# - env: INSTANCE=default-debian-11-master-py3
# - env: INSTANCE=repo-debian-11-master-py3
- env: INSTANCE=debian-11-master-py3
# - env: INSTANCE=default-debian-10-master-py3
# - env: INSTANCE=repo-debian-10-master-py3
- env: INSTANCE=debian-10-master-py3
# - env: INSTANCE=default-debian-9-master-py3
# - env: INSTANCE=repo-debian-9-master-py3
- env: INSTANCE=debian-9-master-py3
# - env: INSTANCE=default-ubuntu-2004-master-py3
# - env: INSTANCE=repo-ubuntu-2004-master-py3
- env: INSTANCE=ubuntu-2004-master-py3
# - env: INSTANCE=default-ubuntu-1804-master-py3
# - env: INSTANCE=repo-ubuntu-1804-master-py3
- env: INSTANCE=ubuntu-1804-master-py3
# - env: INSTANCE=default-centos-8-master-py3
# - env: INSTANCE=repo-centos-8-master-py3
- env: INSTANCE=centos-8-master-py3
# - env: INSTANCE=default-centos-7-master-py3
# - env: INSTANCE=repo-centos-7-master-py3
- env: INSTANCE=centos-7-master-py3
# - env: INSTANCE=default-fedora-34-master-py3
# - env: INSTANCE=repo-fedora-34-master-py3
- env: INSTANCE=fedora-34-master-py3
# - env: INSTANCE=default-fedora-33-master-py3
# - env: INSTANCE=repo-fedora-33-master-py3
- env: INSTANCE=fedora-33-master-py3
# - env: INSTANCE=default-opensuse-leap-153-master-py3
# - env: INSTANCE=repo-opensuse-leap-153-master-py3
- env: INSTANCE=opensuse-leap-153-master-py3
# - env: INSTANCE=default-opensuse-leap-152-master-py3
# - env: INSTANCE=repo-opensuse-leap-152-master-py3
- env: INSTANCE=opensuse-leap-152-master-py3
- env: INSTANCE=default-opensuse-tmbl-latest-master-py3
- env: INSTANCE=default-amazonlinux-2-master-py3
- env: INSTANCE=default-oraclelinux-8-master-py3
- env: INSTANCE=default-oraclelinux-7-master-py3
# - env: INSTANCE=opensuse-tmbl-latest-master-py3
# - env: INSTANCE=default-amazonlinux-2-master-py3
# - env: INSTANCE=repo-amazonlinux-2-master-py3
- env: INSTANCE=amazonlinux-2-master-py3
# - env: INSTANCE=default-oraclelinux-8-master-py3
# - env: INSTANCE=repo-oraclelinux-8-master-py3
- env: INSTANCE=oraclelinux-8-master-py3
# - env: INSTANCE=default-oraclelinux-7-master-py3
# - env: INSTANCE=repo-oraclelinux-7-master-py3
- env: INSTANCE=oraclelinux-7-master-py3
- env: INSTANCE=default-arch-base-latest-master-py3
# - env: INSTANCE=arch-base-latest-master-py3
# - env: INSTANCE=default-gentoo-stage3-latest-master-py3
# - env: INSTANCE=gentoo-stage3-latest-master-py3
# - env: INSTANCE=default-gentoo-stage3-systemd-master-py3
- env: INSTANCE=default-almalinux-8-master-py3
- env: INSTANCE=default-rockylinux-8-master-py3
# - env: INSTANCE=gentoo-stage3-systemd-master-py3
# - env: INSTANCE=default-almalinux-8-master-py3
# - env: INSTANCE=repo-almalinux-8-master-py3
- env: INSTANCE=almalinux-8-master-py3
# - env: INSTANCE=default-rockylinux-8-master-py3
# - env: INSTANCE=repo-rockylinux-8-master-py3
- env: INSTANCE=rockylinux-8-master-py3
# - env: INSTANCE=default-debian-11-3003-1-py3
# - env: INSTANCE=default-debian-10-3003-1-py3
# - env: INSTANCE=default-debian-9-3003-1-py3

View file

@ -445,3 +445,103 @@ suites:
verifier:
inspec_tests:
- path: test/integration/default
- name: repo
includes:
- debian-11-tiamat-py3
- debian-10-tiamat-py3
- debian-9-tiamat-py3
- ubuntu-2004-tiamat-py3
- ubuntu-1804-tiamat-py3
- centos-8-tiamat-py3
- centos-7-tiamat-py3
- amazonlinux-2-tiamat-py3
- oraclelinux-8-tiamat-py3
- oraclelinux-7-tiamat-py3
- almalinux-8-tiamat-py3
- rockylinux-8-tiamat-py3
- debian-11-master-py3
- debian-10-master-py3
- debian-9-master-py3
- ubuntu-2004-master-py3
- ubuntu-1804-master-py3
- centos-8-master-py3
- centos-7-master-py3
- fedora-34-master-py3
- fedora-33-master-py3
- opensuse-leap-153-master-py3
- opensuse-leap-152-master-py3
- amazonlinux-2-master-py3
- oraclelinux-8-master-py3
- oraclelinux-7-master-py3
- almalinux-8-master-py3
- rockylinux-8-master-py3
- debian-11-3003-1-py3
- debian-10-3003-1-py3
- debian-9-3003-1-py3
- ubuntu-2004-3003-1-py3
- ubuntu-1804-3003-1-py3
- centos-8-3003-1-py3
- centos-7-3003-1-py3
- fedora-34-3003-1-py3
- fedora-33-3003-1-py3
- opensuse-leap-153-3003-1-py3
- opensuse-leap-152-3003-1-py3
- amazonlinux-2-3003-1-py3
- oraclelinux-8-3003-1-py3
- oraclelinux-7-3003-1-py3
- debian-11-3002-6-py3
- debian-10-3002-6-py3
- debian-9-3002-6-py3
- ubuntu-2004-3002-6-py3
- ubuntu-1804-3002-6-py3
- centos-8-3002-6-py3
- centos-7-3002-6-py3
- fedora-34-3002-6-py3
- fedora-33-3002-6-py3
- amazonlinux-2-3002-6-py3
- oraclelinux-8-3002-6-py3
- oraclelinux-7-3002-6-py3
- opensuse-leap-153-3002-2-py3
- opensuse-leap-152-3002-2-py3
- debian-10-3001-7-py3
- debian-9-3001-7-py3
- ubuntu-2004-3001-7-py3
- ubuntu-1804-3001-7-py3
- centos-8-3001-7-py3
- centos-7-3001-7-py3
- fedora-34-3001-7-py3
- fedora-33-3001-7-py3
- opensuse-leap-153-3001-7-py3
- opensuse-leap-152-3001-7-py3
- amazonlinux-2-3001-7-py3
- oraclelinux-8-3001-7-py3
- oraclelinux-7-3001-7-py3
- debian-10-3000-9-py3
- debian-9-3000-9-py3
- ubuntu-1804-3000-9-py3
- centos-8-3000-9-py3
- centos-7-3000-9-py3
- opensuse-leap-153-3000-9-py3
- opensuse-leap-152-3000-9-py3
- amazonlinux-2-3000-9-py3
- oraclelinux-8-3000-9-py3
- oraclelinux-7-3000-9-py3
- ubuntu-1804-3000-9-py2
provisioner:
state_top:
base:
'*':
- postgres._mapdata
- postgres
pillars:
top.sls:
base:
'*':
- postgres
- repo
pillars_from_files:
postgres.sls: test/salt/pillar/postgres.sls
repo.sls: test/salt/pillar/repo.sls
verifier:
inspec_tests:
- path: test/integration/repo

View file

@ -78,10 +78,17 @@
{{ debian_codename('focal', '12') }}
## Fedora
# http://apt.postgresql.org/pub/repos/yum/reporpms/
# https://download.postgresql.org/pub/repos/yum/13/fedora/
# https://apps.fedoraproject.org/packages/postgresql
# `oscodename` grain has long distro name
{{ fedora_codename('Fedora-31', '11', 'Fedora 31 (Thirty One)') }}
{{ fedora_codename('Fedora-30', '11', 'Fedora 30 (Thirty)') }}
{{ fedora_codename('Fedora-34', '13') }}
{{ fedora_codename('Fedora-33', '13') }}
## Amazon
Amazon Linux 2:
pkgs_deps:
- libicu
- systemd-sysv
pkg_repo:
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-7-$basearch'
# vim: ft=sls

View file

@ -63,11 +63,12 @@ RedHat:
gpgkey: 'https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ release }}'
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-$releasever-$basearch'
{%- if grains.get('osmajorrelease', 0) >= 7 %}
pkgs_deps:
- libicu
{%- if grains.get('osmajorrelease', 0) == 7 %}
- systemd-sysv
{%- endif %}
pkg_python: python3-psycopg2
{%- endif %}
{% if repo.use_upstream_repo == true %}
{% set data_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}

View file

@ -9,7 +9,3 @@ Fedora:
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/fedora/fedora-$releasever-$basearch'
remove:
releases: ['9.4', '9.5', '9.6', '10']
Amazon:
pkg_repo:
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-7-$basearch'

View file

@ -0,0 +1,26 @@
# frozen_string_literal: true
service_name = 'postgresql'
pg_port =
case platform[:family]
when 'debian', 'suse'
5433
else
5432
end
control 'Postgres service' do
impact 0.5
title 'should be installed, enabled and running'
describe service(service_name) do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
describe port(pg_port) do
it { should be_listening }
end
end

View file

@ -1,24 +0,0 @@
# frozen_string_literal: true
# Overide by Platform
service_name = 'postgresql'
pg_port = 5432
if (platform[:name] == 'centos') && platform[:release].start_with?('6')
service_name = 'postgresql-9.6'
elsif (platform[:family] == 'debian') || (platform[:family] == 'suse')
pg_port = 5433
end
control 'Postgres service' do
impact 0.5
title 'should be running and enabled'
describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
describe port(pg_port) do
it { should be_listening }
end
end

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
# https://docs.chef.io/inspec/profiles/#including-all-controls-from-a-profile
# Could use `include_controls` in this scenario
# include_controls 'share'
# https://docs.chef.io/inspec/profiles/#selectively-including-controls-from-a-profile
# However, using `require_controls` for more clarity
require_controls 'share' do
control 'Postgres command'
control 'Postgres configuration'
# control 'Postgres service'
end

View file

@ -0,0 +1,50 @@
# InSpec Profile: `repo`
This shows the implementation of the `repo` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
## Verify a profile
InSpec ships with built-in features to verify a profile structure.
```bash
$ inspec check repo
Summary
-------
Location: repo
Profile: profile
Controls: 4
Timestamp: 2019-06-24T23:09:01+00:00
Valid: true
Errors
------
Warnings
--------
```
## Execute a profile
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
```bash
$ inspec exec repo
..
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
8 examples, 0 failures
```
## Execute a specific control from a profile
To run one control from the profile use `inspec exec /path/to/profile --controls name`.
```bash
$ inspec exec repo --controls package
.
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
1 examples, 0 failures
```
See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).

View file

@ -0,0 +1,37 @@
# frozen_string_literal: true
service_name =
case platform[:family]
when 'redhat', 'fedora', 'suse'
case system.platform[:release]
when 'tumbleweed'
'postgresql'
else
'postgresql-13'
end
else
'postgresql'
end
pg_port =
case platform[:family]
when 'debian', 'suse'
5433
else
5432
end
control 'Postgres service' do
impact 0.5
title 'should be installed, enabled and running'
describe service(service_name) do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
describe port(pg_port) do
it { should be_listening }
end
end

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
# https://docs.chef.io/inspec/profiles/#including-all-controls-from-a-profile
# Could use `include_controls` in this scenario
# include_controls 'share'
# https://docs.chef.io/inspec/profiles/#selectively-including-controls-from-a-profile
# However, using `require_controls` for more clarity
require_controls 'share' do
control 'Postgres command'
control 'Postgres configuration'
# control 'Postgres service'
end

View file

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: repo
title: postgres formula
maintainer: SaltStack Formulas
license: Apache-2.0
# yamllint disable-line rule:line-length
summary: Verify that the postgres formula is setup and configured correctly (when installing from the upstream repo)
depends:
- name: share
path: test/integration/share
supports:
- platform-name: debian
- platform-name: ubuntu
- platform-name: centos
- platform-name: fedora
- platform-name: opensuse
- platform-name: suse
- platform-name: freebsd
- platform-name: openbsd
- platform-name: amazon
- platform-name: oracle
- platform-name: arch
- platform-name: gentoo
- platform-name: almalinux
- platform-name: rocky
- platform: windows

View file

@ -8,21 +8,7 @@ postgres.port: '5433'
{%- endif %}
postgres:
# UPSTREAM REPO
# Set True to configure upstream postgresql.org repository for YUM/APT/ZYPP
{%- if grains.os_family != 'Debian' and salt['grains.get']('osfinger') != 'CentOS-6' %}
use_upstream_repo: False
{%- else %}
use_upstream_repo: True
# Version to install from upstream repository (if upstream_repo: True)
version: '13'
# # Set True to add a file in /etc/profile.d adding the bin dir in $PATH
# # as packages from upstream put them somewhere like /usr/pgsql-10/bin
# add_profile: False
# # If automatic package installation fails, use `fromrepo` to specify the
# # upstream repo to install packages from [#133, #185] (if upstream_repo: True)
# fromrepo: 'jessie-pgdg'
{%- endif %}
use_upstream_repo: false
# ### MACOS
# # Set to 'postgresapp' OR 'homebrew' for MacOS
@ -177,7 +163,8 @@ postgres:
public:
owner: localUser
# enable per-db extension
{%- if grains.os_family == 'Debian' and salt['grains.get']('osfinger') != 'Debian-8' %}
{#- TODO: Find a way to only disable this for the `default` suite, since it works with the `repo` suite #}
{%- if grains.os_family == 'Debian' and salt['grains.get']('osfinger') != 'Debian-9' %}
extensions:
uuid-ossp:
schema: 'public'
@ -190,7 +177,8 @@ postgres:
owner: localUser
# optional extensions to install in schema
{%- if grains.os_family == 'Debian' and salt['grains.get']('osfinger') != 'Debian-8' %}
{#- TODO: Find a way to only disable this for the `default` suite, since it works with the `repo` suite #}
{%- if grains.os_family == 'Debian' and salt['grains.get']('osfinger') != 'Debian-9' %}
extensions:
uuid-ossp:
schema: uuid-ossp

View file

@ -0,0 +1,4 @@
---
postgres:
use_upstream_repo: true
version: '13'