diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3016f7593bb9f6586c37e14838d741a23349191..83a18d25e58ca7adc2e526f0ed30b12263cb0c13 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,17 +6,30 @@ - id: check-xml - id: check-yaml - id: check-merge-conflict + - id: flake8 + - id: check-symlinks - repo: https://www.shore.co.il/git/ansible-pre-commit - sha: v0.4.0 + sha: 0fadd691465b97db8992cfc66650f630e433324b hooks: - id: ansible-syntax-check always_run: true files: tests/playbook.yml - args: ['tests/playbook.yml'] + args: + - tests/playbook.yml - repo: https://github.com/willthames/ansible-lint - sha: v3.4.4 + sha: 959ab0f525e9abb19cf75f34381015cf33695f61 hooks: - id: ansible-lint always_run: true files: tests/playbook.yml - args: ['tests/playbook.yml'] + args: + - tests/playbook.yml +- repo: local + hooks: + - id: piprot + name: piprot + description: Check up-to-date Python requirements + language: system + entry: piprot --quiet --outdated tests/requirements.txt + files: requirements.txt + always_run: true diff --git a/README.rst b/README.rst index 9aca8cc202e6f2138ebde2df7a45dc40cfbdff79..eb1f9a8ceecdfc3f4928464d2b6f5840fb614d1c 100644 --- a/README.rst +++ b/README.rst @@ -6,7 +6,8 @@ An Ansible role for installing and configuring an NTP client. Requirements ------------ -See :code:`meta/main.yml` and assertions at top of :code:`tasks/main.yml`. +See :code:`meta/main.yml`, :code:`tests/requirements.yml` and assertions at +the top of :code:`tasks/main.yml`. Role Variables -------------- @@ -26,17 +27,21 @@ See :code:`tests/playbook.yml`. Testing ------- -To install the dependencies: +Testing requires Virtualbox and Vagrant and Python 2.7. Install the Python +dependencies, add pre-commit hooks by running: .. code:: shell - ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles + pip install -r tests/requirements.txt + pre-commit install To run the full test suite: .. code:: shell - molecule test + ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles + molecule test --platform all + pre-commit run --all-files License ------- diff --git a/ansible.cfg b/ansible.cfg index 10b3da5cfa1edbc2186229872bd129f0e34222c8..2bc7613f4df5ddc0fe0f2719df832ddfff4bfe62 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,6 +1,10 @@ [defaults] +library = library host_key_checking = False retry_files_enabled = False -roles_path = roles:../:../../:.molecule/roles +roles_path = .molecule/roles:.molecule/../roles:../:../../ command_warnings = True deprecation_warnings = True + +[ssh_connection] +pipelining = True diff --git a/library/__init__.py b/library/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/molecule.yml b/molecule.yml index 97ca770e2408328f9209a21008607cab2979e98e..838fd33060da0c7114b639da886a1de4cd6224b8 100644 --- a/molecule.yml +++ b/molecule.yml @@ -1,12 +1,10 @@ --- ansible: - verbose: v + verbose: vv playbook: tests/playbook.yml diff: True - -molecule: - testinfra_dir: tests - ansible_config_template: ansible.cfg + config_file: ../ansible.cfg + requirements_file: tests/requirements.yml vagrant: providers: @@ -18,7 +16,7 @@ vagrant: - name: debian box: debian/jessie64 - name: ubuntu - box: ubuntu/trusty64 + box: ubuntu/xenial64 instances: - name: ansible-role-ntp-client options: diff --git a/tests/playbook.yml b/tests/playbook.yml index ce658243cc2b36cc775cc43f19b0d49ef75e7489..15092e57cb0ee27e2b4b656dfea467f2d4f8d820 100644 --- a/tests/playbook.yml +++ b/tests/playbook.yml @@ -1,7 +1,11 @@ --- - hosts: ansible-role-ntp-client-openbsd gather_facts: false - roles: [ role: ansible-role-openbsd-bootstrap ] + roles: [openbsd_bootstrap] + +- hosts: ansible-role-ntp-client-ubuntu + gather_facts: false + roles: [debian_bootstrap] - hosts: all - roles: [ role: ansible-role-ntp-client ] + roles: [ansible-role-ntp-client] diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..0588c359a06c17f6d8a27f8d19be6cf89b2758b8 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,6 @@ +ansible==2.2.0.0 +testinfra==1.4.3 +molecule==1.13.0 +ansible-lint==3.4.4 +pre-commit==0.9.3 +piprot==0.9.7 diff --git a/tests/requirements.yml b/tests/requirements.yml new file mode 100644 index 0000000000000000000000000000000000000000..8b9b2bcba3b4459621ff239243ac0375a081f20a --- /dev/null +++ b/tests/requirements.yml @@ -0,0 +1,7 @@ +--- +- src: https://www.shore.co.il/git/ansible-role-openbsd-bootstrap + scm: git + name: openbsd_bootstrap +- src: https://www.shore.co.il/git/ansible-role-debian-bootstrap + scm: git + name: debian_bootstrap