---

- name: Collect epoche time from date
  shell: |
    date -d '{{ item }}' +"%s"
  register: awx_epoche_time

- name: Purge local media to specific date
  shell: |
    curl -X POST --header "Authorization: Bearer {{ awx_janitors_token.stdout[1:-1] }}" '{{ awx_synapse_container_ip.stdout }}:8008/_synapse/admin/v1/media/matrix.{{ matrix_domain }}/delete?before_ts={{ awx_epoche_time.stdout }}000'
  register: awx_purge_command
  
- name: Print output of purge command
  debug: 
    msg: "{{ awx_purge_command.stdout }}"

- name: Pause for 5 seconds to let Synapse breathe
  pause:
    seconds: 5