Skip to content
README.rst 1.82 KiB
Newer Older
Ansible pre-commit hooks
########################
nimrod's avatar
nimrod committed

**This project has been discontinued and has been replaced by** `pre-commit-hooks
<https://git.shore.co.il/nimrod/pre-commit-hooks>`_

nimrod's avatar
nimrod committed
.. image:: https://git.shore.co.il/ansible/ansible-pre-commit/badges/master/pipeline.svg
    :target: https://git.shore.co.il/ansible/ansible-pre-commit/-/commits/master
    :alt: CI status
Ansible `pre-commit <http://pre-commit.com/>`_ hooks.

- ansible-syntax-check: The hook runs
  :code:`ansible --syntax-check` against playbooks declared.
nimrod's avatar
nimrod committed
- ansible-vault-check: The hook verifies that files that have :code:`vault` in
  the filename are indeed vaulted.
nimrod's avatar
nimrod committed

nimrod's avatar
nimrod committed
Requirements
nimrod's avatar
nimrod committed
------------

nimrod's avatar
nimrod committed
- Pre-commit 1.2 or later.
nimrod's avatar
nimrod committed
- Python 2.7 or 3.6 or later.
nimrod's avatar
nimrod committed

Installation
------------
nimrod's avatar
nimrod committed

Add the following to your :code:`.pre-commit-config.yaml`:

nimrod's avatar
nimrod committed
.. code:: yaml
nimrod's avatar
nimrod committed

nimrod's avatar
nimrod committed
    - repo: https://git.shore.co.il/ansible/ansible-pre-commit.git
nimrod's avatar
nimrod committed
      sha: v0.10.0
nimrod's avatar
nimrod committed
      hooks:
nimrod's avatar
nimrod committed
        files: site.yml #In case you want to specify other playbook files.
nimrod's avatar
nimrod committed
      - id: ansible-vault-check
nimrod's avatar
nimrod committed
And in the next :code:`pre-commit` will install and run 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:
nimrod's avatar
nimrod committed

nimrod's avatar
nimrod committed
.. code::
nimrod's avatar
nimrod committed

    [defaults]
    roles_path=path/to/roles/directory:path/to/another/roles/directory
nimrod's avatar
nimrod committed

nimrod's avatar
nimrod committed
This software is licensed under the MIT license (see the :code:`LICENSE.txt`
file).

Author Information
------------------

Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website
<https://www.shore.co.il/>`_. Patches are welcome via `git send-email
<http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located
nimrod's avatar
nimrod committed
at: https://git.shore.co.il/explore/.