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

Implements extra_hosts for docker_image module #59540

Merged
merged 4 commits into from
Jul 26, 2019

Conversation

ssbarnea
Copy link
Member

@ssbarnea ssbarnea commented Jul 24, 2019

SUMMARY

Allows custom hosts on docker_image module via etc_hosts parameter. Same parameter is already supported by docker_container module.

Fixes: #59233

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

docker_image

ADDITIONAL INFORMATION

This unblocks ansible/molecule#2182

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. cloud community_review In order to be merged, this PR must follow the community review workflow. docker module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Jul 24, 2019
@ansibot
Copy link
Contributor

ansibot commented Jul 24, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

lib/ansible/modules/cloud/docker/docker_image.py:0:0: E305 DOCUMENTATION.options.build.suboptions.extra_hosts.descrioption: extra keys not allowed @ data['options']['build']['suboptions']['extra_hosts']['descrioption']. Got ['Extra hosts to add to /etc/hosts in building containers, as a mapping of hostname to IP address.']
lib/ansible/modules/cloud/docker/docker_image.py:0:0: E305 DOCUMENTATION.options.build.suboptions.extra_hosts.description: required key not provided @ data['options']['build']['suboptions']['extra_hosts']['description']. Got None

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jul 24, 2019
@ansibot
Copy link
Contributor

ansibot commented Jul 24, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

lib/ansible/modules/cloud/docker/docker_image.py:0:0: E305 DOCUMENTATION.options.build.suboptions.extra_hosts.descrioption: extra keys not allowed @ data['options']['build']['suboptions']['extra_hosts']['descrioption']. Got ['Extra hosts to add to /etc/hosts in building containers, as a mapping of hostname to IP address.']
lib/ansible/modules/cloud/docker/docker_image.py:0:0: E305 DOCUMENTATION.options.build.suboptions.extra_hosts.description: required key not provided @ data['options']['build']['suboptions']['extra_hosts']['description']. Got None

click here for bot help

@ssbarnea ssbarnea force-pushed the fix/59233-docker-extra-hosts branch 2 times, most recently from fa90a9f to 5856c2a Compare July 24, 2019 18:37
@ssbarnea ssbarnea marked this pull request as ready for review July 24, 2019 18:38
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. has_issue and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 24, 2019
sivel
sivel previously requested changes Jul 24, 2019
lib/ansible/modules/cloud/docker/docker_image.py Outdated Show resolved Hide resolved
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. needs_triage Needs a first human triage before being processed. labels Jul 24, 2019
@WojciechowskiPiotr
Copy link
Contributor

Would it be possible to add integration tests for this feature?

@ssbarnea ssbarnea force-pushed the fix/59233-docker-extra-hosts branch from 5856c2a to 4ddfae3 Compare July 25, 2019 09:35
@ansibot ansibot added the test This PR relates to tests. label Jul 25, 2019
@ansibot ansibot added the community_review In order to be merged, this PR must follow the community review workflow. label Jul 25, 2019
@ssbarnea ssbarnea force-pushed the fix/59233-docker-extra-hosts branch from ff86877 to 7277eec Compare July 26, 2019 12:41
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. new_plugin This PR includes a new plugin. support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jul 26, 2019
@felixfontein
Copy link
Contributor

Please don't rebase and make changes in the same force push. That makes reviewing a lot harder than it needs to be!

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing you definitely need is a changelog fragment.

lib/ansible/plugins/callback/debug2.py Outdated Show resolved Hide resolved
@ansibot
Copy link
Contributor

ansibot commented Jul 26, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/cloud/docker/docker_image.py:881:79: bad-whitespace Exactly one space required after comma     option_minimal_versions["build.etc_hosts"] = dict(docker_py_version='2.6.0',  docker_api_version='1.27', detect_usage=detect_etc_hosts)                                                                                ^

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/docker/docker_image.py:881:81: E241 multiple spaces after ','

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 26, 2019
Allows custom hosts on docker_image module.

The of this option made impossible to use docker_image module to build
images that required a custom hostname in /etc/hosts. For running
containers this option was already present.

While the python-docker API uses extra_hosts term, our existing module
already uses etc_hosts argument, so it sounds better to have some
consistency between docker_container and docker_image.

Fixes: ansible#59233
@ssbarnea ssbarnea force-pushed the fix/59233-docker-extra-hosts branch from 7277eec to 0bc076e Compare July 26, 2019 13:39
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 26, 2019
Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I marked a couple of nits, besides that it is ready for merging IMO!

changelogs/fragments/docker_image_etc_hosts.yml Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/docker/docker_image.py Outdated Show resolved Hide resolved
ssbarnea and others added 3 commits July 26, 2019 19:51
Co-Authored-By: Felix Fontein <felix@fontein.de>
Co-Authored-By: Felix Fontein <felix@fontein.de>
Co-Authored-By: Felix Fontein <felix@fontein.de>
Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shipit

@ansibot ansibot added automerge This PR was automatically merged by ansibot. shipit This PR is ready to be merged by Core and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jul 26, 2019
@ansibot ansibot merged commit 7c6fb57 into ansible:devel Jul 26, 2019
@felixfontein
Copy link
Contributor

@ssbarnea thanks for implementing this! It will appear in Ansible 2.9. And also thanks for taking ownership of docker_image.

@ansible ansible locked and limited conversation to collaborators Aug 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 automerge This PR was automatically merged by ansibot. bug This issue/PR relates to a bug. cloud docker feature This issue/PR relates to a feature request. has_issue module This issue/PR relates to a module. new_plugin This PR includes a new plugin. shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker_image: is missing etc_hosts (extra_hosts argument from python-docker)
5 participants