Refactored docker inventory. (#15485)

This commit is contained in:
Chris Houseknecht 2016-04-22 15:19:12 -04:00 committed by Brian Coca
parent 4d36b3f7b6
commit 221b1c9fd0
2 changed files with 855 additions and 415 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,134 +1,61 @@
# This is the configuration file for the Ansible plugin for Docker inventory. # This is the configuration file for the Docker inventory script: docker_inventory.py.
# #
# Author: Paul Durivage <paul.durivage@gmail.com> # defaults: Defines a default connnection. Defaults will be taken from this and applied to any values not provided
# for a host defined in the hosts list.
# #
# Description: # hosts: If you wish to get inventory from more than one Docker daemon hosts, define a hosts list.
# This module queries local or remote Docker daemons and generates #
# inventory information. # For a host defined in defaults or hosts, you can provided the following attributes. The only required attribute is host.
# #
# This plugin does not support targeting of specific hosts using the --host # host:
# flag. Instead, it it queries the Docker API for each container, running # description: The URL or Unix socket path for the host.
# or not, and returns this data all once. # required: yes
# # tls:
# The plugin returns the following custom attributes on Docker containers: # description: Connect using https://
# docker_args # default: false
# docker_config # required: false
# docker_created # tls_verify:
# docker_driver # description: Connect using https:// and verify the host name matches the host name found in the certificate.
# docker_exec_driver # default: false
# docker_host_config # required: false
# docker_hostname_path # cert_path:
# docker_hosts_path # description: Path to the client's certificate .pem file.
# docker_id # default: null
# docker_image # required: false
# docker_name # cacert_path:
# docker_network_settings # description: Path to the client's Certificate Authority .pem file.
# docker_path # default: null
# docker_resolv_conf_path # required: false
# docker_state # key_path:
# docker_volumes # description: Path to the client's encryption key .pem file
# docker_volumes_rw # default: null
# # required: false
# Requirements: # version:
# The docker-py module: https://github.com/dotcloud/docker-py # description: The API version the client will use.
# # required: false
# Notes: # default: will be supplied by the docker-py module.
# A config file can be used to configure this inventory module, and there # timeout:
# are several environment variables that can be set to modify the behavior # description: The amount of time in seconds to wait on an API response.
# of the plugin at runtime: # required: false
# DOCKER_CONFIG_FILE # default: will be supplied by the docker-py module.
# DOCKER_HOST # default_ip:
# DOCKER_VERSION # description: The IP address to assign to ansilbe_host when the container's SSH port is mappped to 0.0.0.0
# DOCKER_TIMEOUT # required: false
# DOCKER_PRIVATE_SSH_PORT # default: 1267.0.0.1
# DOCKER_DEFAULT_IP # private_ssh_port:
# # description: The port containers use for SSH
# Environment Variables: # required: false
# environment variable: DOCKER_CONFIG_FILE # default: 22
# description: #
# - A path to a Docker inventory hosts/defaults file in YAML format
# - A sample file has been provided, colocated with the inventory
# file called 'docker.yml'
# required: false
# default: Uses docker.docker.Client constructor defaults
# environment variable: DOCKER_HOST
# description:
# - The socket on which to connect to a Docker daemon API
# required: false
# default: Uses docker.docker.Client constructor defaults
# environment variable: DOCKER_VERSION
# description:
# - Version of the Docker API to use
# default: Uses docker.docker.Client constructor defaults
# required: false
# environment variable: DOCKER_TIMEOUT
# description:
# - Timeout in seconds for connections to Docker daemon API
# default: Uses docker.docker.Client constructor defaults
# required: false
# environment variable: DOCKER_PRIVATE_SSH_PORT
# description:
# - The private port (container port) on which SSH is listening
# for connections
# default: 22
# required: false
# environment variable: DOCKER_DEFAULT_IP
# description:
# - This environment variable overrides the container SSH connection
# IP address (aka, 'ansible_ssh_host')
#
# This option allows one to override the ansible_ssh_host whenever
# Docker has exercised its default behavior of binding private ports
# to all interfaces of the Docker host. This behavior, when dealing
# with remote Docker hosts, does not allow Ansible to determine
# a proper host IP address on which to connect via SSH to containers.
# By default, this inventory module assumes all 0.0.0.0-exposed
# ports to be bound to localhost:<port>. To override this
# behavior, for example, to bind a container's SSH port to the public
# interface of its host, one must manually set this IP.
#
# It is preferable to begin to launch Docker containers with
# ports exposed on publicly accessible IP addresses, particularly
# if the containers are to be targeted by Ansible for remote
# configuration, not accessible via localhost SSH connections.
#
# Docker containers can be explicitly exposed on IP addresses by
# a) starting the daemon with the --ip argument
# b) running containers with the -P/--publish ip::containerPort
# argument
# default: 127.0.0.1 if port exposed on 0.0.0.0 by Docker
# required: false
#
# Examples:
# Use the config file:
# DOCKER_CONFIG_FILE=./docker.yml docker.py --list
#
# Connect to docker instance on localhost port 4243
# DOCKER_HOST=tcp://localhost:4243 docker.py --list
#
# Any container's ssh port exposed on 0.0.0.0 will mapped to
# another IP address (where Ansible will attempt to connect via SSH)
# DOCKER_DEFAULT_IP=1.2.3.4 docker.py --list
#
#
#
# The Docker inventory plugin provides several environment variables that
# may be overridden here. This configuration file always takes precedence
# over environment variables.
#
# Variable precedence is: hosts > defaults > environment
--- #defaults:
defaults: # host: unix:///var/run/docker.sock
host: unix:///var/run/docker.sock # private_ssh_port: 22
version: 1.9 # default_ip: 127.0.0.1
timeout: 60
private_ssh_port: 22 #hosts:
default_ip: 127.0.0.1
hosts:
# - host: tcp://10.45.5.16:4243 # - host: tcp://10.45.5.16:4243
# version: 1.9
# timeout: 60
# private_ssh_port: 2022 # private_ssh_port: 2022
# default_ip: 172.16.3.45 # default_ip: 172.16.3.45
# - host: tcp://localhost:4243 # - host: tcp://localhost:4243
# private_ssh_port: 2029