docker_machine – Docker Machine inventory source
docker_machine – Docker Machine inventory source
Synopsis
- Get inventory hosts from Docker Machine.
- Uses a YAML configuration file that ends with docker_machine.(yml|yaml).
- The plugin sets standard host variables
ansible_host
,ansible_port
,ansible_user
andansible_ssh_private_key
. - The plugin stores the Docker Machine ‘env’ output variables in dm_ prefixed host variables.
Requirements
The below requirements are needed on the local master node that executes this inventory.
Parameters
Parameter | Choices/Defaults | Configuration | Comments |
---|---|---|---|
compose dictionary |
Default: {} |
Create vars from jinja2 expressions. | |
daemon_env string |
|
Whether docker daemon connection environment variables should be fetched, and how to behave if they cannot be fetched. With With With If fetched successfully, the variables will be prefixed with dm_ and stored as host variables. | |
groups dictionary |
Default: {} |
Add hosts to group based on Jinja2 conditionals. | |
keyed_groups list |
Default: [] |
Add hosts to group based on the values of a variable. | |
plugin - / required |
|
token that ensures this is a source file for the | |
running_required boolean |
|
when true, hosts which Docker Machine indicates are in a state other than | |
strict boolean |
|
If Since it is possible to use facts in the expressions they might not always be available and we ignore those errors by default. | |
verbose_output boolean |
|
when true, include all available nodes metadata (e.g. Image, Region, Size) as a JSON object named |
Examples
# Minimal example
plugin: docker_machine
# Example using constructed features to create a group per Docker Machine driver
# (https://docs.docker.com/machine/drivers/), e.g.:
# $ docker-machine create --driver digitalocean ... mymachine
# $ ansible-inventory -i ./path/to/docker-machine.yml --host=mymachine
# {
# ...
# "digitalocean": {
# "hosts": [
# "mymachine"
# ]
# ...
# }
strict: no
keyed_groups:
- separator: ''
key: docker_machine_node_attributes.DriverName
# Example grouping hosts by Digital Machine tag
strict: no
keyed_groups:
- prefix: tag
key: 'dm_tags'
# Example using compose to override the default SSH behaviour of asking the user to accept the remote host key
compose:
ansible_ssh_common_args: '"-o StrictHostKeyChecking=accept-new"'
Status
- This inventory is not guaranteed to have a backwards compatible interface. [preview]
- This inventory is maintained by the Ansible Community. [community]
Authors
- Ximon Eighteen (@ximon18)
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/plugins/inventory/docker_machine.html