Ansible

LXDock provides built-in support for Ansible provisioning.

Requirements

Ansible v2.0+

Usage

Just append an ansible provisioning operation to your LXDock file as follows:

name: myproject
image: ubuntu/xenial

provisioning:
  - type: ansible
    playbook: deploy/site.yml

Required options

playbook

The playbook option allows you to define the path to your Ansible playbook you want to run when your containers are provisioned.

Optional options

ask_vault_pass

You can use this option to force the use of the --ask-vault-pass flag when the ansible-playbook command is executed during the provisioning workflow. Here is an example:

[...]
provisioning:
  - type: ansible
    playbook: deploy/site.yml
    ask_vault_pass: yes

vault_password_file

You can use this option to specify the path toward the vault password file you want to use when the ansible-playbook command is executed. Here is an example:

[...]
provisioning:
  - type: ansible
    playbook: deploy/site.yml
    vault_password_file: secrets/vaultpass

groups

Use this option to add groups to the inventory that is dynamically generated by the provisioner. This option is a hash of lists of container names. Example:

[...]
provisioning:
  - type: ansible
    playbook: deploy/site.yml
    groups:
      group1:
        - container1
        - container2
      group2:
        - container2

lxd_transport

If this boolean option is set to true, we will use ansible’s lxd transport instead of the ssh one, thus bypassing ssh entirely and using lxc exec directly.

It should be noted that while very cool-sounding, this transport method comes with a couple of drawbacks due to its incomplete support in Ansible. For example, synchronize actions don’t work.