For Ansible Molecule setup the following commands needs to be executed:
1.pip install
2.virtualenv ansible(will create virtual env
for python with ansible name)
- cd ansible (to go to ansible folder)
- source bin/activate (to activate python env)
- pip install molecule anisble molecule[docker] docker Now, verify ansible and molecule version
- ansible –version
- molecule –version
run command :
- molecule init role
-r my-ansible-molecule-role - cd my-ansible-molecule-role
folder “my-ansible-molecule-role”
will have following folders
1.defaults
2.handlers
3.meta
4.molecule
5.tasks
6.vars
except molecule, all folders have main. yml
molecule folder has
1.default > task folder
2.molecule.yml
3.playbook. yml
4.Dockerfile
now, run command
- cd..(to go to parent folder)
store yml files in tasks folder thatto be tested and linted by molecule
now just run command
- molecule test
- molecule destroy
- molecule converge