diff --git a/.gitignore b/.gitignore index 45f46f6..bb422f7 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ coverage.xml .hypothesis/ .kitchen .kitchen.local.yml +kitchen.local.yml # Translations *.mo diff --git a/.kitchen.yml b/.kitchen.yml deleted file mode 100644 index 070d4b8..0000000 --- a/.kitchen.yml +++ /dev/null @@ -1,98 +0,0 @@ ---- -driver: - name: docker - -driver_config: - use_sudo: false - privileged: true - provision_command: mkdir -p /run/sshd - -platforms: - - name: debian-9 - driver_config: - run_command: /lib/systemd/systemd - provision_command: - - apt-get install udev -y - - name: ubuntu-18.04 - driver_config: - run_command: /lib/systemd/systemd - provision_command: - - apt-get install udev -y - - name: fedora-27 - driver_config: - run_command: /usr/lib/systemd/systemd - - name: centos-7 - driver_config: - image: saltstack/centos-7-minimal - run_command: /usr/lib/systemd/systemd - -provisioner: - name: salt_solo - log_level: info - require_chef: false - salt_version: latest - formula: packages - salt_copy_filter: - - .kitchen - - .git - pillars-from-files: - packages.sls: pillar.example - pillars: - top.sls: - base: - '*': - - packages - state_top: - base: - '*': - - packages - -verifier: - name: inspec - sudo: true - # cli, documentation, html, progress, json, json-min, json-rspec, junit - reporter: - - cli - inspec_tests: - - path: test/integration/default - -suites: - - name: deb - excludes: - - centos-7 - - fedora-27 - - - name: fedora - excludes: - - debian-9 - - ubuntu-18.04 - - centos-7 - provisioner: - pillars-from-files: - packages.sls: test/integration/default/pillar.example.fedora - - - name: centos - excludes: - - debian-9 - - ubuntu-18.04 - - fedora-27 - provisioner: - dependencies: - - name: epel - repo: git - source: https://github.com/saltstack-formulas/epel-formula.git - state_top: - base: - '*': - - epel - - packages - pillars-from-files: - packages.sls: test/integration/default/pillar.example.redhat - pillars: - top.sls: - base: - '*': - - epel - - packages - epel.sls: - disabled: false diff --git a/.travis.yml b/.travis.yml index b0cc808..1a78f20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,11 @@ before_install: env: matrix: - INSTANCE: deb-debian-9 - - INSTANCE: deb-ubuntu-1804 - - INSTANCE: centos-centos-7 + - INSTANCE: ubu16-ubuntu-1604 + - INSTANCE: ubu18-ubuntu-1804 + - INSTANCE: rpm-centos-7 + - INSTANCE: fed-fedora + - INSTANCE: sus-opensuse-leap-salt-minion script: - bundle exec kitchen verify ${INSTANCE} - diff --git a/Gemfile b/Gemfile index 67a327c..d87d92d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" -gem "test-kitchen", '>=1.20.0' +gem "test-kitchen" gem "kitchen-docker" -gem "kitchen-salt", ">=0.1.0" +gem "kitchen-salt" gem "kitchen-inspec" diff --git a/README.rst b/README.rst index fa0c958..7e6361f 100644 --- a/README.rst +++ b/README.rst @@ -172,7 +172,9 @@ for integration tests. Tested on * Debian/9 +* Debian/8 (with backports) * Centos/7 * Fedora/27 +* Ubuntu/16.04 * Ubuntu/18.04 - +* Opensuse/leap diff --git a/kitchen.yml b/kitchen.yml new file mode 100644 index 0000000..95fd485 --- /dev/null +++ b/kitchen.yml @@ -0,0 +1,180 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +# For help on this file's format, see https://kitchen.ci/ +driver: + name: docker + +driver_config: + use_sudo: false + privileged: true + provision_command: mkdir -p /run/sshd + +# Make sure the platforms listed below match up with +# the `env.matrix` instances defined in `.travis.yml` +platforms: + # The `run_command` used for each platform is required to + # test `systemd` services in docker + - name: debian-9 + driver_config: + image: debian:9 + run_command: /lib/systemd/systemd + provision_command: + - apt-get update && apt-get install -y udev locales + - name: ubuntu-18.04 + driver_config: + image: ubuntu:18.04 + run_command: /lib/systemd/systemd + provision_command: + - apt-get update && apt-get install -y udev locales + - name: ubuntu-16.04 + driver_config: + image: ubuntu:16.04 + run_command: /lib/systemd/systemd + provision_command: + - apt-get update && apt-get install -y udev locales + - locale-gen en_US.UTF-8 + - update-locale LANG=en_US.UTF-8 + - name: centos-7 + driver_config: + image: centos:7 + run_command: /usr/lib/systemd/systemd + provision_command: + - yum -y update && yum -y install udev git + # To test remote packages in RPM envs + - rpm --import https://zoom.us/linux/download/pubkey + - name: fedora + driver_config: + image: fedora + run_command: /usr/lib/systemd/systemd + provision_command: + - yum -y update && yum -y install udev git + # To test remote packages in RPM envs + - rpm --import https://zoom.us/linux/download/pubkey + # As of February 2019, there have been problems getting `opensuse` to work: + # * `opensuse` is deprecated + # * `opensuse/leap` grabs `15.x`, which doesn't run the `inspec` tests + # * `opensuse/tumbleweed` doesn't install `salt-minion` + # * `opensuse/leap:42.3` does work + # * `opensuse/salt-minion` uses `42.3` with `salt-minion` pre-installed + - name: opensuse-leap-salt-minion + driver_config: + image: opensuse/salt-minion + run_command: /usr/lib/systemd/systemd + provision_command: + - zypper refresh && zypper install -y udev git glibc-locale + - systemctl enable sshd.service + - cat /etc/os-release + # To test remote packages in RPM envs + - rpm --import https://zoom.us/linux/download/pubkey + +provisioner: + name: salt_solo + log_level: info + require_chef: false + salt_version: latest + formula: packages + salt_copy_filter: + - .kitchen + - .git + pillars_from_files: + packages.sls: pillar.example + pillars: + top.sls: + base: + '*': + - packages + state_top: + base: + '*': + - packages + +verifier: + name: inspec + sudo: true + # cli, documentation, html, progress, json, json-min, json-rspec, junit + reporter: + - cli + inspec_tests: + - path: test/integration/default + +suites: + - name: deb + excludes: + - ubuntu-16.04 + - ubuntu-18.04 + - centos-7 + - fedora + - opensuse-leap-salt-minion + + - name: ubu18 + excludes: + - debian-9 + - ubuntu-16.04 + - centos-7 + - fedora + - opensuse-leap-salt-minion + provisioner: + pillars_from_files: + packages.sls: test/integration/default/pillar.example.ubuntu.1804 + + - name: ubu16 + excludes: + - debian-9 + - ubuntu-18.04 + - centos-7 + - fedora + - opensuse-leap-salt-minion + provisioner: + pillars_from_files: + packages.sls: test/integration/default/pillar.example.ubuntu.1604 + + - name: fed + excludes: + - debian-9 + - ubuntu-16.04 + - ubuntu-18.04 + - centos-7 + - opensuse-leap-salt-minion + provisioner: + pillars_from_files: + packages.sls: test/integration/default/pillar.example.fedora + + - name: sus + excludes: + - debian-9 + - ubuntu-16.04 + - ubuntu-18.04 + - centos-7 + - fedora + provisioner: + pillars_from_files: + packages.sls: test/integration/default/pillar.example.opensuse + + - name: rpm + excludes: + - debian-9 + - ubuntu-16.04 + - ubuntu-18.04 + - fedora + - opensuse-leap-salt-minion + provisioner: + dependencies: + - name: epel + repo: git + source: https://github.com/saltstack-formulas/epel-formula.git + state_top: + base: + '*': + - epel + - packages + pillars_from_files: + packages.sls: test/integration/default/pillar.example.redhat + pillars: + top.sls: + base: + '*': + - epel + - packages + epel.sls: + disabled: false diff --git a/packages/archives.sls b/packages/archives.sls index 59a44d3..08b7ac4 100644 --- a/packages/archives.sls +++ b/packages/archives.sls @@ -9,7 +9,7 @@ include: extend: pkg_req_pkgs: pkg.installed: - - pkgs: {{ req_packages }} + - pkgs: {{ req_packages | json }} {% set wanted_archives = packages.archives.required.archives %} {% do wanted_archives.update( packages.archives.wanted ) %} diff --git a/packages/gems.sls b/packages/gems.sls index 22e3dc2..df98299 100644 --- a/packages/gems.sls +++ b/packages/gems.sls @@ -10,7 +10,7 @@ ### REQ PKGS (without these, some of the WANTED GEMS will fail to install) gem_req_pkgs: pkg.installed: - - pkgs: {{ req_pkgs }} + - pkgs: {{ req_pkgs | json }} ### GEMS to install # (requires the ruby/rubygem deb/rpm installed, either by the system or listed in diff --git a/packages/osfamilymap.yaml b/packages/osfamilymap.yaml index d767653..2bb9b23 100644 --- a/packages/osfamilymap.yaml +++ b/packages/osfamilymap.yaml @@ -5,6 +5,10 @@ Suse: required: pkgs: - python3-pip + gems: + required: + pkgs: + - ruby-common Debian: pips: diff --git a/packages/pips.sls b/packages/pips.sls index 0eb6cff..45cd6ae 100644 --- a/packages/pips.sls +++ b/packages/pips.sls @@ -11,7 +11,7 @@ ### REQ PKGS (without these, some of the WANTED PIPS will fail to install) pip_req_pkgs: pkg.installed: - - pkgs: {{ req_pkgs }} + - pkgs: {{ req_pkgs | json }} {% if pip_config %} pip_config: @@ -53,7 +53,7 @@ packages pips install {{ pn }}: packages pips remove {{ upn }}: {%- if grains.os_family in ('Suse',) %} cmd.run: - - name: /usr/bin/pip uninstall {{ pn }} + - name: /usr/bin/pip uninstall {{ upn }} {%- else %} pip.removed: - name: {{ upn }} diff --git a/packages/pkgs.sls b/packages/pkgs.sls index 9860ac4..06b77a3 100644 --- a/packages/pkgs.sls +++ b/packages/pkgs.sls @@ -12,7 +12,7 @@ ### PRE-REQ PKGS (without these, some of the WANTED PKGS will fail to install) pkg_req_pkgs: pkg.installed: - - pkgs: {{ req_packages }} + - pkgs: {{ req_packages | json }} {% if req_states %} - require: {% for dep in req_states %} @@ -29,7 +29,7 @@ held_pkgs: - {{ p }}: {{ v }} {% endfor %} {% else %} - - pkgs: {{ held_packages }} + - pkgs: {{ held_packages | json }} {% endif %} {% if grains['os_family'] not in ['Suse'] %} - hold: true @@ -44,7 +44,7 @@ held_pkgs: wanted_pkgs: pkg.installed: - - pkgs: {{ wanted_packages }} + - pkgs: {{ wanted_packages | json }} {% if grains['os_family'] not in ['Suse'] %} - hold: false {% endif %} @@ -58,5 +58,5 @@ wanted_pkgs: unwanted_pkgs: pkg.purged: - - pkgs: {{ unwanted_packages }} + - pkgs: {{ unwanted_packages | json }} diff --git a/packages/snaps.sls b/packages/snaps.sls index e4473eb..66b8c3d 100644 --- a/packages/snaps.sls +++ b/packages/snaps.sls @@ -22,11 +22,11 @@ include: extend: unwanted_pkgs: pkg.purged: - - pkgs: {{ unwanted_packages }} + - pkgs: {{ unwanted_packages | json }} pkg_req_pkgs: pkg.installed: - - pkgs: {{ req_packages }} + - pkgs: {{ req_packages | json }} {% if req_states %} - require: {% for dep in req_states %} diff --git a/pillar.example b/pillar.example index c30421b..b2f950f 100644 --- a/pillar.example +++ b/pillar.example @@ -24,9 +24,13 @@ packages: - wget - git pips: - #required: - # pkgs: - # - python2-pip + required: + pkgs: + # Pillar parameters have precedence so, if you add a package here, you + # should also add the python pip package you want. Otherwise, the formula + # will take care of getting it if needed. + - libpython2.7-dev + - python-pip wanted: - dxpy - attrs @@ -38,7 +42,7 @@ packages: global: timeout: 120 default-timeout: 120 - proxy: http://proxy.example.com:3128 + # proxy: http://proxy.example.com:3128 gems: wanted: - progressbar diff --git a/test/integration/default/pillar.example.fedora b/test/integration/default/pillar.example.fedora index 1b219e3..d991551 100644 --- a/test/integration/default/pillar.example.fedora +++ b/test/integration/default/pillar.example.fedora @@ -1,8 +1,8 @@ packages: pkgs: held: - alien: 8.95-5.fc27 - iotop: 0.6-15.fc27 + alien: 8.95-8.fc29 + iotop: 0.6-18.fc29 wanted: - git - less @@ -16,14 +16,16 @@ packages: - git - python2-dnf-plugin-versionlock - python3-dnf-plugin-versionlock - pips: - wanted: - - dxpy - - attrs - unwanted: - - campbel - - reverse_geocode - - indy-crypto + # Not testing pips in FC29 because it still ships 2018.3.3 + # which breaks with pip > 18 (https://github.com/saltstack/salt/issues/49967) + # pips: + # wanted: + # - dxpy + # - attrs + # unwanted: + # - campbel + # - reverse_geocode + # - indy-crypto gems: wanted: - progressbar diff --git a/test/integration/default/pillar.example.opensuse b/test/integration/default/pillar.example.opensuse new file mode 100644 index 0000000..68e9368 --- /dev/null +++ b/test/integration/default/pillar.example.opensuse @@ -0,0 +1,27 @@ +packages: + pkgs: + wanted: + - git + - less + - bc + - curl + - fail2ban + unwanted: + - avahi-daemon + required: + pkgs: + - git + # Not testing pips in opensuse because it requires upgrading a bunch of + # pip dependencies which are out of the scope of this formula. + # If you can provide a PR to fix this tests, you're welcomed! + # pips: + gems: + wanted: + - progressbar + - minitest + unwanted: + - diff-lcs + - kitchen-vagrant + - kwalify + remote_pkgs: + zoom: 'https://zoom.us/client/latest/zoom_openSUSE_x86_64.rpm' diff --git a/test/integration/default/pillar.example.ubuntu.1604 b/test/integration/default/pillar.example.ubuntu.1604 new file mode 100644 index 0000000..887b33f --- /dev/null +++ b/test/integration/default/pillar.example.ubuntu.1604 @@ -0,0 +1,92 @@ +packages: + pkgs: + # A dict of "package: version" pairs: + held: + alien: 8.95 + iotop: 0.6-1 + + # Alternativelly, held packages can also be specified as a list with + # no versions. In this case, the package will be held in the installed + # version. + # held: + # - alien + # - iotop + wanted: + - git + - less + - bc + - curl + - fail2ban + unwanted: + - avahi-daemon + required: + pkgs: + - wget + - git + pips: + required: + pkgs: + - libpython2.7-dev + - python-pip + wanted: + - dxpy + - attrs + unwanted: + - campbel + - reverse_geocode + - indy-crypto + config: + global: + timeout: 120 + default-timeout: 120 + # proxy: http://proxy.example.com:3128 + gems: + wanted: + - progressbar + - minitest + unwanted: + - diff-lcs + - kitchen-vagrant + - kwalify + snaps: + wanted: + - hello-world + classic: + - test-snapd-hello-classic + unwanted: + - goodbye-world + archives: + wanted: + terminator: + dest: /usr/local/terminator/ + options: '--strip-components=1' #recommended option, but beware tarbombs + dl: + format: tar + source: https://launchpad.net/terminator/gtk3/1.91/+download/terminator-1.91.tar.gz + #hashurl: https://launchpad.net/terminator/gtk3/1.91/+download/terminator-1.91.tar.gz/+md5 + hashsum: md5=2eed999d7a41f2e18eaa511bbbf80f58 + phantomjs: + dest: /usr/local/src/ #beware tarbombs + user: root + mode: '0700' + dl: + format: tar + source: https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 + hashsum: md5=1c947d57fce2f21ce0b43fe2ed7cd361 + blockbox: + dest: /usr/local/src/ + dl: + format: raw + source: https://raw.githubusercontent.com/openstack/cinder/master/contrib/block-box/docker-compose.yml + hashsum: 1751f8e4f6b4cddd8c4843a0f4473274 + kubectl: + dest: /usr/local/bin + dl: + format: bin + source: https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/darwin/amd64/kubectl + unwanted: + - /usr/local/boring_archive_software + + remote_pkgs: + zoom: 'https://zoom.us/client/latest/zoom_amd64.deb' + diff --git a/test/integration/default/pillar.example.ubuntu.1804 b/test/integration/default/pillar.example.ubuntu.1804 new file mode 100644 index 0000000..e7e1e03 --- /dev/null +++ b/test/integration/default/pillar.example.ubuntu.1804 @@ -0,0 +1,94 @@ +packages: + pkgs: + # A dict of "package: version" pairs: + held: + alien: 8.95 + iotop: 0.6-2 + + # Alternativelly, held packages can also be specified as a list with + # no versions. In this case, the package will be held in the installed + # version. + # held: + # - alien + # - iotop + wanted: + - git + - less + - bc + - curl + - fail2ban + unwanted: + - avahi-daemon + required: + pkgs: + - wget + - git + pips: + required: + pkgs: + - libpython2.7-dev + - python-pip + wanted: + - dxpy + - attrs + unwanted: + - campbel + - reverse_geocode + - indy-crypto + config: + global: + timeout: 120 + default-timeout: 120 + # proxy: http://proxy.example.com:3128 + gems: + wanted: + - progressbar + - minitest + unwanted: + - diff-lcs + - kitchen-vagrant + - kwalify + # Disable Snaps testing in Ubuntu 18 due to + # https://github.com/saltstack-formulas/packages-formula/issues/44 + # snaps: + # wanted: + # - hello-world + # classic: + # - test-snapd-hello-classic + # unwanted: + # - goodbye-world + archives: + wanted: + terminator: + dest: /usr/local/terminator/ + options: '--strip-components=1' #recommended option, but beware tarbombs + dl: + format: tar + source: https://launchpad.net/terminator/gtk3/1.91/+download/terminator-1.91.tar.gz + #hashurl: https://launchpad.net/terminator/gtk3/1.91/+download/terminator-1.91.tar.gz/+md5 + hashsum: md5=2eed999d7a41f2e18eaa511bbbf80f58 + phantomjs: + dest: /usr/local/src/ #beware tarbombs + user: root + mode: '0700' + dl: + format: tar + source: https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 + hashsum: md5=1c947d57fce2f21ce0b43fe2ed7cd361 + blockbox: + dest: /usr/local/src/ + dl: + format: raw + source: https://raw.githubusercontent.com/openstack/cinder/master/contrib/block-box/docker-compose.yml + hashsum: 1751f8e4f6b4cddd8c4843a0f4473274 + kubectl: + dest: /usr/local/bin + dl: + format: bin + source: https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/darwin/amd64/kubectl + unwanted: + - /usr/local/boring_archive_software + + remote_pkgs: + zoom: 'https://zoom.us/client/latest/zoom_amd64.deb' + diff --git a/test/integration/default/pips_spec.rb b/test/integration/default/pips_spec.rb index fac64f6..95fb242 100644 --- a/test/integration/default/pips_spec.rb +++ b/test/integration/default/pips_spec.rb @@ -1,11 +1,18 @@ ### WANTED/REQUIRED +case os[:name] +when 'fedora', 'opensuse' + wanted_pips = [] +else + wanted_pips = %w{ + dxpy + attrs + } +end + control 'Wanted/Required python packages' do title 'should be installed' - %w{ - dxpy - attrs - }.each do |p| + wanted_pips.each do |p| describe pip(p) do it { should be_installed } end diff --git a/test/integration/default/pkgs_spec.rb b/test/integration/default/pkgs_spec.rb index 8aec082..22e258d 100644 --- a/test/integration/default/pkgs_spec.rb +++ b/test/integration/default/pkgs_spec.rb @@ -23,15 +23,22 @@ python3-dnf-plugin-versionlock ) held_packages = { - 'alien': '8.95-5.fc27', - 'iotop': '0.6-15.fc27' + 'alien': '8.95-8.fc29', + 'iotop': '0.6-18.fc29' } lock_file = '/etc/dnf/plugins/versionlock.list' +# Adding empty Suse entries, to get tests passing +# Don't know the correct values to add here. +when 'opensuse' + os_packages = %w() + held_packages = {} + lock_file = '' when 'debian', 'ubuntu' os_packages = %w() held_packages = { 'alien': '8.95', - 'iotop': '0.6-2' + # To match also ubuntu16's + 'iotop': '0.6-' } lock_file = '/var/lib/dpkg/status' end