Commit Graph

390 Commits (64ded1bb5eb86838184ab39bbfd71f60c9ba9b20)

Author SHA1 Message Date
Toshio Kuratomi 9db1233521 Fix documentation 9 years ago
John R Barker bb9572ca86 ansible-validate-modules part 4: Enable check on ansible-modules-core (#3526)
* Call ansible-validate-modules

* Correct quotes + add newline
9 years ago
chouseknecht a9ab2e1142
Add doc string for container_limits. Fixed push fail message. Use path type. 9 years ago
Chris Houseknecht 35c589575d Adding docker_image_facts (#3493)
* Adding docker_image_facts

* Fix github credentials
9 years ago
Chris Houseknecht f6344b6dc7 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.
9 years ago
Toshio Kuratomi 22ce32dd93 Fix docs building 9 years ago
Toshio Kuratomi f3fef24e49 Some beginning python3 porting for modules which have unittests 9 years ago
chouseknecht 1d2be97013 Updated version_added on options to reflect options added for 2.1. 9 years ago
chouseknecht e888abbcb0
Clean up and fixes post API version 1.20 testing. 9 years ago
chouseknecht 6eba1d6fb3 Fix github credentials 9 years ago
chouseknecht 009b02e928 Fix unfriendly exeption handling. 9 years ago
chouseknecht 39fdd2358e Updater per PR comments 9 years ago
chouseknecht 7a1eea2767 Adding refactored docker_image module. 9 years ago
Chris Houseknecht ec5515edcf Adding docker_login (#3494)
* Adding docker_login

* Set correct version_added.

* Fix github credentials
9 years ago
Darek Kaczyński f7c32e2b5e Fix for 'cannot unmarshal array into Go value of type string' error about HostConfig Binds (#3496) 9 years ago
ThomasSteinbach 8dc0276533 docker: fix type issue (#3491)
* fix type issue

* fix type issue for 'volumes-from'
9 years ago
Alexey Wasilyev 1c3071af61 docker: support polling image by digest (#2932) 9 years ago
Fabian von Feilitzsch edc8698c14 make binds a list instead of a dict (to prevent overwriting when copying the same file to two places) (#2294) 9 years ago
René Moser 13f4b40c15 Merge pull request #3284 from mscherer/fix_docker_args
Improve/fix type checking for docker module
9 years ago
Ash Wilson f4557c1631 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.
9 years ago
Brian Coca dabf28edbe Merge pull request #2853 from Igelko/patch-1
docker: If cmd and entrypoint not set, don't match them
9 years ago
Victor Beresnev 6a279fd421 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
9 years ago
Brian Coca 0abade73c4 Merge pull request #2929 from gesellix/add_env_file_support_v2
add `env_file` support
9 years ago
Michael Scherer e78e13b222 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
9 years ago
Yannig Perré b958985816 Add an example of extra_hosts option. 9 years ago
Schlueter 0028f58ab6 Add missing quote in docker documentation 9 years ago
Andrey Gubarev 45b3066c81 update docker_image's path param type to 'path'. Fixes #3175 9 years ago
Brian Coca 5129ef5590 Merge pull request #2993 from berlic/devel
Fix docker container restart
9 years ago
Brian Coca 76669fa16c Merge pull request #2992 from dusdanig/devel
Adds ulimit to the docker module
9 years ago
Daniel Petty bf04a0fe0e replaced sudo with become 9 years ago
Daan Oosterveld 90153a2ca5 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.
9 years ago
Konstantin Suvorov d9f13a0bbc 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
9 years ago
Tobias Gesellchen 60e37e6fda add `env_file` support (original code from @vpetersson) 9 years ago
Alexey Wasilyev 511ce25ac8 docker: fix failing in case of empty image tag 9 years ago
Brian Coca 9c80b1adb7 added note about awslogs version added 9 years ago
jefferson fermo 028ecad9d4 add awslog option in docker log driver. this option is available starting with ansible 2.1 9 years ago
Brian Coca 9d4403f2b3 Merge pull request #2521 from wrouesnel/docker_reloaded_fixes
docker: Fix state=reloaded to detect default LoggingDriver for docker
9 years ago
Brian Coca 061da7dc05 updated version_added 9 years ago
Alexey Wasilyev d61772807c Add cpu_shares option for docker module 9 years ago
Brian Coca 4be34067de added versions note in description for new choice 9 years ago
Brian Coca c1df014e3b Merge pull request #2485 from sebi-hgdata/sebi/docker_unless_stopped
added unless stopped option to docker module
9 years ago
Brian Coca f1754fb51e Merge pull request #2376 from mtpereira/fix_2351
Add support for legacy registries to pull_image().
9 years ago
Pavel Derendyaev 61fdb52039 Add "timeout" option to Docker module 9 years ago
sebi aa15231cb7 added unless stopped option 9 years ago
Toshio Kuratomi 15c1c0cca7 entrypoint feature added in 2.1 9 years ago
Toshio Kuratomi 2220dc8e12 Merge pull request #2185 from AndrewPashkin/add_entrypoint_param_to_docker_module
Add entrypoint parameter to docker module
9 years ago
Toshio Kuratomi ba3ee25172 labels is actually not aded in 1.9.4 but in 2.1 9 years ago
Omar Khan 19ebc45364 Add stop_timeout option to docker module 9 years ago
Toshio Kuratomi d907f889a3 Merge pull request #1972 from yannh/docker-restarted
Docker module: restarted should update the container when necessary
9 years ago
Toshio Kuratomi 581b4f6de6 Add version_added to documentation 9 years ago
Joe Quadrino 8fe5d6f7ef add devices parameter for docker module 9 years ago
Brian Coca 4e8d04d248 Merge pull request #2159 from leonty/devel
Support 'labels' parameter for docker.
9 years ago
Brian Coca a876704740 Merge pull request #2239 from boushley/devel
Fix issue with comparing versions improperly
9 years ago
Brian Coca ed43b66d77 made note that Z/z are only 2.1 options 9 years ago
Will Rouesnel 7237798f20 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.
9 years ago
Steve Spencer fc5da26dee Sync up with allowable docker volume mounting modes 9 years ago
Steve Spencer 2c95641d66 Add support for mounting host volumes with Z and z options 9 years ago
Toshio Kuratomi f2943bd404 Add zfil as an owner of the docker module 9 years ago
Toshio Kuratomi 4ed7b690f6 Add a new contributor as a maintainer of the docker module 9 years ago
Toshio Kuratomi 750aa16a06 Merge pull request #2093 from zfil/fix_facts
docker module: fix regressions introduced by f38186c and 80aca4b
9 years ago
Leonty cff83dd257 Merge remote-tracking branch 'upstream/devel' into devel 9 years ago
Leonty 5b904c1401 Corrected misspelling in the 'labels' docker parameter documentation. 9 years ago
Toshio Kuratomi e318be30ff Fix issues version_added and chaged => changed typo 9 years ago
Michael Schuett 80c2e28a48 Fix message
Previous fix did not actual work. This fix does however.
9 years ago
Michael Schuett b0357bf9e8 Handle connection error
Try and help when mac hits a connection error.
9 years ago
Michael Schuett 1dcb31cad6 remove .geturl()
Can't call geturl on a string.
9 years ago
Michael Schuett c126498899 Remove faulty logic
Update logic after splitting the error into two separate messages.
9 years ago
Michael Schuett 1e8d20b0da Documentation Fix
Updated documentation to match current module state.
9 years ago
Michael Schuett 0a5b7087bd 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.
9 years ago
Michael Schuett addbc329be 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.
9 years ago
Michael Schuett bf5929d32a 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.
9 years ago
Manuel Tiago Pereira 3079c5e001 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.
9 years ago
Brian Coca 4c14e6267f Merge pull request #2258 from SamYaple/fix_docker_bug_2257
Don't assume ExposedPorts exists (bug #2257)
9 years ago
Adam Williamson 64b8596250 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.
9 years ago
Sam Yaple f15d285514 Catch the second occurance of ExposedPorts as well 9 years ago
Sam Yaple 9db5ac8e45 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
9 years ago
Brian Coca da1a317f7d Merge pull request #2139 from justnom/devel
Adding additional Docker log drivers.
9 years ago
Aaron Boushley 81e9d1bde5 Fix issue with comparing versions improperly.
This allows old versions of docker api to function.
9 years ago
Andrew Pashkin cee7e928fc Add 'entrypoint' parameter to Docker module 9 years ago
Colin Hutchinson f7aa6c4d27 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
9 years ago
Andrew Pashkin e96549c95d 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()'.
9 years ago
Leonty 2080c8ab6e Support 'labels' parameter for docker. 9 years ago
justnom 518ac36878 Adding additional Docker log drivers.
Adding additional `log_driver` choices:
* journald
* gelf
* fluentd

Compatible with Docker version >= 1.8.0
9 years ago
Philippe Jandot 8052d49b07 fix regression introduced by f38186ce8b, and propose a fix for docker facts 9 years ago
David Dyball a0a374b8ca Updated PR based on comments 9 years ago
Toshio Kuratomi 6e5a832dc2 Fix read-only usage to depend on the docker-py and docker server version 9 years ago
Toshio Kuratomi 1f358f349b 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. 9 years ago
Yann Hamon 8f03f1e4e1 Docker module: restarted should update the container when necessary 9 years ago
Omri Iluz daf7a0551b 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
9 years ago
Ilya Epifanov d951172920 fixed memory_limit for docker api version >= 1.19 9 years ago
sebi 599d60efc0 mem_limit client version check 9 years ago
Toshio Kuratomi 1001eae3c8 Set a default value for DEFAULT_DOCKER_API_VERSION so we can create the AnsibleModule without docker-py 9 years ago
Brian Coca c6da9d0758 added missing version_Added to extra_hosts
fixes #1843
9 years ago
Toshio Kuratomi 2785364ebe Merge pull request #1736 from larsks/bug/docker-version-parse
docker: fix parsing of docker __version__ string
9 years ago
Brian Coca 49400d90ac Merge pull request #1830 from ecliptik/devel
Fix incorrect var name for api_version
9 years ago
Micheal Waltz b43f236b05 Fix incorrect var name for api_version 9 years ago
Brian Coca dbdbcb33cc defined DEFAULT_DOCKER_API_VERSION to avoid it erroring out before we send the message that docker.py is missing 9 years ago
Brian Coca 44d23ababd Merge pull request #1767 from ecliptik/devel
Use proper HostConfig element which contains the proper Memory value …
9 years ago
Brian Coca d91834bdf5 Merge pull request #1763 from larsks/bug/missing-mem-limit
restore mem_limit
9 years ago
Micheal Waltz 613fe54908 Use a if/else instead to avoid loading possibly invalid values for Memory 9 years ago
Micheal Waltz 77d1c896fe 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'].
9 years ago
Johan Haals 1ea03e7182 ensures API compatibility for read_only containers 9 years ago
Johan Haals 851e55b55f changed version_added for read_only param
this feature will be released in 2.0
9 years ago
Johan Haals 8ec6538ad4 Merge remote-tracking branch 'upstream/devel' into docker-read-only-container 9 years ago
Christian Hammerl b96d304b93 docker: add support to add/drop capabilities 9 years ago
Micheal Waltz b0b1566b89 Use proper HostConfig element which contians the proper Memory value - fixes #1766 9 years ago
Lars Kellogg-Stedman 6aedc1020e restore mem_limit
mem_limit got lost in the #1744; this restores it.  Thanks to @dgromov
for the report.
9 years ago
Johan Haals 38f01b52e8 Added support for --read-only Docker containers
Adds support for mounting the container's root filesystem as read only.
9 years ago
Brian Coca 88167a5dac minor doc fixes to docker_user 9 years ago
Brian Coca 5240124525 Merge pull request #361 from simono/docker-add-user
Add option docker_user for docker module.
9 years ago
Brian Coca 030d6d645c added version_Added for new signal option in docker module 9 years ago
Brian Coca ac28f16126 Merge pull request #1014 from nemunaire/docker-kill-signal
[Docker] Add signal parameter when killing container
9 years ago
Brian Coca 2441928484 corrected v ersion added 9 years ago
Daniel Kerwin d4d78a1998 Too late for 1.8 9 years ago
Daniel Kerwin a702dbd29a Switch to _cap_ver_req and add cpu_set to create_containers 9 years ago
Daniel Kerwin a8bc50a11f Renamed to cpu_set 9 years ago
Daniel Kerwin fca75a9705 Add support for cpusets. Requires docker-py >= 0.6.0 9 years ago
Brian Coca cf25888e2d Merge pull request #978 from bobrik/faster-docker-updates
[docker] pulling missing docker image before doing anything
9 years ago
Maksim Losev efb6088c27 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.
9 years ago
Lars Kellogg-Stedman 444a2ad808 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.
9 years ago
Lars Kellogg-Stedman 6672205f49 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.
9 years ago
Lars Kellogg-Stedman b7e92b3e52 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')
9 years ago
Brian Coca 51b6b725cc Merge pull request #1078 from andrewgdavis/devel
ansible_facts reflects 1.8 output
9 years ago
Brian Coca afeb3c8d07 Merge pull request #1031 from smashwilson/docker-wait
[docker] Wait for process exit on detached=no.
9 years ago
Brian Coca 5f5f01833f Merge pull request #1508 from tarrychk/issue_1442
Fix computation of port bindings
9 years ago
Brian Coca 038cc05f4e Merge pull request #1609 from smashwilson/default-net-bridge
[docker] Prevent unnecessary reloads due to the net parameter
9 years ago
Brian Coca ec15b67712 Merge pull request #547 from steveeJ/devel
Fix bind-volumes on docker >= 1.4.0
9 years ago
Simon Olofsson dc3161dfdd Add option docker_user for docker module.
docker_user can be used to specify the user or UID to use within the
container.
9 years ago
Ash Wilson 29e4a127e1 Default net to 'bridge' in container diff
This prevents an unnecessary reload when the `net` parameter is unspecified
(i.e. almost always).
9 years ago
Toshio Kuratomi 964d731722 Add version_added documentation to log_driver parameter 9 years ago
Toshio Kuratomi 718f32a042 Merge pull request #1405 from ryanwalls/docker-module-log-driver
Add support for --log-driver option that docker released with Docker 1.6
9 years ago
Brian Coca 19f6099777 minor doc fixes 9 years ago
Robin Roth 64fe01178f 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.
9 years ago
Greg DeKoenigsberg 28a869a030 Updating cloud modules with proper github author information 9 years ago
Ed Hein 558f2ace1f Fix computation of port bindings. Port bindings configuration can be a list
if several host ports are bound to the same guest port.
9 years ago
Ryan Walls a2630d40fb Fix typo in Docker module. 9 years ago
Ryan Walls 88eddb13c0 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.
9 years ago
Ryan Walls c95717afe5 Set default "log_driver" option to None in docker module. 9 years ago
Ryan Walls 5f1d88a829 Update docker module to look at log_driver variable when deciding if container configuration has changed. 9 years ago
Andrew Pashkin 27c174128b 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.
9 years ago
Ryan Walls 3f679933a6 Add support for --log-driver option that docker released with Docker 1.6 9 years ago
Pierre Baillet 06e3ac7bf4 Support optional dockerfile name 9 years ago
Toshio Kuratomi 60a66a544d 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.
10 years ago
Ian Babrou 501a665060 Pulling missing docker image before doing anything 10 years ago
Ratnadeep Debnath be66acb436 Fixed typo in cloud docker module. 10 years ago
Toshio Kuratomi f444e49dfa Fix error when container has no names.
Rename loop variable from "i" to more informative "container"

Fixes #1188
10 years ago
Pascal Borreli f29a6ec54d Fixed typos 10 years ago
Toshio Kuratomi 1fdf75d49d Second try at fixing #1227 -- set e default value earlier 10 years ago
Toshio Kuratomi e51ea29d8f Return empty list if an image has no repo_tags 10 years ago
Toshio Kuratomi e356692c74 Get docker's default api version definition from both 1.2 location and pre-1.2 location
Fixes #1227
10 years ago