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
```
This commit is contained in:
Imran Iqbal 2019-08-07 00:00:54 +01:00
parent f63e73c4ee
commit e76525f130
No known key found for this signature in database
GPG key ID: 6D8629439D2B7819
9 changed files with 119 additions and 19 deletions

View file

@ -3,7 +3,7 @@
---
stages:
- test
- commitlint
- lint
- name: release
if: branch = master AND type != pull_request
@ -50,7 +50,7 @@ env:
# - INSTANCE: default-amazonlinux-2-2018-3-py2
# - INSTANCE: default-debian-8-2017-7-py2
# - INSTANCE: default-ubuntu-1604-2017-7-py2
- INSTANCE: default-centos-6-2017-7-py2
- INSTANCE: centos6-centos-6-2017-7-py2
# - INSTANCE: default-fedora-29-2017-7-py2
# - INSTANCE: default-opensuse-leap-15-2017-7-py2
# - INSTANCE: default-amazonlinux-2-2017-7-py2
@ -60,16 +60,21 @@ script:
jobs:
include:
# Define the commitlint stage
- stage: commitlint
# Define the `lint` stage (runs `yamllint` and `commitlint`)
- stage: lint
language: node_js
node_js: lts/*
before_install: skip
script:
# Install and run `yamllint`
- pip install --user yamllint
# yamllint disable-line rule:line-length
- yamllint -s . .yamllint pillar.example test/salt/pillar/define_roles.sls test/salt/pillar/centos6.sls
# Install and run `commitlint`
- npm install @commitlint/config-conventional -D
- npm install @commitlint/travis-cli -D
- commitlint-travis
# Define the release stage that runs semantic-release
# Define the release stage that runs `semantic-release`
- stage: release
language: node_js
node_js: lts/*

16
.yamllint Normal file
View file

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# Extend the `default` configuration provided by `yamllint`
extends: default
# Files to ignore completely
# 1. All YAML files under directory `node_modules/`, introduced during the Travis run
ignore: |
node_modules/
rules:
line-length:
# Increase from default of `80`
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
max: 88

View file

@ -134,6 +134,8 @@ verifier:
suites:
- name: default
excludes:
- centos-6-2017-7-py2
provisioner:
state_top:
base:
@ -144,8 +146,30 @@ suites:
base:
'*':
- template
- define_roles
pillars_from_files:
template.sls: pillar.example
define_roles.sls: test/salt/pillar/define_roles.sls
verifier:
inspec_tests:
- path: test/integration/default
- name: centos6
includes:
- centos-6-2017-7-py2
provisioner:
state_top:
base:
'*':
- template
pillars:
top.sls:
base:
'*':
- template
- define_roles
pillars_from_files:
template.sls: test/salt/pillar/centos6.sls
define_roles.sls: test/salt/pillar/define_roles.sls
verifier:
inspec_tests:
- path: test/integration/default

View file

@ -11,17 +11,10 @@ template:
# Using bash package and udev service as an example. This allows us to
# test the template formula itself. You should set these parameters to
# examples that make sense in the contexto of the formula you're writing.
{%- if grains.osfinger == 'CentOS-6' %}
pkg:
name: cronie
service:
name: crond
{%- else %}
pkg:
name: bash
service:
name: systemd-udevd
{%- endif %}
config: /etc/template-formula.conf
tofs:

View file

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

View file

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['os_family'] based logic.
@ -10,10 +10,6 @@
# you will need to provide at least an empty dict in this file, e.g.
# osfamilymap: {}
---
{%- if grains.os == 'MacOS' %}
{%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
{%- endif %}
Debian:
pkg:
name: template-debian
@ -48,5 +44,4 @@ Solaris: {}
Windows: {}
MacOS:
rootgroup: {{ macos_rootgroup | d('') }}
MacOS: {}

View file

@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: default
title: template formula
maintainer: SaltStack Formulas

View file

@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
template:
lookup:
master: template-master
# Just for testing purposes
winner: lookup
added_in_lookup: lookup_value
# Using bash package and udev service as an example. This allows us to
# test the template formula itself. You should set these parameters to
# examples that make sense in the contexto of the formula you're writing.
pkg:
name: cronie
service:
name: crond
config: /etc/template-formula.conf
tofs:
# The files_switch key serves as a selector for alternative
# directories under the formula files directory. See TOFS pattern
# doc for more info.
# Note: Any value not evaluated by `config.get` will be used literally.
# This can be used to set custom paths, as many levels deep as required.
files_switch:
- any/path/can/be/used/here
- id
- roles
- osfinger
- os
- os_family
# All aspects of path/file resolution are customisable using the options below.
# This is unnecessary in most cases; there are sensible defaults.
# path_prefix: template_alt
# dirs:
# files: files_alt
# default: default_alt
# The entries under `source_files` are prepended to the default source files
# given for the state
# source_files:
# template-config-file-file-managed:
# - 'example_alt.tmpl'
# - 'example_alt.tmpl.jinja'
# For testing purposes
source_files:
template-config-file-file-managed:
- 'example.tmpl.jinja'
template-subcomponent-config-file-file-managed:
- 'subcomponent-example.tmpl.jinja'
# Just for testing purposes
winner: pillar
added_in_pillar: pillar_value

View file

@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# libtofs.jinja must work with tofs.files_switch looked up list
roles:
- foo