Skip to content

fix(repo): fix relative includes cannot be used for sls requisites #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,67 @@ jobs:
# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
- env: INSTANCE=default-debian-10-master-py3
# - env: INSTANCE=package-debian-10-master-py3
# - env: INSTANCE=default-ubuntu-2004-master-py3
- env: INSTANCE=package-ubuntu-2004-master-py3
# - env: INSTANCE=default-ubuntu-1804-master-py3
# - env: INSTANCE=package-ubuntu-1804-master-py3
- env: INSTANCE=default-centos-8-master-py3
- env: INSTANCE=default-fedora-32-master-py3
# - env: INSTANCE=package-centos-8-master-py3
# - env: INSTANCE=default-fedora-32-master-py3
- env: INSTANCE=package-fedora-32-master-py3
# - env: INSTANCE=default-fedora-31-master-py3
- env: INSTANCE=default-opensuse-leap-152-master-py3
# - env: INSTANCE=package-fedora-31-master-py3
# - env: INSTANCE=default-opensuse-leap-152-master-py3
# - env: INSTANCE=package-opensuse-leap-152-master-py3
# - env: INSTANCE=default-amazonlinux-2-master-py3
# - env: INSTANCE=package-amazonlinux-2-master-py3
# - env: INSTANCE=default-debian-10-3000-3-py3
# - env: INSTANCE=package-debian-10-3000-3-py3
# - env: INSTANCE=default-debian-9-3000-3-py3
# - env: INSTANCE=package-debian-9-3000-3-py3
# - env: INSTANCE=default-ubuntu-1804-3000-3-py3
# - env: INSTANCE=package-ubuntu-1804-3000-3-py3
# - env: INSTANCE=default-centos-8-3000-3-py3
# - env: INSTANCE=package-centos-8-3000-3-py3
# - env: INSTANCE=default-centos-7-3000-3-py3
# - env: INSTANCE=package-centos-7-3000-3-py3
# - env: INSTANCE=default-fedora-31-3000-3-py3
# - env: INSTANCE=default-opensuse-leap-152-3000-3-py3
# - env: INSTANCE=default-amazonlinux-2-3000-3-py3
# - env: INSTANCE=package-fedora-31-3000-3-py3
- env: INSTANCE=default-opensuse-leap-152-3000-3-py3
# - env: INSTANCE=package-opensuse-leap-152-3000-3-py3
- env: INSTANCE=default-amazonlinux-2-3000-3-py3
# - env: INSTANCE=package-amazonlinux-2-3000-3-py3
# - env: INSTANCE=default-ubuntu-1804-3000-3-py2
# - env: INSTANCE=package-ubuntu-1804-3000-3-py2
# - env: INSTANCE=default-ubuntu-1604-3000-3-py2
# - env: INSTANCE=package-ubuntu-1604-3000-3-py2
# - env: INSTANCE=default-arch-base-latest-3000-3-py2
# - env: INSTANCE=package-arch-base-latest-3000-3-py2
# - env: INSTANCE=default-debian-10-2019-2-py3
# - env: INSTANCE=package-debian-10-2019-2-py3
# - env: INSTANCE=default-debian-9-2019-2-py3
# - env: INSTANCE=package-debian-9-2019-2-py3
# - env: INSTANCE=default-ubuntu-1804-2019-2-py3
# - env: INSTANCE=package-ubuntu-1804-2019-2-py3
# - env: INSTANCE=default-ubuntu-1604-2019-2-py3
# - env: INSTANCE=package-ubuntu-1604-2019-2-py3
# - env: INSTANCE=default-centos-8-2019-2-py3
# - env: INSTANCE=package-centos-8-2019-2-py3
# - env: INSTANCE=default-centos-7-2019-2-py3
# - env: INSTANCE=package-centos-7-2019-2-py3
# - env: INSTANCE=default-fedora-31-2019-2-py3
# - env: INSTANCE=package-fedora-31-2019-2-py3
# - env: INSTANCE=default-opensuse-leap-152-2019-2-py3
# - env: INSTANCE=package-opensuse-leap-152-2019-2-py3
# - env: INSTANCE=default-amazonlinux-2-2019-2-py3
# - env: INSTANCE=package-amazonlinux-2-2019-2-py3
# - env: INSTANCE=default-centos-6-2019-2-py2
# - env: INSTANCE=package-centos-6-2019-2-py2
# - env: INSTANCE=default-amazonlinux-1-2019-2-py2
# - env: INSTANCE=package-amazonlinux-1-2019-2-py2
# - env: INSTANCE=default-arch-base-latest-2019-2-py2
- env: INSTANCE=package-arch-base-latest-2019-2-py2

## Define the release stage that runs `semantic-release`
- stage: 'release'
Expand Down
3 changes: 2 additions & 1 deletion golang/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ golang:
rootuser: root
rootgroup: root
command: go/bin/go
path: ''
pkg:
name: go
name: golang
use_upstream_repo: false
use_upstream_archive: true
archive:
Expand Down
8 changes: 6 additions & 2 deletions golang/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ Debian: {}

RedHat: {}

Suse: {}
Suse:
pkg:
name: go

Gentoo: {}

Arch: {}
Arch:
pkg:
name: go

Alpine: {}

Expand Down
6 changes: 5 additions & 1 deletion golang/package/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
# vim: ft=sls

{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_repo_install = '.repo' %}
{%- set sls_repo_install = tplroot ~ '.package.repo.install' %}
{%- from tplroot ~ "/map.jinja" import golang with context %}

{%- if grains.kernel|lower == 'linux' %}
{%- if golang.pkg.use_upstream_repo %}
include:
- {{ sls_repo_install }}
{%- endif %}

golang-package-install-pkg-installed:
pkg.installed:
- name: {{ golang.pkg.name }}
- reload_modules: true
{%- if golang.pkg.use_upstream_repo %}
- require:
- sls: {{ sls_repo_install }}
{%- endif %}

{%- elif grains.os_family == 'MacOS' %}

Expand Down
6 changes: 1 addition & 5 deletions golang/package/repo/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import golang with context %}

{%- if golang.pkg.use_upstream_repo %}
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}

golang-package-repo-install-pkgrepo-managed:
pkgrepo.managed:
{{- format_kwargs(golang.pkg.repo) }}

{%- endif %}
16 changes: 16 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,19 @@ suites:
verifier:
inspec_tests:
- path: test/integration/default
- name: package
provisioner:
state_top:
base:
'*':
- golang
pillars:
top.sls:
base:
'*':
- golang
pillars_from_files:
golang.sls: test/salt/pillar/package.sls
verifier:
inspec_tests:
- path: test/integration/package
3 changes: 2 additions & 1 deletion test/integration/default/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ name: default
title: golang formula
maintainer: SaltStack Formulas
license: Apache-2.0
summary: Verify that the golang formula is setup and configured correctly
# yamllint disable-line rule:line-length
summary: Verify that the golang formula is setup and configured correctly (installation from archive)
supports:
- platform-name: debian
- platform-name: ubuntu
Expand Down
50 changes: 50 additions & 0 deletions test/integration/package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# InSpec Profile: `package`

This shows the implementation of the `package` 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 package
Summary
-------
Location: package
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 package
..

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 package --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).
12 changes: 12 additions & 0 deletions test/integration/package/controls/config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

control 'golang configuration' do
title 'should match desired configuration'

describe file('/etc/default/golang.sh') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
end
end
19 changes: 19 additions & 0 deletions test/integration/package/controls/packages_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

control 'golang package' do
title 'should be installed'

# Overide by platform
pkg =
case platform[:family]
# `linux` covers `arch` here
when 'suse', 'linux'
'go'
else
'golang'
end

describe package(pkg) do
it { should be_installed }
end
end
19 changes: 19 additions & 0 deletions test/integration/package/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: package
title: golang formula
maintainer: SaltStack Formulas
license: Apache-2.0
# yamllint disable-line rule:line-length
summary: Verify that the golang formula is setup and configured correctly (installation from package)
supports:
- platform-name: debian
- platform-name: ubuntu
- platform-name: centos
- platform-name: fedora
- platform-name: opensuse
- platform-name: suse
- platform-name: freebsd
- platform-name: amazon
- platform-name: arch
7 changes: 7 additions & 0 deletions test/salt/pillar/package.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
golang:
pkg:
use_upstream_repo: false
use_upstream_archive: false