---
- name: Up secondary proxy to serve requests
  hosts: all
  become: yes
  become_user: root
  gather_facts: no

  tasks:
    - name: Ensure nginx is enabled and running
      service:
        name: nginx
        enabled: yes
        state: started

    - name: Reload nginx
      service:
        name: nginx
        state: reloaded

    - name: Remove cron to reload nginx every 5 mins # kept as we used to reload nginx every 5 mins via cron historically
      become: yes
      become_user: jingrow
      cron:
        name: reload_nginx
        state: absent

    - name: Remove Primary from Authorized Keys
      become: yes
      become_user: jingrow
      authorized_key:
        user: jingrow
        key: "{{ primary_public_key }}"
        state: absent
