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

Open
wants to merge 11 commits into
base: devel
from

Conversation

Projects
None yet
2 participants
@hannseman
Copy link
Contributor

commented Jul 11, 2019

SUMMARY

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

docker_swarm_service:
  name: someservice
  image: alpine:3.8
  networks:
    - name: network1
      aliases:
        - network1alias
      options:
        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

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

docker_swarm_service

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.