Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

docker: use env vars if present #272

Closed
wants to merge 3 commits into from
Closed

Conversation

lorin
Copy link
Contributor

@lorin lorin commented Nov 4, 2014

If the DOCKER_HOST environment variable is set, use environment variables
to configure the docker client.

This makes it much simpler to use this module with boot2docker on OS X.

Fixes #176.

Lorin Hochstein added 3 commits November 15, 2014 16:00
If the DOCKER_HOST environment variable is set, use it instead
of socket.

This makes it much simpler to use this module with boot2docker on OS X.
Configure docker_image to take connection info from environment variables.

Document that docker and docker_image will read connection info from environment
variables if present.
@lorin
Copy link
Contributor Author

lorin commented Nov 15, 2014

Rebased against devel to resolve merge conflict

@tcurdt
Copy link

tcurdt commented Nov 16, 2014

cannot get boot2docker to work with ansible without this - please merge!

@abadger
Copy link
Contributor

abadger commented Dec 22, 2014

Can we change this so that if you specify these in the playbook the playbook values would override what's in the environment or does that still break this use case?

@lorin
Copy link
Contributor Author

lorin commented Dec 28, 2014

@abadger I like the idea of only using the environment variable if the user does not explicitly specify a docker_url, but I'm not sure how to actually implement this.

The docker_url parameter has a default value of unix://var/run/docker.sock.

Consider the following two invocations:

- docker: image=ubuntu
- docker: image=ubuntu docker_url=unix://var/run/docker.sock

We would want to use the DOCKER_HOST environment variable in the first case but not in the second. Is there a way to differentiate between the following two invocations of the docker module in the code?

@deiga
Copy link

deiga commented Jan 14, 2015

Can I be of some assistance with this issue? I can't get ansible to run my docker containers in the current state..

@abadger
Copy link
Contributor

abadger commented Mar 4, 2015

@lorin -- sorry, I have too many docker tickets and this one got lost in my queue of tickets. Yes, there is a way to do that. We'd have to change the default value in the argument_spec to a sentinel value. Then in the module code we'd need to set the if any of the values we'd have to merge the values from the environment variable, actually specified in the playbook, and defaults if they weren't in the environment variable and the variable from the playbook was the sentinel value. None is probably the best sentinel value.

@abadger
Copy link
Contributor

abadger commented Mar 13, 2015

@lorin, how does this match up with the environment handling from the recent TLS merge? #926

@lorin
Copy link
Contributor Author

lorin commented Mar 14, 2015

#926 looks good, other than #946. I'm going to close this PR.

@lorin lorin closed this Mar 14, 2015
@lorin
Copy link
Contributor Author

lorin commented Mar 14, 2015

Looks like the env var logic was originally added in #502.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker and docker_image should respect $DOCKER_HOST environment variable
5 participants