I use Ansible to deploy my containers for production. During development, I would like Ansible to deploy all containers on my localhost instead of production servers.
Production servers run on Ubuntu, localhost - OS X with boot2docker.
I have 2 inventory files, production and localhost. My structure looks like this:
.
|--inventories
| |localhost
| |production
|
|--group_vars
| |all
| |localhost
| |production
|
|--roles
| |--web
| |--tasks
|main.yml
|
|web.yml
web.yml simply defines a group of hosts and assigns a role web.
/roles/web/tasks/main.yml is as follows:
- name: Run web container
docker:
name: web
image: some/image
state: reloaded
...
tls_hostname: boot2docker
volumes:
- "/data/db:/data/db"
env:
...
tags:
- ...
I need to install tls_hostnameconditionally only if the localhost inventory was used; Similarly, I want to install the volume only if a production inventory file has been used.
Ansible - , , ? ; tls_hostname ( )