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

docker_* modules: stop returning ansible_facts #52518

Merged
merged 1 commit into from Feb 26, 2019

Conversation

felixfontein
Copy link
Contributor

SUMMARY

Some of the docker_* modules returned ansible_facts:

  • docker_container returns a fact called docker_container;
  • docker_network returns a fact called docker_network;
  • docker_volume returns a fact called docker_volume;
  • docker_service/docker_compose returns one fact named as the service for each service.

While this can be handy when using these modules, it is in general annoying for multiple reasons:

  1. the modules pollute the variables namespace (especially the values they return are not host specific, since there might be more than one container/network/volume/... per host);
  2. when trying to access the data of a registered result, one needs to write result.ansible_facts.docker_container when one cannot directly use the docker_container fact (for example, when using docker_container to start several containers in a loop);
  3. in particular the way docker_compose returns facts named according to user input, it can easily happen that random variables are overridden, which is in most cases not what the user expects;
  4. I don't think it was really intended to use facts in this way. Not really a reason, but I think many will agree... :-)

I've already created a PR (merged) which also returns the facts as regular return values, so people can start getting rid of the facts in their playbooks (#51192). I don't think this is enough, though. I want to deprecate the returned facts.

I know that in the past, return values of modules have been deprecated; see The ``win_disk_image`` module has deprecated the return value ``mount_path``, use ``mount_paths[0]`` instead. This will be removed in Ansible 2.11. in the 2.7 porting guide. I guess this hasn't been done for returned facts so far (they have been renamed in the past, though: the facts returned by docker_container have been renamed from ansible_docker_container to docker_container for Ansible 2.3 to avoid conflicts with the connection plugin.) Similarly to returned variables, it is not possible to warn the user when they are used, so that return values and returned facts should be deprecated with care. But I think that for the facts returned by these modules, it is really warranted to deprecate them!

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

docker_container
docker_network
docker_volume
docker_compose

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud core_review In order to be merged, this PR must follow the core review workflow. docker docs This issue/PR relates to or includes documentation. 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. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Feb 18, 2019
@WojciechowskiPiotr
Copy link
Contributor

Is the intention to remove returning any facts at all from those modules or you still want to return facts on the object that has been created/modified?

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Feb 19, 2019
@felixfontein
Copy link
Contributor Author

There is no point of returning facts of something which is not host-specific. So: no facts should be returned. (Regular return values should be used, no ansible_facts.)

@felixfontein
Copy link
Contributor Author

Discussed at public ansible meeting today, logs are here. Motion to do this passed (last item on this meeting).

Copy link
Contributor

@jamescassell jamescassell 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 the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 26, 2019
@gundalow gundalow merged commit c6ae230 into ansible:devel Feb 26, 2019
@felixfontein felixfontein deleted the docker-deprecate-facts branch February 26, 2019 21:41
@felixfontein
Copy link
Contributor Author

@WojciechowskiPiotr @jamescassell @gundalow and all others involved, thanks a lot for your feedback and helping to get this merged! :)

@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud core_review In order to be merged, this PR must follow the core review workflow. docker docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants