-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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_node: Docker Swarm node operations module #50584
Conversation
The test
|
@DBendit @agronholm @akshay196 @cove @danihodovic @dariko @dusdanig @joshuaconner @jwitko @kassiansun @keitwb @olsaki @softzilla @tbouvet @ushuz @zfil As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add |
ready_for_review Would be nice to get this PR reviewed and hopefully merged in parallel to #50571 as those are not in conflict to each other |
I think it makes more sense to first get #50571 merged, and then modify Anyway, to get something merged, some more reviews are needed. Anyone? :) |
Now that #50571 has been merged, can you rebase this PR against |
The change in As @tbouvet agreed with me in #50428, we will use the As for the I think the options to consider are:
One more thing worth noticing is the difference between Swarm and non-Swarm hosts. The non-Swarm modules ( With the approach in point 4) the playbook developer may fetch the nodes lists and roles from To sum this up - I like the consistency between the modules and I like the idea that modules are working in similar way as CLI because most people will first know the CLI then will try automate the tasks. My preference is option 4 in this case, but I am happy to go with approach most of the docker modules maintainers here will recommend as preferred. |
There are a few things to consider:
Also, for offering lists in a |
…ibleDockerSwarmClient instead of AnsibleDockerClient docker_node: cosmetic code changes BOTMETA: updated on $team_docker
@felixfontein no problem :) Rebased and waiting for review and merging now |
@@ -584,6 +584,7 @@ files: | |||
maintainers: $team_windows_core | |||
support: core | |||
$module_utils/docker_common.py: *docker | |||
$module_utils/docker_swarm.py: *docker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for remembering to update this, if you replace the above line with:
$module_utils/docker: *docker
We can future proof this.
extends_documentation_fragment: | ||
- docker | ||
requirements: | ||
- "python >= 2.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ansible 2.8 only supports Python 2.6+ on the remote, so this line isn't needed.
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python | ||
module has been superseded by L(docker,https://pypi.org/project/docker/) | ||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details). | ||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ansible 2.8 only supports Python 2.6+ on the remote, so this could be reworded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this for now, and let's change all of these in a subsequent PR for all docker_*
modules, so that all modules get the same text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, follow up PR is a good idea.
''' | ||
|
||
RETURN = ''' | ||
node_facts: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we know the structure of the dict
then adding some of those details would be good, see the example at https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_documenting.html#return-block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only know a subset of the structure, as newer API versions will add more data here. For other docker_* modules, we "solved" this by adding sample:
with an excerpt of a result containing the most interesting things. No idea what's the best approach here.
(Another thing is that depending on the data returned, this can be really complex. For docker_container, the returned inspect result is a huge dict; documenting everything would be a big task.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a direct link to the latest Docker API documentation instead if sample:
and information to check the API documentation for the specific API version on remote?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be fine, too. Maybe also have sample:
as well, so people get an idea what they will get.
@WojciechowskiPiotr Thank you for this PR |
@WojciechowskiPiotr thanks for the PR! You will notice that you'll get CC'ed in all docker issues/PRs; ansibot will take some time to add you to all existing issues/PRs. I've opened a first follow-up PR in #51700 with some things discussed with @gundalow. |
More stuff for follow-up PRs (before I forget about this):
@WojciechowskiPiotr anything else? :) |
@felixfontein docker_swarm_facts from #50622 |
@WojciechowskiPiotr that already has a PR (and is in the tab to the left of this PR in my Ansible docker tab collection ;-) ), so I didn't mention it. |
SUMMARY
New module to handle Docker Swarm node operations. It must be executed on Swarm
manager
node and allows changing the node availability, role, and labels (fixes #49547). Part of the commit is also a shared library for all common methods for other Swarm modules.ISSUE TYPE
COMPONENT NAME
docker_node
ADDITIONAL INFORMATION
This PR is a copy of #50428, required due to the wrong branch in original PR. The open discussion in old PR is on module name and where put some inspect features, either in
docker_node
ordocker_node_facts
(#50571). The upcomingdocker_swarm_facts
will use the shared code from this PR.This module is equivalent of
docker node
CLI command allowing now changing the node availability and role as well as applying or removing the labels from the node. It must be executed on Swarm manager node otherwise exception is raised.When RP is merged into
ansible/devel
then we can updatedocker_swarm
module so it uses the shared methods frommodule_utils/docker_swarm
instead of own local wherever it is possible.