Skip to content
Snippets Groups Projects
Commit d46d9b6a authored by nimrod's avatar nimrod
Browse files

A plethora of small updates.

- Update Ansible.
- More pre-commit checks.
- Replace the Vault shell script with a simpler grep hook.
parent 3f6663a8
Branches
Tags
No related merge requests found
# vim:ff=unix ts=2 sw=2 ai expandtab
---
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0 rev: v2.5.0
hooks: hooks:
- id: check-added-large-files - id: check-added-large-files
- id: check-yaml
- id: check-merge-conflict - id: check-merge-conflict
- id: flake8 - id: detect-private-key
- repo: https://www.shore.co.il/git/shell-pre-commit/ - id: trailing-whitespace
rev: v0.6.0 - repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.0
hooks: hooks:
- id: shell-lint - id: rst-linter
files: ansible-vault-check - repo: https://github.com/adrienverge/yamllint
rev: v1.21.0
hooks:
- id: yamllint
- repo: https://github.com/amperser/proselint/
rev: 0.10.2
hooks:
- id: proselint
types: [plain-text]
exclude: LICENSE|requirements
hooks.yaml
\ No newline at end of file
---
- id: ansible-syntax-check
name: Syntax check Ansible playbooks
description: Check Ansible playbooks for syntax errors.
language: python
entry: ansible-playbook
files: playbook.yml
args: ['--inventory=localhost,', '--syntax-check']
- id: ansible-vault-check
name: Verify vaulted files
description: Verify that Ansible Vault files are vaulted.
language: pygrep
files: vault
entry: |-
ANSIBLE_VAULT
--- ---
language: python language: python
python: ["2.7", "3.4", "3.5", "3.6"] python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
dist: trusty dist: trusty
sudo: false sudo: false
group: beta group: beta
......
...@@ -14,7 +14,7 @@ Ansible `pre-commit <http://pre-commit.com/>`_ hooks. ...@@ -14,7 +14,7 @@ Ansible `pre-commit <http://pre-commit.com/>`_ hooks.
Requirements Requirements
------------ ------------
- Pre-commit. - Pre-commit 1.2 or later.
- Python 2.7 or 3.4 or later. - Python 2.7 or 3.4 or later.
Installation Installation
...@@ -25,7 +25,7 @@ Add the following to your :code:`.pre-commit-config.yaml`: ...@@ -25,7 +25,7 @@ Add the following to your :code:`.pre-commit-config.yaml`:
.. code:: yaml .. code:: yaml
- repo: https://www.shore.co.il/git/ansible-pre-commit/ - repo: https://www.shore.co.il/git/ansible-pre-commit/
sha: v0.6.0 sha: v0.9.0
hooks: hooks:
- id: ansible-syntax-check - id: ansible-syntax-check
files: site.yml #In case you want to specify other playbook files. files: site.yml #In case you want to specify other playbook files.
......
#!/bin/sh
set -eu
for filename in $@
do
grep -q ANSIBLE_VAULT "$filename" || \
(echo "$filename is not vaulted." && exit 1)
done
---
- id: ansible-syntax-check
name: Syntax check Ansible playbooks
description: Check Ansible playbooks for syntax errors.
language: python
entry: ansible-playbook
files: playbook.yml
args: ['--inventory=localhost,', '--syntax-check']
- id: ansible-vault-check
name: Verify vaulted files
description: Verify that Ansible Vault files are vaulted.
language: script
entry: ansible-vault-check
files: vault
...@@ -2,10 +2,10 @@ from setuptools import setup ...@@ -2,10 +2,10 @@ from setuptools import setup
setup( setup(
name='pre_commit_ansible_dummy_package', name="pre_commit_ansible_dummy_package",
url='https://www.shore.co.il/git/ansible-pre-commit', url="https://www.shore.co.il/git/ansible-pre-commit",
author='Nimrod Adar', author="Nimrod Adar",
author_email='nimrod@shore.co.il', author_email="nimrod@shore.co.il",
version=open('VERSION', 'r').read().strip(), version=open("VERSION", "r").read().strip(),
install_requires=['ansible==2.6.2'], install_requires=["ansible==2.9.6"],
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment