---
- name: 'restart-docker-nginx'
  sudo: true
  docker:
    image: "nginx:{{ nginx_docker_tag }}"
    name: "{{ nginx_container_name }}"
    volumes:
      - "{{ nginx_base_directory }}/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "{{ nginx_base_directory }}/defaults:/usr/share/nginx/html:ro"
    ports: '80:80'
    state: 'restarted'
    restart_policy: 'always'
    log_driver: 'syslog'
    log_opt:
      syslog-tag: "{{ nginx_container_name }}"

---
- name: 'restart-docker-nginx'
  sudo: true
  docker:
    image: "nginx:{{ nginx_docker_tag }}"
    name: "{{ nginx_container_name }}"
    volumes:
      - "{{ nginx_base_directory }}/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "{{ nginx_base_directory }}/defaults:/usr/share/nginx/html:ro"
    ports: '80:80'
    state: 'stopped'
    restart_policy: 'always'
    log_driver: 'syslog'
    log_opt:
      syslog-tag: "{{ nginx_container_name }}"
  notify: 'start-docker-nginx'

- name: 'start-docker-nginx'
  sudo: true
  docker:
    image: "nginx:{{ nginx_docker_tag }}"
    name: "{{ nginx_container_name }}"
    volumes:
      - "{{ nginx_base_directory }}/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "{{ nginx_base_directory }}/defaults:/usr/share/nginx/html:ro"
    ports: '80:80'
    state: 'started'
    restart_policy: 'always'
    log_driver: 'syslog'
    log_opt:
      syslog-tag: "{{ nginx_container_name }}"

Split the restart phase into stop + start
Split the restart phase into stop + start

This is to work around an ansible bug.

More details: https://github.com/ansible/ansible-modules-core/issues/2824
