Skip to content
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

WIP: feat(unsupported): prevent formula running on unsupported minions #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions template/config/init.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_fail_if_unsupported = tplroot ~ '.unsupported' %}

include:
- {{ sls_fail_if_unsupported }}
- .file
4 changes: 4 additions & 0 deletions template/init.sls
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_fail_if_unsupported = tplroot ~ '.unsupported' %}

include:
- {{ sls_fail_if_unsupported }}
- .package
- .config
- .service
9 changes: 6 additions & 3 deletions template/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ FreeBSD: {}

OpenBSD: {}

Solaris: {}
Solaris:
unsupported: 'osfamily: Solaris.'

Windows: {}
Windows:
unsupported: 'osfamily: Windows.'

MacOS: {}
MacOS:
unsupported: 'osfamily: MacOS.'
10 changes: 7 additions & 3 deletions template/osfingermap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
# the `os_finger` grain.
---
# os: Ubuntu
Ubuntu-14.04:
unsupported: 'osfinger: Ubuntu 14.04 (does not use `systemd`).'
Ubuntu-16.04: {}
Ubuntu-18.04:
config: /etc/template.d/custom-ubuntu-18.04.conf

# os: CentOS
CentOS-6:
pkg: template-centos-6
config: /etc/template.d/custom-centos-6.conf
CentOS-7: {}
unsupported: 'osfinger: CentOS 6 (does not use `systemd`).'
CentOS-7:
pkg: template-centos-7
config: /etc/template.d/custom-centos-7.conf
3 changes: 2 additions & 1 deletion template/osmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Ubuntu:
pkg: template-ubuntu
config: /etc/template.d/custom-ubuntu.conf

Raspbian: {}
Raspbian:
unsupported: 'os: Raspbian (`armhf` architecture).'

# os_family: RedHat
Fedora:
Expand Down
4 changes: 4 additions & 0 deletions template/package/init.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_fail_if_unsupported = tplroot ~ '.unsupported' %}

include:
- {{ sls_fail_if_unsupported }}
- .install
4 changes: 4 additions & 0 deletions template/service/init.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_fail_if_unsupported = tplroot ~ '.unsupported' %}

include:
- {{ sls_fail_if_unsupported }}
- .running
19 changes: 19 additions & 0 deletions template/unsupported.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import template with context %}

{%- if template.unsupported is defined and template.unsupported %}
template-unsupported-test-fail:
test.fail_without_changes:
- name: |


#######################################
# Unsupported minion for this formula #
#######################################
{{ template.unsupported }}
- failhard: True
{%- endif %}