Skip to content

Commit e76525f

Browse files
committed
feat(yamllint): include for this repo and apply rules throughout
* Semi-automated using `ssf-formula` (v0.5.0) * Fix errors shown below: ```bash template-formula$ $(grep "\- yamllint" .travis.yml | sed -e "s:^\s\+-\s\(.*\):\1:") ./test/integration/default/inspec.yml 1:1 warning missing document start "---" (document-start) ./template/osfamilymap.yaml 1:89 error line too long (116 > 88 characters) (line-length) 1:24 error trailing spaces (trailing-spaces) 13:2 error syntax error: found character '%' that cannot start any token pillar.example 14:4 error syntax error: found character '%' that cannot start any token ```
1 parent f63e73c commit e76525f

File tree

9 files changed

+119
-19
lines changed

9 files changed

+119
-19
lines changed

.travis.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
---
44
stages:
55
- test
6-
- commitlint
6+
- lint
77
- name: release
88
if: branch = master AND type != pull_request
99

@@ -50,7 +50,7 @@ env:
5050
# - INSTANCE: default-amazonlinux-2-2018-3-py2
5151
# - INSTANCE: default-debian-8-2017-7-py2
5252
# - INSTANCE: default-ubuntu-1604-2017-7-py2
53-
- INSTANCE: default-centos-6-2017-7-py2
53+
- INSTANCE: centos6-centos-6-2017-7-py2
5454
# - INSTANCE: default-fedora-29-2017-7-py2
5555
# - INSTANCE: default-opensuse-leap-15-2017-7-py2
5656
# - INSTANCE: default-amazonlinux-2-2017-7-py2
@@ -60,16 +60,21 @@ script:
6060

6161
jobs:
6262
include:
63-
# Define the commitlint stage
64-
- stage: commitlint
63+
# Define the `lint` stage (runs `yamllint` and `commitlint`)
64+
- stage: lint
6565
language: node_js
6666
node_js: lts/*
6767
before_install: skip
6868
script:
69+
# Install and run `yamllint`
70+
- pip install --user yamllint
71+
# yamllint disable-line rule:line-length
72+
- yamllint -s . .yamllint pillar.example test/salt/pillar/define_roles.sls test/salt/pillar/centos6.sls
73+
# Install and run `commitlint`
6974
- npm install @commitlint/config-conventional -D
7075
- npm install @commitlint/travis-cli -D
7176
- commitlint-travis
72-
# Define the release stage that runs semantic-release
77+
# Define the release stage that runs `semantic-release`
7378
- stage: release
7479
language: node_js
7580
node_js: lts/*

.yamllint

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
# Extend the `default` configuration provided by `yamllint`
5+
extends: default
6+
7+
# Files to ignore completely
8+
# 1. All YAML files under directory `node_modules/`, introduced during the Travis run
9+
ignore: |
10+
node_modules/
11+
12+
rules:
13+
line-length:
14+
# Increase from default of `80`
15+
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
16+
max: 88

kitchen.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ verifier:
134134

135135
suites:
136136
- name: default
137+
excludes:
138+
- centos-6-2017-7-py2
137139
provisioner:
138140
state_top:
139141
base:
@@ -144,8 +146,30 @@ suites:
144146
base:
145147
'*':
146148
- template
149+
- define_roles
147150
pillars_from_files:
148151
template.sls: pillar.example
152+
define_roles.sls: test/salt/pillar/define_roles.sls
153+
verifier:
154+
inspec_tests:
155+
- path: test/integration/default
156+
- name: centos6
157+
includes:
158+
- centos-6-2017-7-py2
159+
provisioner:
160+
state_top:
161+
base:
162+
'*':
163+
- template
164+
pillars:
165+
top.sls:
166+
base:
167+
'*':
168+
- template
169+
- define_roles
170+
pillars_from_files:
171+
template.sls: test/salt/pillar/centos6.sls
172+
define_roles.sls: test/salt/pillar/define_roles.sls
149173
verifier:
150174
inspec_tests:
151175
- path: test/integration/default

pillar.example

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@ template:
1111
# Using bash package and udev service as an example. This allows us to
1212
# test the template formula itself. You should set these parameters to
1313
# examples that make sense in the contexto of the formula you're writing.
14-
{%- if grains.osfinger == 'CentOS-6' %}
15-
pkg:
16-
name: cronie
17-
service:
18-
name: crond
19-
{%- else %}
2014
pkg:
2115
name: bash
2216
service:
2317
name: systemd-udevd
24-
{%- endif %}
2518
config: /etc/template-formula.conf
2619

2720
tofs:

template/map.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@
4848

4949
{#- Change **template** to match with your formula's name and then remove this line #}
5050
{%- set template = config %}
51+
52+
{#- Post-processing for specific non-YAML customisations #}
53+
{%- if grains.os == 'MacOS' %}
54+
{%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
55+
{%- do template.update({'rootgroup': macos_group}) %}
56+
{%- endif %}

template/osfamilymap.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: utf-8 -*-
1+
# -*- coding: utf-8 -*-
22
# vim: ft=yaml
33
#
44
# Setup variables using grains['os_family'] based logic.
@@ -10,10 +10,6 @@
1010
# you will need to provide at least an empty dict in this file, e.g.
1111
# osfamilymap: {}
1212
---
13-
{%- if grains.os == 'MacOS' %}
14-
{%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
15-
{%- endif %}
16-
1713
Debian:
1814
pkg:
1915
name: template-debian
@@ -48,5 +44,4 @@ Solaris: {}
4844

4945
Windows: {}
5046

51-
MacOS:
52-
rootgroup: {{ macos_rootgroup | d('') }}
47+
MacOS: {}

test/integration/default/inspec.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
14
name: default
25
title: template formula
36
maintainer: SaltStack Formulas

test/salt/pillar/centos6.sls

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
template:
5+
lookup:
6+
master: template-master
7+
# Just for testing purposes
8+
winner: lookup
9+
added_in_lookup: lookup_value
10+
11+
# Using bash package and udev service as an example. This allows us to
12+
# test the template formula itself. You should set these parameters to
13+
# examples that make sense in the contexto of the formula you're writing.
14+
pkg:
15+
name: cronie
16+
service:
17+
name: crond
18+
config: /etc/template-formula.conf
19+
20+
tofs:
21+
# The files_switch key serves as a selector for alternative
22+
# directories under the formula files directory. See TOFS pattern
23+
# doc for more info.
24+
# Note: Any value not evaluated by `config.get` will be used literally.
25+
# This can be used to set custom paths, as many levels deep as required.
26+
files_switch:
27+
- any/path/can/be/used/here
28+
- id
29+
- roles
30+
- osfinger
31+
- os
32+
- os_family
33+
# All aspects of path/file resolution are customisable using the options below.
34+
# This is unnecessary in most cases; there are sensible defaults.
35+
# path_prefix: template_alt
36+
# dirs:
37+
# files: files_alt
38+
# default: default_alt
39+
# The entries under `source_files` are prepended to the default source files
40+
# given for the state
41+
# source_files:
42+
# template-config-file-file-managed:
43+
# - 'example_alt.tmpl'
44+
# - 'example_alt.tmpl.jinja'
45+
46+
# For testing purposes
47+
source_files:
48+
template-config-file-file-managed:
49+
- 'example.tmpl.jinja'
50+
template-subcomponent-config-file-file-managed:
51+
- 'subcomponent-example.tmpl.jinja'
52+
53+
# Just for testing purposes
54+
winner: pillar
55+
added_in_pillar: pillar_value

test/salt/pillar/define_roles.sls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
14
# libtofs.jinja must work with tofs.files_switch looked up list
25
roles:
36
- foo

0 commit comments

Comments
 (0)