How to create Molecule and test Ansible tasks

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)

  1. cd ansible (to go to ansible folder)
  2. source bin/activate (to activate python env)
  1. pip install molecule anisble molecule[docker] docker Now, verify ansible and molecule version
  2. ansible –version
  3. molecule –version

run command :

  1. molecule init role
    -r my-ansible-molecule-role
  2. 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

  1. cd..(to go to parent folder)
    store yml files in tasks folder thatto be tested and linted by molecule

now just run command

  1. molecule test
  2. molecule destroy
  3. molecule converge