Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to install Docker Ansible module dependencies #48

Closed
ndusart opened this issue Oct 3, 2018 · 10 comments
Closed

Add support to install Docker Ansible module dependencies #48

ndusart opened this issue Oct 3, 2018 · 10 comments
Labels

Comments

@ndusart
Copy link

ndusart commented Oct 3, 2018

Ansible docker_container module requires that either docker or docker-py python library is installed in order to work.

I think this would be a good thing to install these from this role as this is always required for use in dependent roles. Maybe through a variable to enable that ?

@haxorof
Copy link
Owner

haxorof commented Oct 3, 2018

Thanks for the suggestion @ndusart. I have actually been thinking about this from time to time but has hesitated a bit because of incompatibilities in docker-py etc and what to use to install it: pip or OS package manager. Want to have an easy config so users does not need to think too much. 😄

Question: when you install Ansible do you use pip or OS pkg mgr? If you use pip, do you use virtualenv?

Cheers!

@ndusart
Copy link
Author

ndusart commented Oct 3, 2018

I totally understand your concern.

I am not quite into python development and not very used with the pip package manager and all that stuff so I maybe overlooked the complexity of it for a broad compatibility.

I simply do this on my playbooks:

- name: Ensure pip is installed
  package:
    name: python-pip
    state: present

- name: Ensure docker library for python is installed
  pip:
    name: docker
    state: present

For your question about the installation of Ansible, I'm using a local clone of their git repository and use the hacking/env_setup script to define environment variables to use it. But I'm not installing it on the remote host, so I do not know if it has an implication in this issue.

Maybe a boolean role variable to opt-in on this feature with other variables letting the user define which docker python sdk to install and how, with default values that are likely to fit most of the people ?
Complex cases could be left to be dealt outside this role (with direct commands to docker for example)

@haxorof
Copy link
Owner

haxorof commented Oct 3, 2018

As you say I see this as an opt-in feature to ease use of docker module in Ansible. Hopefully the packages are called the same in the different distributions this role supports and might be a good also to have a variable to say if pip shall be used or not because mixing pip and stuff from the apt/yum/dnf then you can get into trouble with dependency problems.

Hopefully I will take a deeper look into it later this week.

@haxorof haxorof closed this as completed in 96adc61 Oct 6, 2018
@haxorof haxorof reopened this Oct 6, 2018
@haxorof haxorof added the add label Oct 6, 2018
@haxorof
Copy link
Owner

haxorof commented Oct 6, 2018

@ndusart I have now implemented that I hope is what you are looking for.

If you can please try it out on the master before I do a release if you can and if you got some feedback please let me know. 😄

These are the variables you can use to get dependencies:

# Ensures 'docker_container' Ansible module dependencies are installed
docker_container_deps: false
# Ensures 'docker_service' Ansible module dependencies are installed
docker_service_deps: false
# Ensures 'docker_stack' Ansible module dependencies are installed
docker_stack_deps: false

Cheers!

@haxorof haxorof changed the title Should install python docker library Add support to install Docker Ansible module dependencies Oct 6, 2018
@haxorof
Copy link
Owner

haxorof commented Oct 7, 2018

@ndusart
Copy link
Author

ndusart commented Oct 10, 2018

@haxorof sorry about the delay, I was quite busy these days.

I just tested it with success in my playbooks ! 😃
I could only test docker_container and docker_image commands so I cannot say for the others.

Maybe there should be a comment that docker_container_deps installs dependencies for docker_image as well ?
It could lead to confusion imho.

Thanks for the good work ! 👍

@haxorof
Copy link
Owner

haxorof commented Oct 10, 2018

Thanks @ndusart!
I will update the documentation so it will be more clear. Thank you again for testing the parts you need.

Will do a release today if I got time to update the documentation.

Cheers!

@haxorof
Copy link
Owner

haxorof commented Oct 10, 2018

btw, would you @ndusart have some suggestion for better variable names for this? Was looking through the Ansible docs and maybe change to something like docker_core_deps and then document what modules it will cover.

Cheers!

@haxorof haxorof closed this as completed Oct 14, 2018
@haxorof
Copy link
Owner

haxorof commented Oct 14, 2018

# Ensures dependencies are installed so that most of the 'docker' Ansible modules will work
docker_sdk: false
# Ensures dependencies are installed so that 'docker_service' Ansible module will work
docker_compose: false
# Ensures dependencies are installed so that 'docker_stack' Ansible module will work
docker_stack: false

@ndusart
Copy link
Author

ndusart commented Oct 14, 2018

The new terms are good to me !

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

No branches or pull requests

2 participants