/ansible_role_skeleton

Skeleton project for roles.

Primary LanguageRuby

name about comments feedback
ansible-galaxy-role-skeleton
Project template for Ansible Galaxy Roles.
true
true

Ansible Galaxy Role Skeleton

Description

Ansible Galaxy Role Skeleton is used to quickly create new Ansible Galaxy roles.

Requirements

  • Ansible 2.9+
  • Python 3.4+

Usage

Role Names

Roles long name

Used as the roles repository name in cases where you have a single role per repository.

ansible-role-%{specific_role}
Roles short name

Used when creating a new role using this project.:

%{specific_role}

Setup

Clone project fork

Clone your customised personal or business fork to your Ansible projects directory

mkdir ~/projects
cd ~/projects
git clone git@gitlab.cherubits.hu:oss/ansible-galaxy-roles/ansible-galaxy-role-skeleton.git
export ALTERNATIVE_ROLE_SKELETON_PATH=~/projects/ansible-galaxy-role-skeleton

Create your role

Syntax example
ansible-galaxy init --role-skeleton=ALTERNATIVE_ROLE_SKELETON_PATH %{specific_role}

Real world usage examples:

To create a new role
mkdir -p ~/projects/ansible-%{specific_project}-playbook/roles
cd ~/projects/ansible-%{specific_project}-playbook/roles
ansible-galaxy init --role-skeleton=~/projects/ansible-galaxy-role-skeleton/skeleton %{specific_role} -vvv
To overwrite an existing role
cd ~/projects/ansible-galaxy-role-skeleton/roles
ansible-galaxy init --role-skeleton=~/projects/ansible-galaxy-role-skeleton/skeleton -f %{short-name-of-existing-role} -vvv
Set up Molecule environment
virtualenv --python=/usr/bin/python3.7 .env
source .env/bin/activate
pip install molecule docker molecule[lint] molecule[docker]
Set up your default Molecule scenario
molecule init scenario -s default -d lxd -r %{short-name-of-role}

Troubleshooting

Molecule

pytest bug: Fix for error"AttributeError: 'Config' object has no attribute 'cache'

touch molecule/default/pytest.ini" like this one.
[pytest]
addopts = -p no:cacheprovider -p no:stepwise

Authors

License

Apache-2.0