Testing

Test Ansible with Vagrant

Install Vagrant

You need to install Vagrant. See the following links for details:

In short, you can install Vagrant on macOS with Homebrew (and Homebrew Cask):

$ brew cask install virtualbox
$ brew cask install vagrant

You need Ansible locally installed:

$ conda install -c conda-forge ansible
OR
$ brew install ansible # macOS only

Install Ansible roles:

$ ansible-galaxy install -p roles -r requirements.yml --ignore-errors

Run Vagrant

Use Vagrant config:

$ ln -s etc/sample-vagrant.yml custom.yml

Initial setup:

$ vagrant up

Provision with Ansible again:

$ vagrant provision

Login with SSH:

$ vagrant ssh

Run Ansible manually:

$ ansible-playbook -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory playbook.yml

Remove VMs:

$ vagrant destroy -f

Try Twitcher

Run a Twitcher request:

http://192.168.128.100:8000/

Try other OS

Configure Vagrantfile with another Bento Box:

twitcher.vm.box = "bento/ubuntu-18.04"

Alternative: use Vagrant without provisioning

Use Vagrant without provisioning and just to setup a new VM:

$ vagrant destroy -f  # remove previous VM
$ vagrant up --no-provision  # setup new VM
$ vagrant ssh  # ssh into VM

Run the installation manually now:

vagrant> sudo yum install git
vagrant> git clone https://github.com/bird-house/ansible-twitcher-playbook.git
vagrant> cd ansible-twitcher-playbook
vagrant> ./bootstrap.sh
vagrant> ln -s etc/sample-vagrant.yml custom.yml
vagrant> ansible-galaxy install -r requirements.yml
vagrant> ansible-playbook -c local playbook.yml

Test Ansible in a Docker container

Warning

The Nignx and Supervisor services are not automatically started in Docker. You need to do this manually. This will be fixed in a later release.

Start an Ubuntu Docker container with mounted local source:

$ ./run_docker.sh

Update the configuration:

$ ln -s etc/sample-emu.yml custom.yml

Run the Ansible deployment:

$ ./bootstrap.sh
$ make play

Check if application is started (Supervisor):

$ service supervisord status

Check also nginx … might not start automatically in Docker:

$ service nginx status
$ service nginx start # if not already started

Run a Twitcher request:

http://192.168.128.100:8000/

Check log files:

$ supervisorctl tail -f twitcher