Commit Graph

403 Commits (c7eeb37f64328295a672d8b0a098ff89bfe7d016)

Author SHA1 Message Date
chouseknecht bc665fca9c Fix for issue #3775 - env config comparison 2016-12-08 11:24:32 -05:00
chouseknecht 65e71d8960 Update restart_policy doc strings. 2016-12-08 11:24:32 -05:00
chouseknecht b5666c0f1c Fix restart_poicy 2016-12-08 11:24:32 -05:00
chouseknecht 8f9ef1213d Fix for #3783 - command returns not found or does not exist. 2016-12-08 11:24:32 -05:00
Dan Schmidt c8ec843ac2 Fix "ansbile_facts" typo in docker_container module 2016-12-08 11:24:32 -05:00
chouseknecht d0da544aef Fix for issue 3740. Make docker_service more resilient when targeting older API versions. 2016-12-08 11:24:31 -05:00
Brian Coca f6690828af deprecated docker (#3710)
* deprecated docker

* updated formatting
2016-12-08 11:24:31 -05:00
chouseknecht afc8c42e57 Fixed the URL in description. It's now valid Yaml. 2016-12-08 11:24:29 -05:00
chouseknecht f14d675d2a Remove the U(). 2016-12-08 11:24:29 -05:00
chouseknecht 176363052f Uppercase 2016-12-08 11:24:29 -05:00
chouseknecht 2b4ee0c19d Make the new bits a NOTE 2016-12-08 11:24:29 -05:00
chouseknecht 4ac31f1e8d Where to get the full docker picture. 2016-12-08 11:24:29 -05:00
Shubham 8a6237955d remove module argument, fix #3682 (#3683) 2016-12-08 11:24:29 -05:00
Matt Martz 190f24f30e Revert "Fix doc strings spacing."
This reverts commit 127d518011224289f7917fd3b2ec8ddf73c7dd17.
2016-12-08 11:24:28 -05:00
chouseknecht 26392077c0 Fix doc strings spacing. 2016-12-08 11:24:28 -05:00
chouseknecht 8e6d00f28e Fix doc strings. Missing requirements and doc fragment reference. 2016-12-08 11:24:28 -05:00
chouseknecht d5b82d67b8 Fail gracefully when build path is not found. 2016-12-08 11:24:27 -05:00
chouseknecht 9a021b4181 Fixed files/project_files naming. Correct name is files. 2016-12-08 11:24:27 -05:00
chouseknecht 5837f744e0 Flip version added back to 2.2 to make tests pass. 2016-12-08 11:24:27 -05:00
chouseknecht 018c2f8f73 Moving version added to 2.1 2016-12-08 11:24:27 -05:00
chouseknecht e8d49261e3 Added actions to RETURN docs. Show actions when debug or check mode. 2016-12-08 11:24:27 -05:00
chouseknecht 2860f57551 Removed use of --diff. Replaced 'diff' in output with 'actions'. Only show 'actions' in output if debug true. 2016-12-08 11:24:27 -05:00
chouseknecht be24f83a41 Removed fail method. Combined recreate and force_recreate params. 2016-12-08 11:24:27 -05:00
chouseknecht 50ef604713 Adding docker_service 2016-12-08 11:24:27 -05:00
Chris Houseknecht 8ba5cc4392 Fixed parameters passing in container_create method. (#3618) 2016-12-08 11:24:27 -05:00
Brian Coca c03e1bd2d5 fixed documentation and arg issues 2016-12-08 11:24:26 -05:00
Toshio Kuratomi ed932a53cd Fix documentation 2016-12-08 11:24:26 -05:00
John R Barker d13046a905 ansible-validate-modules part 4: Enable check on ansible-modules-core (#3526)
* Call ansible-validate-modules

* Correct quotes + add newline
2016-12-08 11:24:26 -05:00
chouseknecht 1d6517489b Add doc string for container_limits. Fixed push fail message. Use path type. 2016-12-08 11:24:25 -05:00
Chris Houseknecht b4caa29b00 Adding docker_image_facts (#3493)
* Adding docker_image_facts

* Fix github credentials
2016-12-08 11:24:25 -05:00
Chris Houseknecht bc3391f1f9 Adding docker_container (#3495)
* Adding docker_container

* If state absent, stop the container before attempting to remove. Fixed status running check.

* If container absent, stop before removing. Fix container status check.
2016-12-08 11:24:25 -05:00
Toshio Kuratomi 371d7ec73d Fix docs building 2016-12-08 11:24:25 -05:00
Toshio Kuratomi 5f0dc2b90f Some beginning python3 porting for modules which have unittests 2016-12-08 11:24:24 -05:00
chouseknecht a67e9f3122 Updated version_added on options to reflect options added for 2.1. 2016-12-08 11:24:24 -05:00
chouseknecht f2e7f1935b Clean up and fixes post API version 1.20 testing. 2016-12-08 11:24:24 -05:00
chouseknecht 6f122bdc88 Fix github credentials 2016-12-08 11:24:24 -05:00
chouseknecht f257fb3efa Fix unfriendly exeption handling. 2016-12-08 11:24:23 -05:00
chouseknecht 6aa76b835a Updater per PR comments 2016-12-08 11:24:23 -05:00
chouseknecht fd0554c67e Adding refactored docker_image module. 2016-12-08 11:24:23 -05:00
Chris Houseknecht c5b7e456bd Adding docker_login (#3494)
* Adding docker_login

* Set correct version_added.

* Fix github credentials
2016-12-08 11:24:23 -05:00
Darek Kaczyński 08ad68984c Fix for 'cannot unmarshal array into Go value of type string' error about HostConfig Binds (#3496) 2016-12-08 11:24:20 -05:00
ThomasSteinbach a90fd67c7e docker: fix type issue (#3491)
* fix type issue

* fix type issue for 'volumes-from'
2016-12-08 11:24:20 -05:00
Alexey Wasilyev 4971c7fe82 docker: support polling image by digest (#2932) 2016-12-08 11:24:18 -05:00
Fabian von Feilitzsch 32c744e82a make binds a list instead of a dict (to prevent overwriting when copying the same file to two places) (#2294) 2016-12-08 11:24:17 -05:00
Ash Wilson 6e2f724919 Remove myself from the docker module maintainers
Apologies, but I no longer use this module day-to-day myself, and I don't have the bandwidth right now to effectively triage changes in any kind of timely fashion.
2016-12-08 11:24:14 -05:00
Michael Scherer daddfb490b Improve/fix type checking for docker module
tls_* point to files, so should be type=path
count is a int, so tag it as such and avoid converting later
password should be tagged as no_log
2016-12-08 11:24:14 -05:00
Victor Beresnev 2e94affde6 If cmd and entrypoint not set, don't match them
Hello!
I wanted stop the containers matched only by image name, but can't do this, if I not set cmd in playbook.
This behavior confused me.

If cmd or entrypoint is defined for running container, but not defined in playbook, makes matching behavior as this sample:
https://github.com/ansible/ansible-modules-core/blob/devel/cloud/docker/docker.py#L463
2016-12-08 11:24:14 -05:00
Yannig Perré 72d3aab736 Add an example of extra_hosts option. 2016-12-08 11:24:13 -05:00
Schlueter 734811910e Add missing quote in docker documentation 2016-12-08 11:24:11 -05:00
Andrey Gubarev edde3b49cf update docker_image's path param type to 'path'. Fixes #3175 2016-12-08 11:24:10 -05:00
Tobias Gesellchen db14b544a5 add `env_file` support (original code from @vpetersson) 2016-12-08 11:24:09 -05:00
Konstantin Suvorov 762bd3a801 Fix docker container restart
restart_containers(containers.running) may try to restart containers
that are deleted when looping through get_differing_containers()
fix this by refreshing list after first loop
2016-12-08 11:24:07 -05:00
Daan Oosterveld 6b4fbe62de Adds ulimit to the docker module
The ulimit will be specified as a list and separated by colons. The
hard limit is optional, in which case it is equal to the soft limit.

The ulimits are compared to the ulimits of the container and added
or adjusted accordingly on by a reload.

The module ensures that ulimits are available in the capabilities
iff ulimits is passes as a parameter.
2016-12-08 11:24:07 -05:00
Alexey Wasilyev f8adc99196 docker: fix failing in case of empty image tag 2016-12-08 11:24:02 -05:00
Brian Coca b25c2a4261 added note about awslogs version added 2016-12-08 11:23:59 -05:00
jefferson fermo 9d9daeb73c add awslog option in docker log driver. this option is available starting with ansible 2.1 2016-12-08 11:23:59 -05:00
Alexey Wasilyev 4d30ae313d Add cpu_shares option for docker module 2016-12-08 11:23:57 -05:00
Will Rouesnel b565da78b3 docker: Fix state=reloaded to detect default LoggingDriver for docker
Previously the logging module hard coded the default logging driver. This means
if the docker daemon is started with a different logging driver, the ansible
module would continually restart it when run.

This fix adds a call to docker.Client.info(), which is inspected if a logging
driver is not supplied in the playbook, and the container only restarted if
the logging driver applied differs from the configured default.

In usage, this has solved issues with using alternative logging drivers.
2016-12-08 11:23:57 -05:00
Brian Coca 0ca9356675 added versions note in description for new choice 2016-12-08 11:23:56 -05:00
Pavel Derendyaev 3129154a2a Add "timeout" option to Docker module 2016-12-08 11:23:56 -05:00
sebi 76af56eaca added unless stopped option 2016-12-08 11:23:55 -05:00
Manuel Tiago Pereira 057cbacf8a Add support for legacy registries to pull_image().
Since we now have several exceptions to the assumption that the
result of the pull would be on the last status line returned by
docker-py's pull(), I've changed the function so that it looks
through the status lines and returns what if finds on it.
Despite the repeated `break`s, the code seems simpler and a little
more coherent like this. From what I've checked using
`https://github.com/jlafon/ansible-profile`, the execution time is
mostly the same.
2016-12-08 11:23:54 -05:00
Toshio Kuratomi 4fa9de5af3 entrypoint feature added in 2.1 2016-12-08 11:23:54 -05:00
Toshio Kuratomi eb65f819f5 labels is actually not aded in 1.9.4 but in 2.1 2016-12-08 11:23:54 -05:00
Andrew Pashkin c811a3f4bc Add 'entrypoint' parameter to Docker module 2016-12-08 11:23:54 -05:00
Andrew Pashkin 8342397427 Harden matching running containers by "command" in the Docker module
Before this patch:

  - Command was matched if 'Command' field of docker-py
    representation of Docker container ends with 'command' passed
    to Ansible docker module by user.
  - That can give false positives and false negatives.
  - For example:
      a) If 'command' was set up with more than one spaces,
         like 'command=sleep  123', it would be never matched again
         with a container(s) launched by this task.
         Because after launching, command would be normalized and
         appear, in docker-py API call, just as 'sleep 123' - with one
         space. This is false negative case.
      b) If 'entrypoint + command = command', for example
         'sleep + 123 = sleep 123', module would give false positive
         match.

This patch fixes it, by making matching more explicit - against
'Config'->Cmd' field of 'docker inspect' output, provided by docker-py
API and with proper normalization of user input by splitting it to
tokens with 'shlex.split()'.
2016-12-08 11:23:54 -05:00
Omar Khan 369fe78c60 Add stop_timeout option to docker module 2016-12-08 11:23:54 -05:00
Toshio Kuratomi a708ad65c4 Add version_added to documentation 2016-12-08 11:23:54 -05:00
Joe Quadrino b6e2b2dce1 add devices parameter for docker module 2016-12-08 11:23:54 -05:00
Yann Hamon 1faf8dd5c2 Docker module: restarted should update the container when necessary 2016-12-08 11:23:54 -05:00
Brian Coca b4f87ac7fe made note that Z/z are only 2.1 options 2016-12-08 11:23:52 -05:00
Steve Spencer d4aca8eacc Sync up with allowable docker volume mounting modes 2016-12-08 11:23:52 -05:00
Steve Spencer 769d7db1d0 Add support for mounting host volumes with Z and z options 2016-12-08 11:23:52 -05:00
Leonty 22648e88cd Corrected misspelling in the 'labels' docker parameter documentation. 2016-12-08 11:23:52 -05:00
Aaron Boushley 876bdb62e1 Fix issue with comparing versions improperly.
This allows old versions of docker api to function.
2016-12-08 11:23:51 -05:00
Leonty 8638d9d26c Support 'labels' parameter for docker. 2016-12-08 11:23:51 -05:00
Toshio Kuratomi 6f214bccca Add zfil as an owner of the docker module 2016-12-08 11:23:47 -05:00
Toshio Kuratomi edaa4c3f32 Add a new contributor as a maintainer of the docker module 2016-12-08 11:23:47 -05:00
Philippe Jandot 5b7d72e4ef fix regression introduced by f38186ce8b49ea98e29241712da45917a3154e73, and propose a fix for docker facts 2016-12-08 11:23:46 -05:00
Toshio Kuratomi 2619ec5321 Fix issues version_added and chaged => changed typo 2016-12-08 11:23:45 -05:00
Michael Schuett e61a4f2fb5 Fix message
Previous fix did not actual work. This fix does however.
2016-12-08 11:23:45 -05:00
Michael Schuett 0cefc2358b Handle connection error
Try and help when mac hits a connection error.
2016-12-08 11:23:45 -05:00
Michael Schuett 536bfb521a remove .geturl()
Can't call geturl on a string.
2016-12-08 11:23:45 -05:00
Michael Schuett 6ff693f975 Remove faulty logic
Update logic after splitting the error into two separate messages.
2016-12-08 11:23:45 -05:00
Michael Schuett 5a20bb473b Documentation Fix
Updated documentation to match current module state.
2016-12-08 11:23:44 -05:00
Michael Schuett 8d1f8dacba Improve Message
Give user a course of action in the case where the suggestions do not
work. This will hopefully allow us to work through any further issues
much faster.
2016-12-08 11:23:44 -05:00
Michael Schuett 53294dbaaa Improve Error Reporting
This will hopefully help mac users be able to quickly resolve any issues
they may find when trying to use this module.
2016-12-08 11:23:44 -05:00
Michael Schuett 75a61ae6e1 docker_image TLS
Check commit enables using tls when using the docker_image module. It
also removes the default for docker_url which doesn't allow us to check
for DOCKER_HOST which is a more sane default. This allows you to use
docker_image on OSX but more documentation is needed.
2016-12-08 11:23:44 -05:00
Adam Williamson 83d941da27 fix #2043: strip empty dict from end of 'pull' stream
When pulling an image using Docker 1.8, it seems the output
JSON stream has an empty dict at the very end. This causes
ansible to fail when pulling an image, as it's expecting a
status message in that dict which it uses to determine whether
it had to download the image or not. As a bit of an ugly hack
for that which remains backward compatible, try the last item
in the stream, and if it's an empty dict, take the last-but-one
item instead.

The strip() is needed as the exact value appears to be '{}/r/n';
we could just match that, but it seems like the kind of thing
where maybe it'd happen to just be '{}/n' or '{}' or something
in some cases, so let's just use strip() in case.
2016-12-08 11:23:40 -05:00
Sam Yaple a4a4b6f423 Catch the second occurance of ExposedPorts as well 2016-12-08 11:23:40 -05:00
Sam Yaple 463fb5a058 Don't assume ExposedPorts exists (bug #2257)
A recent change [1] in docker between v1.8.2 and v1.8.3 changed what
is returned in the json when inspecting an image. Five variables which
could have been expected before will now be omited when empty. Only
one of those variables is being addressed in the docker, ExposedPorts.

Unfortunately there was also no API version change on this so this
can't be easily corrected with pinning the API to the older version.

This does a get() which will return None if the variable is not in the
dict formed from the json that was returned. Everything else works the
same way.

[1] 9098628b29
2016-12-08 11:23:40 -05:00
Colin Hutchinson d70c33f932 make a text link into a actual hyperlink
the text link doesn't fit on some screen resolutions. Making it into sphinx hyperlink will solve that
2016-12-08 11:23:39 -05:00
justnom b724bf8f1c Adding additional Docker log drivers.
Adding additional `log_driver` choices:
* journald
* gelf
* fluentd

Compatible with Docker version >= 1.8.0
2016-12-08 11:23:38 -05:00
David Dyball cdff62643b Updated PR based on comments 2016-12-08 11:23:35 -05:00
Toshio Kuratomi b3262479e9 Fix read-only usage to depend on the docker-py and docker server version 2016-12-08 11:23:34 -05:00
Toshio Kuratomi 13ab511642 We had two separate methods trying to do the same thing but neither one was complete. This merges them so that all of the options get parsed and applied. 2016-12-08 11:23:34 -05:00
Omri Iluz 1c6acc3e8f No need for .keys on volumes list
Since c3f92cca21 changed "volumes" to be a list instead of a dictionary, we don't need (and cannot) .keys when appending to set.
Reported as bug #1957
2016-12-08 11:23:33 -05:00
Ilya Epifanov cbbf284a74 fixed memory_limit for docker api version >= 1.19 2016-12-08 11:23:32 -05:00
sebi ce1afd01e0 mem_limit client version check 2016-12-08 11:23:30 -05:00
Toshio Kuratomi 98e600961f Set a default value for DEFAULT_DOCKER_API_VERSION so we can create the AnsibleModule without docker-py 2016-12-08 11:23:29 -05:00
Brian Coca 9241955076 added missing version_Added to extra_hosts fixes #1843 2016-12-08 11:23:27 -05:00
Micheal Waltz 5f0d989973 Fix incorrect var name for api_version 2016-12-08 11:23:27 -05:00
Brian Coca 92dfe33021 defined DEFAULT_DOCKER_API_VERSION to avoid it erroring out before we send the message that docker.py is missing 2016-12-08 11:23:26 -05:00
Micheal Waltz 950701ba3e Use a if/else instead to avoid loading possibly invalid values for Memory 2016-12-08 11:23:25 -05:00
Micheal Waltz af5e402b87 Set the API version when checking differences in containers and use this to determine the location of the Memory value depending on the version used.
In v1.18 and earlier it was ['Config']['Memory'], but in v1.19 it
changed to ['HostConfig']['Memory'].
2016-12-08 11:23:25 -05:00
Micheal Waltz f36666ae1d Use proper HostConfig element which contians the proper Memory value - fixes #1766 2016-12-08 11:23:25 -05:00
Lars Kellogg-Stedman 3d79d96a1b restore mem_limit
mem_limit got lost in the #1744; this restores it.  Thanks to @dgromov
for the report.
2016-12-08 11:23:25 -05:00
Lars Kellogg-Stedman 562341049e docker: fix parsing of docker __version__ string
If `docker.__version__` contains non-digit characters, such as:

    >>> import docker
    >>> docker.__version__
    '1.4.0-dev'

Then `get_docker_py_versioninfo` will fail with:

    ValueError: invalid literal for int() with base 10: '0-de'

This patch corrects the parsing of the version string so that
`get_docker_py_versioninfo` in this example would return:

    (1, 4, 0, '-dev')
2016-12-08 11:23:25 -05:00
Johan Haals 6a9a4d905a ensures API compatibility for read_only containers 2016-12-08 11:23:24 -05:00
Johan Haals c88feaff7e changed version_added for read_only param
this feature will be released in 2.0
2016-12-08 11:23:24 -05:00
Johan Haals 6231a9d52f Added support for --read-only Docker containers
Adds support for mounting the container's root filesystem as read only.
2016-12-08 11:23:24 -05:00
Christian Hammerl 426ec96ea5 docker: add support to add/drop capabilities 2016-12-08 11:23:23 -05:00
Brian Coca 1976ed931a minor doc fixes to docker_user 2016-12-08 11:23:23 -05:00
Brian Coca b62a6f01ab added version_Added for new signal option in docker module 2016-12-08 11:23:23 -05:00
Brian Coca 07fedaa03a corrected v ersion added 2016-12-08 11:23:23 -05:00
Daniel Kerwin 277065a302 Too late for 1.8 2016-12-08 11:23:23 -05:00
Daniel Kerwin 3a68101fa3 Switch to _cap_ver_req and add cpu_set to create_containers 2016-12-08 11:23:23 -05:00
nemunaire f37510ebaa Add optional signal parameter when killing docker container 2016-12-08 11:23:23 -05:00
Daniel Kerwin 5b029bde98 Renamed to cpu_set 2016-12-08 11:23:22 -05:00
Daniel Kerwin 940baa92a6 Add support for cpusets. Requires docker-py >= 0.6.0 2016-12-08 11:23:22 -05:00
Maksim Losev 482d8da2dc Use HostConfig object when creating container with Docker Remote API > 1.15
This is mlosev's patch (from #1208), rebased against devel as of
2790af2.  It resolves #1707, which was caused by an API incompatibility
between the docker module and server API version 1.19.
2016-12-08 11:23:21 -05:00
Lars Kellogg-Stedman e031efd82c Do not erroneously mask exceptions
There was a catch-all `except` statement in `create_containers`:

        try:
            containers = do_create(count, params)
        except:
            self.pull_image()
            containers = do_create(count, params)

This would mask a variety of errors that should be exposed, including
API compatability errors (as in #1707) and common Python exceptions (KeyError, ValueError, etc) that could result from errors in the code.

This change makes the `except` statement more specific, and only attempts to pull the image and start a container if the original create attempt failed due to a 404 error from the docker API.
2016-12-08 11:23:21 -05:00
Lars Kellogg-Stedman 6116e4cdab docker: permit empty or false pid
The `docker` Python module only accepts `None` or `'host'` as arguments.
This makes it difficult to conditionally set the `pid` attribute using
standard Ansible syntax.

This change converts any value that evaluates as boolean `False` to
`None`, which includes empty strings:

    pid:

As well as an explicit `false`:

    pid: false

This permits the following to work as intended:

    - hosts: localhost
      tasks:
      - name: starting container
        docker:
          docker_api_version: 1.18
          image: larsks/mini-httpd
          name: web
          pid: "{{ container_pid|default('') }}"

If `container_pid` is set to `host` somewhere, this will create a
Docker container with `pid=host`; otherwise, this will create a
container with normal isolated pid namespace.
2016-12-08 11:23:21 -05:00
Ian Babrou 9219aeaaeb Pulling missing docker image before doing anything 2016-12-08 11:23:19 -05:00
Simon Olofsson a3cb6d2f16 Add option docker_user for docker module.
docker_user can be used to specify the user or UID to use within the
container.
2016-12-08 11:23:19 -05:00
Ash Wilson 9f12fd0a26 Default net to 'bridge' in container diff
This prevents an unnecessary reload when the `net` parameter is unspecified
(i.e. almost always).
2016-12-08 11:23:14 -05:00
Ed Hein f11c451bfa Fix computation of port bindings. Port bindings configuration can be a list if several host ports are bound to the same guest port. 2016-12-08 11:23:14 -05:00
Andrew Davis 4d4d911d6e ansible_facts reflects 1.8 output 2016-12-08 11:23:13 -05:00
Ash Wilson ea83727fcf Wait for process exit on detached=no. 2016-12-08 11:23:13 -05:00
Stefan Junker 4ee972190b docker: Use a list instead of a dict for volumes according to the docker-py docs. Do not add host-binds to volumes list. 2016-12-08 11:23:13 -05:00
Stefan Junker 50fe57fff3 Fix bind-volumes on docker >= 1.4.0
If bind-volumes are submitted to docker >= 1.4.0 with the volumes set in addition to the binds, docker will create a regular volume and not bind-mount the specified path.
2016-12-08 11:23:13 -05:00
Toshio Kuratomi 0a3150f7d7 Add version_added documentation to log_driver parameter 2016-12-08 11:23:12 -05:00
Ryan Walls 01a28e7d80 Fix typo in Docker module. 2016-12-08 11:23:12 -05:00
Ryan Walls 9630972c2c Update docker module to avoid false positives when containers are first created. Also have the module check for api compatibility before trying to set a "--log-driver" option. 2016-12-08 11:23:12 -05:00
Ryan Walls f5c1d8141b Set default "log_driver" option to None in docker module. 2016-12-08 11:23:12 -05:00
Ryan Walls 0df1b01cb2 Update docker module to look at log_driver variable when deciding if container configuration has changed. 2016-12-08 11:23:12 -05:00
Ryan Walls 3419a1e253 Add support for --log-driver option that docker released with Docker 1.6 2016-12-08 11:23:12 -05:00
Robin Roth abc89f0df5 add comment: ports need to be exposed.
port mapping with this module only works for ports that are exposed either in the Dockerfile or via an additional arguments. This is different from the command line docker client, that is willing to also map ports that are not exposed.

This comments makes the behaviour more obvious.
2016-12-08 11:23:09 -05:00
Greg DeKoenigsberg 18ca7aee07 Updating cloud modules with proper github author information 2016-12-08 11:23:07 -05:00
Andrew Pashkin a960caae96 Add 'docker_api_version' to docker_image
By default docker-py uses latest version of Docker API. This is not
always desireable, and this patch adds option to specify version, that
should be used.
2016-12-08 11:23:02 -05:00
Pierre Baillet eba0f12769 Support optional dockerfile name 2016-12-08 11:22:59 -05:00
Toshio Kuratomi 5336217649 Several cleanups to many modules:
* Fix docs to specify when python2.6+ is required (due to a library
  dep).  This helps us know when it is okay to use python2.6+ syntax in
  the file.
* remove BabyJson returns.  See #1211  This commit fixes all but the
  openstack modules.
* Use if __name__ == '__main__' to only run the main part of the module
  if the module is run as a program.  This allows for the potential to
  unittest the code later.
2016-12-08 11:22:58 -05:00
Ratnadeep Debnath a99d7da0c1 Fixed typo in cloud docker module. 2016-12-08 11:22:57 -05:00
Toshio Kuratomi c2bf2c7c54 Fix error when container has no names.
Rename loop variable from "i" to more informative "container"

Fixes #1188
2016-12-08 11:22:57 -05:00
Toshio Kuratomi 8bc34613bc Second try at fixing #1227 -- set e default value earlier 2016-12-08 11:22:56 -05:00
Toshio Kuratomi 030858df67 Return empty list if an image has no repo_tags 2016-12-08 11:22:56 -05:00
Toshio Kuratomi 0d468a3aa0 Get docker's default api version definition from both 1.2 location and pre-1.2 location
Fixes #1227
2016-12-08 11:22:56 -05:00
Brian Coca 018b0118dc removed deprecated docs, not true anymore 2016-12-08 11:22:56 -05:00
Toshio Kuratomi 4592b795d9 Only split on the first colon.
Fixes #1214
2016-12-08 11:22:56 -05:00
Heikki Partanen ec566d86b3 Add support for extra_hosts to docker module
extra_hosts parameter (maps to --add-host in 'docker run' syntax) is used
to add host-to-ip mappings to the container.
2016-12-08 11:22:55 -05:00
Ash Wilson c6b0656c1c Record facts for each changed container. 2016-12-08 11:22:52 -05:00
Ryan Trauntvein eaa0ce0ceb Specify that "state: reloaded" was added in Ansible 1.9 2016-12-08 11:22:51 -05:00
Ash Wilson 2dde45cea9 Only fetch details when necessary. 2016-12-08 11:22:50 -05:00
Ash Wilson 93b620ea8a Compare container images to Config.Image. 2016-12-08 11:22:50 -05:00
moncho 0156188a54 Update docker.py
Fix typo that prevents use_tls 'encrypt' option from working properly.
2016-12-08 11:22:49 -05:00
Toshio Kuratomi 5262d768e0 Add another valid status from downloading images 2016-12-08 11:22:49 -05:00
nemunaire 7eebab43ae Convert tuple items to string before format 2016-12-08 11:22:49 -05:00
Toshio Kuratomi d5e3abc5d5 Some code cleanup (removed unused variables and imports) 2016-12-08 11:22:49 -05:00
Toshio Kuratomi f892ca5b8f Also use DOCKER_TLS_VERIFY env var to turn on tls verification 2016-12-08 11:22:49 -05:00
Toshio Kuratomi 1bb98542d3 Fix a potential bug in docker pull 2016-12-08 11:22:49 -05:00
Toshio Kuratomi 0ad023a0ac When no use_tls is not specified and no tls parameters are given we need to not attempt tls. 2016-12-08 11:22:49 -05:00
Toshio Kuratomi 2e93f8e9f7 Make state=running work for backwards compatibility with 1.8 2016-12-08 11:22:48 -05:00
Toshio Kuratomi 1946f05baf Fix lookup of parameter name to be pid instead of pid_mode 2016-12-08 11:22:48 -05:00
Toshio Kuratomi 09a0db1e1f Make pid_mode parameter do minimum docker-py/docker server version checks 2016-12-08 11:22:48 -05:00
Toshio Kuratomi 95df4bcbee Fix for problems found by @dguerri
* TLSConfig['verify'] has to be set to False if we're only encrypting the
  connection, not verifying the host.
* tls_hostname was not set if tls_ca_cert was not present

https://github.com/ansible/ansible-modules-core/pull/926#issuecomment-78573877
2016-12-08 11:22:48 -05:00
Toshio Kuratomi 7c261b3954 Implement comments from @smashwilson:
* if tls_ca_cert is set then use tls to verify the server
* take tls_hostname from the environment variable DOCKER_TLS_HOSTNAME
  if it's not specified in the playbook

https://github.com/ansible/ansible-modules-core/pull/926#issuecomment-78542210
2016-12-08 11:22:48 -05:00
Ian Babrou 3bfe9a7b50 fixed: global name 'e' is not defined 2016-12-08 11:22:48 -05:00
Toshio Kuratomi 3284359894 Alternative implementation of tls for docker
Alternative to #854
2016-12-08 11:22:48 -05:00
Toshio Kuratomi a02641b4f3 Documentation style changes 2016-12-08 11:22:48 -05:00
Ian Babrou 005d02b185 not triggering reload for links and not string env variables 2016-12-08 11:22:47 -05:00
Ash Wilson 7c4e8774d8 Use {0}, {1} style format indices for 2.6 compat 2016-12-08 11:22:47 -05:00
Ash Wilson ff0d0ceb70 Expect module env vars to override Dockerfile ones. 2016-12-08 11:22:47 -05:00
Ash Wilson 4e7d766e8f Include bind mounts in VOLUMES check. 2016-12-08 11:22:47 -05:00
Ash Wilson 959d135b60 Exposed ports, env vars, volumes from the image.
This will account for settings that are provided by the hierarchy of
Dockerfiles used to construct your image, rather than only accounting
for settings provided to the module directly.
2016-12-08 11:22:47 -05:00
Ash Wilson 0d822c0c02 Full image inspection and just repo tags
Hat tip to @bobrik.
2016-12-08 11:22:47 -05:00
Sam Yaple 42fd85f041 Updated version and fixed default 2016-12-08 11:22:47 -05:00
Sam Yaple 24f1cf80bd Add pid mode support to docker module
This allows setting the pid namespace for a container. Currently only
the 'host' pid namespace is supported.

This requires Docker 1.4.1 and docker-py 1.0.0
2016-12-08 11:22:47 -05:00
Ash Wilson 1c5601a0b5 Connect to Docker with optional TLS. 2016-12-08 11:22:47 -05:00
Ash Wilson 4224dd1acb Rework docker module states.
Organize each state into a distinct function for readability and composability.
Rework `present` to create but not start containers. Add a `restarted` state
to unconditionally restart a container and a `reloaded` state to restart a
container if and only if its configuration is incorrect. Store our most recent
knowledge about container states in a ContainerSet object. Improve the value
registered by this task to include not only the inspect data from any changed
containers, but also action counters in their native form, a summary message
for all actions taken, and a `reload_reasons` key to store a human-readable
diagnostic to determine why each container was reloaded.
2016-12-08 11:22:47 -05:00
Lorin Hochstein 09e10ea031 Don't pass volumes_from to create_container
Don't pass the volumes_from argument to the Docker create_container method.

If the volumes_from argument is passed to the create_container method, Docker
raises the following exception:

    docker.errors.DockerException: 'volumes_from' parameter has no effect on
    create_container(). It has been moved to start()
2016-12-08 11:22:47 -05:00
Ash Wilson 338bbf6efc Pull newer image versions when requested. 2016-12-08 11:22:46 -05:00
Ash Wilson 6505ce3940 Another documentation commit. 2016-12-08 11:22:46 -05:00
Brian Coca 5c90040626 undeprecated docker_image until replacement actually arives 2016-12-08 11:22:45 -05:00
Sergey Zhukov d013652dc7 Fixed broken volumes_from for client API >= 1.10 2016-12-08 11:22:43 -05:00
Marek Chodor 35ab6d15df Fixes docker.errors.DockerException: 'dns' parameter has no effect on create_container(). It has been moved to start() 2016-12-08 11:22:43 -05:00
Tomer Paz 76ee9a6a04 resolve issue 764
https://github.com/ansible/ansible-modules-core/issues/764
added 'domainname' attribute in addition to existing 'hostname'.
That's the most elegant way to delegate domain name to docker-py...
2016-12-08 11:22:41 -05:00
Toshio Kuratomi dd79a27e73 Spelling and grammar fix 2016-12-08 11:22:39 -05:00
Brian Coca ed0f5045eb moved defaulting to module constant to after when it is defined 2016-12-08 11:22:39 -05:00
Lorin Hochstein 88d5f15025 docker: fix volume[s]_from typo
Code makes reference to volume_from instead of volumes_from. If volumes_from is
passed as an argument, generates a KeyError.
2016-12-08 11:22:35 -05:00
Jan Weitz 8146b45203 Fixes invalid dictionary access. 2016-12-08 11:22:35 -05:00
Jan Weitz 1b9d0c5987 Fixes version check for docker-py 2016-12-08 11:22:34 -05:00
Toshio Kuratomi d28cd02ab7 Newstyle class 2016-12-08 11:22:34 -05:00
Toshio Kuratomi 4aaba45e29 Make insecure_registry feature version check against the client API 2016-12-08 11:22:34 -05:00
Maksim Losev 807d964a48 Add insecure_registry to docker-py pull method
Starting from docker-py>=0.5.0 it is impossible to work with private registries based on HTTP.
So we need additional parameter to allow pull from insecure registry
Related to ansible/ansible#9111
2016-12-08 11:22:34 -05:00
Toshio Kuratomi 7b74e451d9 Make docker ver checks issue failures rather than silently ignoring
Also:
* make client version checks robust for two digit version pieces and
  alpha versions
* consolidate version checking code
2016-12-08 11:22:33 -05:00
Ingo Gottwald f88107bc9b Add support for new docker restart policies 2016-12-08 11:22:33 -05:00
PikachuEXE fbba80d72e ~ Add missing documentation for option `email` 2016-12-08 11:22:32 -05:00
Toshio Kuratomi 9472a27345 Clean up the docker module just a little so that we can unittest the get_split_image_tag function 2016-12-08 11:22:27 -05:00
Michael DeHaan 98fdc389d0 Deprecate docker_image, use the docker module to deploy docker images, or shell out to docker to call docker build if you want from a playbook. 2016-12-08 11:22:25 -05:00
Brian Coca 5a467bc72c added __init__.py to new cloud subcategories so builds work again 2016-12-08 11:22:25 -05:00
Brian Coca 32e85c0944 made subcategories for cloud modules for better organization 2016-12-08 11:22:24 -05:00
Michael DeHaan 213e518165 file extensions! 2016-12-08 11:22:22 -05:00
Michael DeHaan c7eec45b73 Restructuring. 2016-12-08 11:22:22 -05:00