Changeset - 6b784a5da8bc
[Not reviewed]
1 1 3
Branko Majic (branko) - 7 years ago 2017-06-06 10:35:31
branko@majic.rs
MAR-30: Added documentation related to development:

- Moved existing test site documentation under the new 'Development' chapter.
- Added instructions for preparing development environment.
- Added instructions for running Ansible role tests.
- Added requirement input and txt files for use with pip-tools.
4 files changed with 142 insertions and 2 deletions:
0 comments (0 inline, 0 general)
docs/development.rst
Show inline comments
 
file renamed from docs/testsite.rst to docs/development.rst
 
.. _development:
 

	
 
Development
 
===========
 

	
 
This section covers procedures and information related to development of *Majic
 
Ansible Roles*.
 

	
 

	
 
Preparing environment
 
---------------------
 

	
 
The easiest way to get going with role development is to set-up a separate
 
Python virtual environment with the necessary packages. This can be done by
 
performing the following steps:
 

	
 
1. Ensure that the following minimum set of packages are installed via
 
   distribution package manager:
 

	
 
   - `Git <https://git-scm.com/>`_
 
   - `libffi <https://sourceware.org/libffi/>`_ runtime and development package.
 
   - `OpenSSL <https://www.openssl.org/>`_ runtime and development package.
 
   - `pip <https://pypi.python.org/pypi/pip/>`_
 
   - `virtualenv <https://pypi.python.org/pypi/virtualenv>`_
 
   - `virtualenvwrapper <https://virtualenvwrapper.readthedocs.io/en/latest/>`_
 
   - Development packages for Python.
 

	
 
   On Debian this can be easily done with::
 

	
 
     apt-get install virtualenv virtualenvwrapper git python-pip python-dev \
 
     libffi-dev libssl-dev
 

	
 
2. In order to be able to run role tests, it is necessary to install `VirtualBox
 
   <https://www.virtualbox.org/>`_ and `Vagrant <https://www.vagrantup.com/>`_,
 
   using instructions outlined on their respective websites. It is recommended
 
   to use latest versions available. At time of this writing the role tests have
 
   been successfully run on *VirtualBox 5.1.22* and *Vagrant 1.9.5*.
 

	
 
3. Clone the git repository::
 

	
 
     git clone https://code.majic.rs/majic-ansible-roles/ ~/projects/
 

	
 
4. Create a separate Python virtual environment::
 

	
 
     mkvirtualenv majic-ansible-roles -a ~/projects/majic-ansible-roles/
 

	
 
5. Make sure the virtual environment has been activated, and install `pip-tools
 
   <https://github.com/jazzband/pip-tools>`_::
 

	
 
     workon majic-ansible-roles
 
     pip install pip-tools
 

	
 
6. Synchronise Python virtual environment with requirements file using
 
   **pip-tools**::
 

	
 
     workon majic-ansible-roles
 
     pip-sync
 

	
 

	
 
Running role tests
 
------------------
 

	
 
Role tests are implemented using `Molecule <https://molecule.readthedocs.io/>`_,
 
`Testinfra <https://testinfra.readthedocs.io/en/latest/>`_, `VirtualBox
 
<https://www.virtualbox.org/>`_ and `Vagrant
 
<https://www.vagrantup.com/>`_. *Molecule* and *Testinfra* are installed inside
 
of Pyhton virtual environment, while *VirtualBox* and *Vagrant* need to be
 
installed distribution-wide, following instructions outlined on their
 
corresponding websites.
 

	
 
In order to run tests for a specific role, perform the following steps:
 

	
 
1. Switch to Python virtual environment::
 

	
 
     workon majic-ansible-roles
 

	
 
2. Change directory::
 

	
 
     cd roles/ROLENAME/
 

	
 
3. Run tests::
 

	
 
     molecule test
 

	
 

	
 
.. _testsite:
 

	
 
Test Site
 
=========
 
---------
 

	
 
*Majic Ansible Roles* comes with a small sample test site configuration which
 
demonstrates use of every role. This test site also serves as starting point for
docs/index.rst
Show inline comments
 
@@ -43,7 +43,7 @@ Contents
 
   about
 
   usage
 
   rolereference
 
   testsite
 
   development
 
   releaseprocedures
 
   releasenotes
 

	
requirements.in
Show inline comments
 
new file 100644
 
ansible~=1.9.0
 
dnspython
 
molecule~=1.18.0
 
pip-tools
 
\ No newline at end of file
requirements.txt
Show inline comments
 
new file 100644
 
#
 
# This file is autogenerated by pip-compile
 
# To update, run:
 
#
 
#    pip-compile --output-file requirements.txt requirements.in
 
#
 
ansible-lint==3.4.8       # via molecule
 
ansible==1.9.6
 
anyconfig==0.7.0          # via molecule
 
arrow==0.10.0             # via jinja2-time
 
asn1crypto==0.22.0        # via cryptography
 
binaryornot==0.4.3        # via cookiecutter
 
cffi==1.10.0              # via cryptography
 
chardet==3.0.3            # via binaryornot
 
click==6.7                # via cookiecutter, pip-tools
 
colorama==0.3.7           # via molecule
 
configparser==3.5.0       # via flake8
 
cookiecutter==1.4.0       # via molecule
 
cryptography==1.9         # via paramiko
 
dnspython==1.15.0
 
enum34==1.1.6             # via cryptography, flake8
 
first==2.0.1              # via pip-tools
 
flake8==3.0.4             # via molecule
 
future==0.16.0            # via cookiecutter
 
idna==2.5                 # via cryptography
 
ipaddress==1.0.18         # via cryptography
 
jinja2-time==0.2.0        # via cookiecutter
 
jinja2==2.8               # via ansible, cookiecutter, jinja2-time, molecule
 
markupsafe==1.0           # via jinja2
 
mccabe==0.5.3             # via flake8
 
molecule==1.18.1
 
paramiko==2.0.2           # via ansible, molecule
 
pbr==1.10.0               # via molecule
 
pexpect==4.2.1            # via molecule
 
pip-tools==1.9.0
 
poyo==0.4.1               # via cookiecutter
 
ptyprocess==0.5.1         # via pexpect
 
py==1.4.34                # via pytest
 
pyasn1==0.2.3             # via paramiko
 
pycodestyle==2.0.0        # via flake8
 
pycparser==2.17           # via cffi
 
pycrypto==2.6.1           # via ansible
 
pyflakes==1.2.3           # via flake8
 
pytest==3.1.1             # via testinfra
 
python-dateutil==2.6.0    # via arrow
 
pyyaml==3.12              # via ansible, ansible-lint, molecule
 
sh==1.11                  # via molecule
 
six==1.10.0               # via ansible-lint, cryptography, pip-tools, python-dateutil, testinfra
 
tabulate==0.7.5           # via molecule
 
testinfra==1.4.5          # via molecule
 
whichcraft==0.4.1         # via cookiecutter
0 comments (0 inline, 0 general)