Commit 79a0e8f9 authored by nimrod's avatar nimrod
Browse files

Merge branch 'master' of /home/nimrod/Documents/Shore/Ansible/ansible-role-example

# Conflicts:
#	meta/main.yml
#	molecule.yml
#	tasks/main.yml
#	tests/playbook.yml
parents b740ee15 2902d3d4
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -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
+39 −4
Original line number Diff line number Diff line
@@ -6,7 +6,38 @@ Role to bootstrap an OpenBSD instance (allow Ansible to provision the instance).
Requirements
------------

See :code:`meta/main.yml` and assertions at top of :code:`tasks/main.yml`.
See :code:`meta/main.yml`, :code:`requirements.yml` and assertions at top of
:code:`tasks/main.yml`.

Adding the role as a dependency
-------------------------------

Add the following to your :code:`meta/main.yml`:

.. code:: yaml

    dependencies:
    - src: https://www.shore.co.il/git/ansible-role-example
      scm: git
      name: example

When :code: `ansible-galaxy` downloads your role it will also download its
dependencies, ensuring this role will be present and run everytime your role
runs.

Adding the role to your playbooks
---------------------------------

Add the following to your :code:`requirements.yml`:

.. code:: yaml

    - src: https://www.shore.co.il/git/ansible-role-example
      scm: git
      name: example

and update your roles by running :code: `ansible-galaxy install -r
requirements.yml`.

Role Variables
--------------
@@ -26,17 +57,21 @@ See :code:`tests/playbook.yml`.
Testing
-------

To install the dependencies:
Testing requires Virtualbox and Vagrant (out of scope for this documentation).
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
    pre-commit run --all-files
    molecule test --platform all

License
-------
+5 −1
Original line number Diff line number Diff line
[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
+2 −5
Original line number Diff line number Diff line
---
ansible:
  verbose: v
  verbose: vv
  playbook: tests/playbook.yml
  diff: True

molecule:
  testinfra_dir: tests
  ansible_config_template: ansible.cfg
  config_file: ../ansible.cfg

vagrant:
  providers:
+0 −1
Original line number Diff line number Diff line
---
# tasks file for ansible-role-openbsd-bootstrap

- name: Install Python
  raw: "PKG_PATH={{ openbsd_pkg_mirror }}/OpenBSD/$(uname -r)/packages/$(arch -s)/ /usr/sbin/pkg_add -Iz python-2.7"
  register: openbsd_pkg_add_python
Loading