---
- name: Check if ssl.inc exists
  ansible.builtin.stat:
    path: /etc/nginx/conf.d/ssl.inc
  register: ssl_inc_file

- name: Update ssl_ciphers in existing ssl.inc
  ansible.builtin.lineinfile:
    backup: true
    line: "{{ lookup('file', 'nginx_ssl_ciphers.txt') }}"
    path: /etc/nginx/conf.d/ssl.inc
    regexp: "^ssl_ciphers"
  when: ssl_inc_file.stat.exists
  notify: Reload Nginx

- name: Ensure nginx config is valid
  ansible.builtin.command: /usr/sbin/nginx -t
  changed_when: false
  when: ssl_inc_file.stat.exists
