Changeset - db859106bed8
[Not reviewed]
0 1 0
Branko Majic (branko) - 17 days ago 2024-09-02 23:16:51
branko@majic.rs
MAR-218: Document the workaround needed to make Molecule instance logins work:

- It should be possible to drop this workaround once the upstream has
taken care of merging the necessary fixes.
1 file changed with 9 insertions and 8 deletions:
0 comments (0 inline, 0 general)
docs/development.rst
Show inline comments
 
@@ -27,109 +27,110 @@ performing the following steps:
 

	
 
   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.2.12* and *Vagrant 2.0.4*.
 

	
 
3. In order to allow static IPv6 addresses to be allocated to virtual
 
   machines during testing, it is necessary to explicitly white-list
 
   the range used by the tests. Once the configuration file has been
 
   created, however, even the VirtualBox default allowed IPv4 subnet
 
   needs to be in the configuration explicitly as well.
 

	
 
   Update the VirtulBox configuration file (and make sure it can be
 
   read by the user running the tests):
 

	
 
   :file:`/etc/vbox/networks.conf`
 

	
 
   ::
 

	
 
     * 192.168.56.0/21
 
     * fd00::192:168:56:0/116
 

	
 
4. Clone the git repository::
 

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

	
 
5. Create a separate Python virtual environment::
 

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

	
 
6. 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
 

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

	
 
     workon majic-ansible-roles
 
     pip-sync
 

	
 
8. Patch the installed version of test runner (Molecule) for
 
   compatibility with newer versions of Vagrant (bundled Ruby):
 
8. Patch the installed version of test runner (Molecule) plugins until
 
   upstream merges the requried fixes for logging-in into Molecule
 
   Vagrant instances:
 

	
 
   .. note::
 
      This is an unfortunate consequence of *Majic Ansible Roles*
 
      being dependent on an old/deprecated version of Ansible. This
 
      will be addressed at some point in the future when the roles are
 
      moved over to being compatible with latest (and supported)
 
      versions of Ansible.
 
      For more details, see the following project links:
 

	
 
      - https://github.com/ansible-community/molecule-plugins/issues/239
 
      - https://github.com/ansible-community/molecule-plugins/pull/240
 
      - https://github.com/ansible-community/molecule-plugins/pull/260
 

	
 
   ::
 

	
 
      sed -i -e 's/ Hash\[/ **Hash[/' ~/.virtualenvs/majic-ansible-roles/lib/python3.9/site-packages/molecule/provisioner/ansible/plugins/libraries/molecule_vagrant.py
 
      sed -i -e 's/{{/{/g;s/}}/}/g' "$VIRTUAL_ENV/lib/python3."*"/site-packages/molecule_plugins/vagrant/driver.py"
 

	
 

	
 
Development conventions
 
-----------------------
 

	
 
In order to maintain consistency across different roles and documentation, this
 
section describes development conventions that should be followed while making
 
modifications.
 

	
 

	
 
Task specifications
 
~~~~~~~~~~~~~~~~~~~
 

	
 
When writing new and updating existing tasks, keep the following in mind:
 

	
 
- Quote sensibly. If specifying paths (for example ``src``, ``dest``, ``path``
 
  etc in various models), quote the string to make it stand-out better and to
 
  avoid breakages.
 
- Avoid usage of ``set_facts`` task when same functionality can be achieved via
 
  ``defaults/main.yml``.
 
- When specifying tasks, use the fully expanded form. Do not use single-line
 
  form with ``param=value``.
 
- When specifying ``command`` or ``shell`` tasks, in case a ``creates``
 
  parameter or such need to be used, specify them as part of task's ``args``
 
  parameter. E.g.::
 

	
 
    - name: Run command
 
      command: mycommand
 
      args:
 
        creates: "/etc/mycommand"
 

	
 
- When sepcifying tasks, keep the following ordering between different task
 
  parameters:
 

	
 
  - ``name``
 
  - Module and its parameters.
 
  - ``become``
 
  - ``become_user``
 
  - ``when``
 
  - ``with_items`` / ``with_dict`` / ``with_nested``
 
  - ``wait_for``
 
  - ``register``
 
  - ``changed_when``
 
  - ``failed_when``
 
  - ``no_log``
 
  - ``notify``
 
  - Task tags.
 

	
0 comments (0 inline, 0 general)