molecule

Molecule: Working with inventory

In this post, I will explain how to enable and manage inventory on the molecule. This is could be interesting when you have to parse some inventory within the role. 1) Edit the file: molecule/default/playbook.yml --- - name: Converge hosts: all roles: - role: my_role 2) Add the inventory configuration into the file molecule/default/molecule.yml --- dependency: name: galaxy driver: name: docker lint: name: yamllint platforms: - name: instance image: centos:7 provisioner: name: ansible lint: name: ansible-lint inventory: links: hosts: inventory.yml verifier:…

Keep reading

Molecule: Enabling roles dependencies

Molecule supports roles dependencies, however, we need to define the role-file parameter into the molecule.yml file to fetch the roles automatically. 1) Change the molecule.yml file according to the sample below. dependency: name: galaxy options: role-file: ${MOLECULE_SCENARIO_DIRECTORY}/requirements.yml2) Create a file called requirements.yml within molecule folder. --- # sample for springboot role. - src: git@gitlab.yourdomain.com:/ansible/roles/springboot.git scm: git3) Add the role into the playbook.yml file. - name: Converge hosts: all roles: - role: springboot - role: myrole…

Keep reading

Molecule: How to define the vault password file.

Sometimes we have to deal with encrypted values, such as passwords and sensitive information inside the role, therefore for that case, we have to define the vault configuration for the molecule. The configuration for ansible vault key password file is defined within the file $HOME/.config/molecule/config.yml provisioner: name: ansible config_options: defaults: vault_password_file: ${HOME}/.ansible/.vault…

Keep reading

Molecule: How to create a new role and change some default settings.

Creating new rolesRole with docker driver supportmolecule init role --role-name myrole --driver-name docker Role with vagrant driver supportmolecule init role --role-name myrole --driver-name vagrant Molecule settingsDocker (molecule.yml)Sample file with systemd suppport and port 8080 exposed. --- dependency: name: galaxy driver: name: docker lint: name: yamllint platforms: - name: motown2-proxy.molecule.local image: centos:7 privileged: true volume_mounts: - "/sys/fs/cgroup:/sys/fs/cgroup:rw" command: "/usr/sbin/init" privileged: true pre_build_image: true exposed_ports: - 8080/tcp published_ports: - 0.0.0.0:…

Keep reading

Molecule: How to use (part 2)

On this post, we gonna coverage some useful commands for molecule. Converge will execute the sequence necessary to converge the instances.$ molecule converge This action has cleanup and is not enabled by default. See the provisioner’s documentation for further details.$ molecule cleanup Destroy box/container.$ molecule destroy Runs the converge step a second time. If no tasks will be marked as changed the scenario will be considered idempotent.$ molecule idempotence Initialize a new role.$ molecule init role --role-name foo Execute lint tests$ molecule lint login into the box/container$…

Keep reading