From 8a11bd679a8a6175c796294dd0a5c759725de25d Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 6 Jul 2021 13:25:06 +0100 Subject: [PATCH 1/6] feat(codenamemap): update to current supported Fedora versions --- postgres/codenamemap.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/postgres/codenamemap.yaml b/postgres/codenamemap.yaml index 2f7ca0a..e9d3523 100644 --- a/postgres/codenamemap.yaml +++ b/postgres/codenamemap.yaml @@ -78,10 +78,9 @@ {{ 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') }} # vim: ft=sls From 060c8df630ea4077a3d5a2b301fed56ed6ce1a45 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 6 Jul 2021 14:41:41 +0100 Subject: [PATCH 2/6] fix(redhat): fix `pkg_deps` to be able to install PostgreSQL 13 --- postgres/codenamemap.yaml | 8 ++++++++ postgres/osfamilymap.yaml | 5 +++-- postgres/osmap.yaml | 4 ---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/postgres/codenamemap.yaml b/postgres/codenamemap.yaml index e9d3523..fbfc5fd 100644 --- a/postgres/codenamemap.yaml +++ b/postgres/codenamemap.yaml @@ -83,4 +83,12 @@ {{ 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 diff --git a/postgres/osfamilymap.yaml b/postgres/osfamilymap.yaml index d519334..e572e94 100644 --- a/postgres/osfamilymap.yaml +++ b/postgres/osfamilymap.yaml @@ -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' %} diff --git a/postgres/osmap.yaml b/postgres/osmap.yaml index fd885e5..4fb1309 100644 --- a/postgres/osmap.yaml +++ b/postgres/osmap.yaml @@ -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' From a6c81972a2c722d1dc3637acb412a8e1e513c998 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 20 Jul 2021 18:00:27 +0100 Subject: [PATCH 3/6] ci: use `default` & `repo` InSpec suites * Automated using https://github.com/myii/ssf-formula/pull/348 --- .github/workflows/kitchen.vagrant.yml | 3 + .gitlab-ci.yml | 77 +++++++++++++++----- .travis.yml | 68 +++++++++++++----- kitchen.yml | 100 ++++++++++++++++++++++++++ test/integration/repo/README.md | 50 +++++++++++++ test/integration/repo/inspec.yml | 28 ++++++++ 6 files changed, 293 insertions(+), 33 deletions(-) create mode 100644 test/integration/repo/README.md create mode 100644 test/integration/repo/inspec.yml diff --git a/.github/workflows/kitchen.vagrant.yml b/.github/workflows/kitchen.vagrant.yml index 3840668..9d34048 100644 --- a/.github/workflows/kitchen.vagrant.yml +++ b/.github/workflows/kitchen.vagrant.yml @@ -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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d75c0e..8f2c462 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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'} diff --git a/.travis.yml b/.travis.yml index 5706862..df037e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/kitchen.yml b/kitchen.yml index bc0cb65..9121fe9 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -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 diff --git a/test/integration/repo/README.md b/test/integration/repo/README.md new file mode 100644 index 0000000..7a12525 --- /dev/null +++ b/test/integration/repo/README.md @@ -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). diff --git a/test/integration/repo/inspec.yml b/test/integration/repo/inspec.yml new file mode 100644 index 0000000..635d0f0 --- /dev/null +++ b/test/integration/repo/inspec.yml @@ -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 From 27473b9865e8d716aa991cd33e9e186815933483 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 20 Jul 2021 18:01:34 +0100 Subject: [PATCH 4/6] test(pillar): use separate pillars to test `default` & `repo` suites --- test/salt/pillar/postgres.sls | 22 +++++----------------- test/salt/pillar/repo.sls | 4 ++++ 2 files changed, 9 insertions(+), 17 deletions(-) create mode 100644 test/salt/pillar/repo.sls diff --git a/test/salt/pillar/postgres.sls b/test/salt/pillar/postgres.sls index 3bfa796..da4e734 100644 --- a/test/salt/pillar/postgres.sls +++ b/test/salt/pillar/postgres.sls @@ -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 diff --git a/test/salt/pillar/repo.sls b/test/salt/pillar/repo.sls new file mode 100644 index 0000000..a4445e7 --- /dev/null +++ b/test/salt/pillar/repo.sls @@ -0,0 +1,4 @@ +--- +postgres: + use_upstream_repo: true + version: '13' From 221409636290444aa06ef9e59fd324b94412a635 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 20 Jul 2021 18:01:37 +0100 Subject: [PATCH 5/6] test(inspec): move common controls to the `share` profile --- .../default/controls/services_spec.rb | 18 +++++---- test/integration/default/controls/share.rb | 13 +++++++ .../repo/controls/services_spec.rb | 37 +++++++++++++++++++ test/integration/repo/controls/share.rb | 13 +++++++ .../controls/command_spec.rb | 0 .../controls/config_spec.rb | 0 6 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 test/integration/default/controls/share.rb create mode 100644 test/integration/repo/controls/services_spec.rb create mode 100644 test/integration/repo/controls/share.rb rename test/integration/{default => share}/controls/command_spec.rb (100%) rename test/integration/{default => share}/controls/config_spec.rb (100%) diff --git a/test/integration/default/controls/services_spec.rb b/test/integration/default/controls/services_spec.rb index 5dfd78e..2c3d6e1 100644 --- a/test/integration/default/controls/services_spec.rb +++ b/test/integration/default/controls/services_spec.rb @@ -1,19 +1,21 @@ # 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 + +pg_port = + case platform[:family] + when 'debian', 'suse' + 5433 + else + 5432 + end control 'Postgres service' do impact 0.5 - title 'should be running and enabled' + 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 diff --git a/test/integration/default/controls/share.rb b/test/integration/default/controls/share.rb new file mode 100644 index 0000000..362f11c --- /dev/null +++ b/test/integration/default/controls/share.rb @@ -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 diff --git a/test/integration/repo/controls/services_spec.rb b/test/integration/repo/controls/services_spec.rb new file mode 100644 index 0000000..e1927db --- /dev/null +++ b/test/integration/repo/controls/services_spec.rb @@ -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 diff --git a/test/integration/repo/controls/share.rb b/test/integration/repo/controls/share.rb new file mode 100644 index 0000000..362f11c --- /dev/null +++ b/test/integration/repo/controls/share.rb @@ -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 diff --git a/test/integration/default/controls/command_spec.rb b/test/integration/share/controls/command_spec.rb similarity index 100% rename from test/integration/default/controls/command_spec.rb rename to test/integration/share/controls/command_spec.rb diff --git a/test/integration/default/controls/config_spec.rb b/test/integration/share/controls/config_spec.rb similarity index 100% rename from test/integration/default/controls/config_spec.rb rename to test/integration/share/controls/config_spec.rb From a1837c24f1b5210964e74f576805470f6db1a0cf Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 20 Jul 2021 19:22:36 +0100 Subject: [PATCH 6/6] test(inspec): rename all files to avoid unnecessary `_spec` suffix --- .../default/controls/{services_spec.rb => services.rb} | 0 test/integration/repo/controls/{services_spec.rb => services.rb} | 0 test/integration/share/controls/{command_spec.rb => command.rb} | 0 test/integration/share/controls/{config_spec.rb => config.rb} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename test/integration/default/controls/{services_spec.rb => services.rb} (100%) rename test/integration/repo/controls/{services_spec.rb => services.rb} (100%) rename test/integration/share/controls/{command_spec.rb => command.rb} (100%) rename test/integration/share/controls/{config_spec.rb => config.rb} (100%) diff --git a/test/integration/default/controls/services_spec.rb b/test/integration/default/controls/services.rb similarity index 100% rename from test/integration/default/controls/services_spec.rb rename to test/integration/default/controls/services.rb diff --git a/test/integration/repo/controls/services_spec.rb b/test/integration/repo/controls/services.rb similarity index 100% rename from test/integration/repo/controls/services_spec.rb rename to test/integration/repo/controls/services.rb diff --git a/test/integration/share/controls/command_spec.rb b/test/integration/share/controls/command.rb similarity index 100% rename from test/integration/share/controls/command_spec.rb rename to test/integration/share/controls/command.rb diff --git a/test/integration/share/controls/config_spec.rb b/test/integration/share/controls/config.rb similarity index 100% rename from test/integration/share/controls/config_spec.rb rename to test/integration/share/controls/config.rb