-
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: Module for swarm node operations #50428
Conversation
…ditional parameters than required 'node_id' provided for 'state: node'
The test
The test
|
…ne contains whitespace lib/ansible/modules/cloud/docker/docker_swarm.py:205:1: W293 blank line contains whitespace lib/ansible/modules/cloud/docker/docker_swarm.py:0:0: E309 version_added for new option (node_availability) should be 2.8. Currently 0.0 lib/ansible/modules/cloud/docker/docker_swarm.py:0:0: E309 version_added for new option (node_role) should be 2.8. Currently 0.0
@WojciechowskiPiotr I think it will be better to change the state's name. |
How about |
I think it's best to create two new PRs (for And it's great to know that you like to be involved in maintaining the modules :-) (You might also be interested in ansible/community#408) |
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.
Some comments on the facts modules.
|
||
''' | ||
|
||
RETURN = ''' |
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.
What does it return when the current Docker daemon is not part of a swarm? (Then this module could also be used to detect whether Docker daemon is part of a swarm.)
''' | ||
|
||
EXAMPLES = ''' | ||
- name: Get info on node |
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.
Shouldn't this be 'swarm' (and not 'node')?
Thinking about it, I would suggest to still name the modules This is just my personal opinion, I'm leaving the decision to you two (@tbouvet @WojciechowskiPiotr). |
self.results['actions'].append("Node updated") | ||
self.results['changed'] = True | ||
|
||
def node_list(self): |
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 this function could be in docker_swarm_facts
module because it's all nodes in a swarm environment.
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.
I've checked several other _facts
modules from the cloud
category and all of them returns the full information of all existing objects or just one\multiple objects specified usually as a name
parameter. But it is always the full structure.
To be more align with the docker command line I am thinking about changing the docker_node_facts
by setting the name
as optional and when not provided return information about all nodes, or just one if name
is provided. Then amend the docker_node
state list
so data returned by method matches the command line output.
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.
Making name
optional is probably a good idea.
@felixfontein I would stick to
I think it depends if modules should reflect the command line and API from Docker or we want to name them independently. It is still I don't know the reason why docker developers decided to not put them under Lastly, I think most people who will use the modules first got to know the Swarm via command line so it will be more natural for them to understand So unless @tbouvet disagree with me I opt for naming that align with the docker command line and API. |
I will follow your recommendations during the weekend altogether with the comments to the code |
This file will be presented in separate PR
This file will be added in separate PR
…node from swarm manager
…r swarm node from swarm manager" This reverts commit 133a8a0.
That's probably a matter of taste :) I would vote to stick mostly to the command line, but extend names to make them clearer.
I think so too, and I fully agree ;-)
That's one more reason to name them more explicit in Ansible, since other orchestrators have their own modules.
For me, I was already bitten by this from the other modules: I assumed that modules like
Fine with me. |
You just provided an argument against naming it If there are different orchestrators in future supported in Docker natively I would like to prepare components like secrets or config in a unified way, just not care about such fact as different orchestrators in playbooks unless I perform orchestrator related actions. Otherwise, it will just increase the complexity of playbooks. Like I said, maybe the Docker developers had the same approach in mind |
… to share between modules
…hat will extend the AnsibleDockerClient docker_node: Update documentation section docker_node: Convert to use the AnsibleDockerSwarmClient for client connection
I wouldn't mind renaming them as well ;-) But as I said, we can also keep things as they are now (and name the new module
Actually, renaming
If/when that happens, it might also make sense to create a orchestrator-agnostic set of modules for managing them, similar to the package module which uses |
Moved PR to #50584 |
@WojciechowskiPiotr I agree with you, I prefer |
SUMMARY
New state 'node' that allows changing Swarm node availability and role or returns node_facts about the node from Swarm manager
ISSUE TYPE
COMPONENT NAME
docker_swarm
ADDITIONAL INFORMATION
This is an extension to docker_swarm, but if required it could be easily a new module. The current docker modules do not support Swarm nodes role and availability changes. I use the API update_node call to make changes.