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

- Forked from ansible-pre-commit.

parent d805ec8a
No related branches found
No related tags found
No related merge requests found
...@@ -4,18 +4,4 @@ ...@@ -4,18 +4,4 @@
- id: check-added-large-files - id: check-added-large-files
- id: check-yaml - id: check-yaml
- id: check-merge-conflict - id: check-merge-conflict
- repo: https://www.shore.co.il/git/shell-pre-commit/ - id: flake8
sha: v0.1.0
hooks:
- id: shell-lint
files: ansible-syntax-check|ansible-vault-check
- repo: local
hooks:
- id: piprot
name: piprot
description: Check up-to-date Python requirements
language: system
entry: piprot
args: ['--quiet', '--outdated']
files: requirements.txt
always_run: true
--- ---
language: python language: python
python: "2.7" python: ["2.7", "3.3", "3.4", "3.5", "3.6"]
dist: trusty dist: trusty
sudo: false sudo: false
group: beta group: beta
...@@ -9,8 +9,12 @@ cache: ...@@ -9,8 +9,12 @@ cache:
- directories: - directories:
- $HOME/.pre-commit - $HOME/.pre-commit
install:
- pip install pre-commit
script: script:
- pre-commit run --all-files - pre-commit run --all-files
- pip install .
notifications: notifications:
email: false email: false
MIT License MIT License
Copyright (c) 2016 Adar Nimrod Copyright (c) 2017 Adar Nimrod
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
Ansible pre-commit hooks Python pre-commit hooks
######################## #######################
.. image:: https://travis-ci.org/adarnimrod/ansible-pre-commit.svg?branch=master .. image:: https://travis-ci.org/adarnimrod/python-pre-commit.svg?branch=master
:target: https://travis-ci.org/adarnimrod/ansible-pre-commit :target: https://travis-ci.org/adarnimrod/python-pre-commit
Ansible `pre-commit <http://pre-commit.com/>`_ hooks. Ansible `pre-commit <http://pre-commit.com/>`_ hooks.
- ansible-syntax-check: The hook runs - :code:`piprot`: Checks your requirements files for out of date packages.
:code:`ansible --syntax-check` against playbooks declared.
- ansible-vault-check: The hook verifies that files that have :code:`vault` in
the filename are indeed vaulted.
Dependencies
------------
- Ansible.
- Pre-commit.
Installation Installation
------------ ------------
...@@ -24,23 +15,10 @@ Add the following to your :code:`.pre-commit-config.yaml`: ...@@ -24,23 +15,10 @@ 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/python-pre-commit/
sha: v0.4.0 sha: v0.1.0
hooks: hooks:
- id: ansible-syntax-check - id: piprot
# In case you want to specify other playbook files:
files: playbook.yml
- id: ansible-vault-check
And run :code:`pre-commit autoupdate` to update the hooks. In case your
:code:`roles` directory isn't in the same directory as the playbook you're
testing or at :code:`/etc/ansible/roles` you need to declare the roles search
path in :code:`ansible.cfg` in the root of the repo like so:
.. code::
[defaults]
roles_path=path/to/roles/directory:path/to/another/roles/directory
License License
------- -------
......
0.5.0 0.1.0
#!/bin/sh
set -eu
for playbook in $@
do
ansible-playbook --inventory=localhost, --syntax-check "$playbook"
done
#!/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 - id: piprot
name: Syntax check Ansible playbooks name: Check requirements for out of date packages.
description: Check Ansible playbooks for syntax errors. description: Check requirements for out of date packages.
language: python language: python
entry: ansible-playbook entry: piprot
files: playbook.yml args: ['--outdated']
args: ['--inventory=localhost,', '--syntax-check'] files: 'requirements.*\.txt$'
- id: ansible-vault-check
name: Verify vaulted files
description: Verify that Ansible Vault files are vaulted.
language: script
entry: ansible-vault-check
files: vault
ansible==2.2.1.0
pre-commit==0.11.0
piprot==0.9.7
...@@ -2,7 +2,7 @@ from setuptools import setup ...@@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name='pre_commit_ansible_dummy_package', name='pre_commit_python_dummy_package',
version='0.1.0', version=open('VERSION', 'r').read().strip(),
install_requires=['ansible==2.2.1.0'], install_requires=['piprot', 'docutils'],
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment