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_swarm_service: Allow passing dicts in networks #58961

wants to merge 11 commits into
base: devel


None yet
2 participants
Copy link

commented Jul 11, 2019


This PR adds the functionality to pass dictionaries in the networks:

  name: someservice
  image: alpine:3.8
    - name: network1
        - network1alias
        foo: bar
    - name: network2
    - "network3"

To achieve this the elements=str validation on this option have been removed. I've added a new function called get_docker_networks which will handle the validation of this list.

I did choose to keep this option as list and not let it be raw with passing networks as a single dictionary with the names as keys like compose/stack does it. The reason why is that ansible does not support setting variables as dictionary keys.

Not really satisfied with the new documentation about this option. It would be nice if suboptions could be used somehow but I guess it's not possible.

Passing Networks in the service Spec is unofficially deprecated with the preferred method being to pass them in the TemplateSpec instead. This was introduced in Docker API 1.25 and docker-py 2.7. If these criterias are fulfilled Networks will be passed in TemplateSpec instead. To achieve this we needed to have docker_api_version and docker_py_version available in DockerService so I've added these arguments to the initializer. This allowed us to move the can_update_networks check into this class as well.

Fixes #56009

  • Feature Pull Request


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.