Create and testing ansible role using Molecule and serverspec
- virtualbox
- vagrant
- python pip
- ansible
- serverspec (verifier)
$ apt-get update
$ apt-get install gcc python-pip python-vagrant libssl-dev libffi-dev
$ pip install ansible
$ pip install docker-py
$ pip install molecule
$ molecule --help
| to show others command
$ molecule init --role nginx --verifier serverspec
| create new rule from scratch using serverspec for verifier
$ bundle install
We using debian jessie64, so please edit platform section in molecule.yml
platforms:
- name: debian/jessie64
box: debian/jessie64
box_url: https://vagrantcloud.com/debian/boxes/jessie64/versions/8.7.0/providers/virtualbox.box
$ molecule test --destroy=always
| start testing
More about serverspec
testing can be found at serverspec.org
$ ssh ubuntu@127.0.0.1 -p 2222 -i $(pwd)/nginx/.vagrant/machines/nginx/virtualbox/private_key
hosts file need create manual, and make sure public key configured
$ ansible-playbook nginx/playbook.yml -i nginx/hosts --private-key ~/.ssh/id_rsa --user ubuntu
$ ansible-playbook nginx/playbook.yml -i nginx/environment/staging --private-key ~/.ssh/id_rsa --user ubuntu
- https://youtu.be/LPn2yEiloIs || Deploy to server Digital Ocean with ansible-playbook
- https://youtu.be/TVTxw7YGmq8 || Testing Provision Role with Ansible and Molecule