---
-
  name: Restart nginx
  ansible.builtin.service:
    name: nginx
    state: restarted

-
  name: Validate nginx configuration
  ansible.builtin.command: nginx -t -c /etc/nginx/nginx.conf
  changed_when: false

-
  name: Reload nginx
  ansible.builtin.service:
    name: nginx
    state: reloaded
  when: nginx_service_state == "started"
