Skip to content

glacion/molecule_template

Repository files navigation

Molecule Template

A template for using molecule to develop ansible roles. To be an example, this role installs itself.

Features

Requirements

  • python3
  • qemu-system-x86_64, qemu-system-aarch64, mkisofs, qemu-img for running molecule instances, see molecule-qemu for details. Additionally see workflow for setting up for ubuntu 22.04.

Setting up

Replace my_role with your desired role name and my_username with your GitHub username.

  • Retrieve this repository(or fork it)

    curl -LO https://github.com/glacion/molecule_template/archive/refs/heads/main.tar.gz
    tar -xvf main.tar.gz --strip-components=1 --one-top-level=my_role
  • Initialize git, python, and pre-commit

    git init
    python3 -m venv .venv
    source .venv/bin/activate
    pip install .
    pre-commit install
  • Make necessary metadata changes

    • Author information in README, galaxy metadata
    • namespace field in galaxy metadata to your github username.
    • include_role in converge playbook playbook as my_username/my_role
  • Run a full cycle of molecule

    molecule test
  • Create a repository on GitHub

  • Retrieve your API key from galaxy

  • Save this API key as a Repository secret in your repository under the name of GALAXY_API_KEY settings

  • Push your repository

    git add .
    git commit -m 'initial commit'
    git tag 0.0.0
    git remote add origin [email protected]/my_username/my_role
    git push -u origin main --tags

If everything is set up correctly, GitHub Actions will run tests and publish your role to galaxy. In order to release a new version, create a new tag like git tag 0.1.0 and push with git push --tags. This will additionally create a new release in GitHub with the changes from the previous tag, consider using conventional commits for a better changelog.

License

BSD

Author Information

Can Güvendiren [email protected]