diff --git a/changelogs/fragments/53224-docker_swarm_service-UpdateConfig.yml b/changelogs/fragments/53224-docker_swarm_service-UpdateConfig.yml new file mode 100644 index 0000000000..ac70a2f04d --- /dev/null +++ b/changelogs/fragments/53224-docker_swarm_service-UpdateConfig.yml @@ -0,0 +1,2 @@ +bugfixes: +- "docker_swarm_service - fix problem with docker daemons which do not return ``UpdateConfig`` in the swarm service spec." diff --git a/lib/ansible/modules/cloud/docker/docker_swarm_service.py b/lib/ansible/modules/cloud/docker/docker_swarm_service.py index 4292689351..e5a6fdc72f 100644 --- a/lib/ansible/modules/cloud/docker/docker_swarm_service.py +++ b/lib/ansible/modules/cloud/docker/docker_swarm_service.py @@ -897,18 +897,20 @@ class DockerServiceManager(): ds = DockerService() task_template_data = raw_data['Spec']['TaskTemplate'] - update_config_data = raw_data['Spec']['UpdateConfig'] ds.image = task_template_data['ContainerSpec']['Image'] ds.user = task_template_data['ContainerSpec'].get('User', 'root') ds.env = task_template_data['ContainerSpec'].get('Env', []) ds.args = task_template_data['ContainerSpec'].get('Args', []) - ds.update_delay = update_config_data['Delay'] - ds.update_parallelism = update_config_data['Parallelism'] - ds.update_failure_action = update_config_data['FailureAction'] - ds.update_monitor = update_config_data['Monitor'] - ds.update_max_failure_ratio = update_config_data['MaxFailureRatio'] - ds.update_order = update_config_data['Order'] + + update_config_data = raw_data['Spec'].get('UpdateConfig') + if update_config_data: + ds.update_delay = update_config_data['Delay'] + ds.update_parallelism = update_config_data['Parallelism'] + ds.update_failure_action = update_config_data['FailureAction'] + ds.update_monitor = update_config_data['Monitor'] + ds.update_max_failure_ratio = update_config_data['MaxFailureRatio'] + ds.update_order = update_config_data['Order'] dns_config = task_template_data['ContainerSpec'].get('DNSConfig', None) if dns_config: