Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

99 line
3.3 KiB

  1. - name: Ensure dateutils and curl is installed in AWX
  2. delegate_to: 127.0.0.1
  3. yum:
  4. name: dateutils
  5. state: latest
  6. - name: Include vars in matrix_vars.yml
  7. include_vars:
  8. file: '/var/lib/awx/projects/clients/{{ member_id }}/{{ subscription_id }}/matrix_vars.yml'
  9. no_log: True
  10. - name: Ensure curl and jq intalled on target machine
  11. apt:
  12. pkg:
  13. - curl
  14. - jq
  15. state: present
  16. - name: Collect access token for janitor user
  17. shell: |
  18. curl -XPOST -d '{"type":"m.login.password", "user":"janitor", "password":"{{ matrix_awx_janitor_user_password }}"}' "https://matrix.{{ matrix_domain }}/_matrix/client/r0/login" | jq '.access_token'
  19. register: janitors_token
  20. - name: Collect the internal IP of the matrix-synapse container
  21. shell: "/usr/bin/docker inspect --format '{''{range.NetworkSettings.Networks}''}{''{.IPAddress}''}{''{end}''}' matrix-synapse"
  22. register: synapse_container_ip
  23. - name: Generate list of dates to purge to
  24. delegate_to: 127.0.0.1
  25. shell: "dateseq {{ matrix_purge_from_date }} {{ matrix_purge_to_date }}"
  26. register: purge_dates
  27. - name: Calculate initial size of local media repository
  28. shell: du -sh /matrix/synapse/storage/media-store/local*
  29. register: local_media_size_before
  30. when: matrix_purge_media_type == "Local Media"
  31. ignore_errors: yes
  32. no_log: True
  33. - name: Calculate initial size of remote media repository
  34. shell: du -sh /matrix/synapse/storage/media-store/remote*
  35. register: remote_media_size_before
  36. when: matrix_purge_media_type == "Remote Media"
  37. ignore_errors: yes
  38. no_log: True
  39. - name: Purge local media with loop
  40. include_tasks: purge_media_local.yml
  41. loop: "{{ purge_dates.stdout_lines | flatten(levels=1) }}"
  42. when: matrix_purge_media_type == "Local Media"
  43. - name: Purge remote media with loop
  44. include_tasks: purge_media_remote.yml
  45. loop: "{{ purge_dates.stdout_lines | flatten(levels=1) }}"
  46. when: matrix_purge_media_type == "Remote Media"
  47. - name: Calculate final size of local media repository
  48. shell: du -sh /matrix/synapse/storage/media-store/local*
  49. register: local_media_size_after
  50. when: matrix_purge_media_type == "Local Media"
  51. ignore_errors: yes
  52. no_log: True
  53. - name: Calculate final size of remote media repository
  54. shell: du -sh /matrix/synapse/storage/media-store/remote*
  55. register: remote_media_size_after
  56. when: matrix_purge_media_type == "Remote Media"
  57. ignore_errors: yes
  58. no_log: True
  59. - name: Print size of local media repository before purge
  60. debug:
  61. msg: "{{ local_media_size_before.stdout.split('\n') }}"
  62. when: matrix_purge_media_type == "Local Media"
  63. - name: Print size of local media repository after purge
  64. debug:
  65. msg: "{{ local_media_size_after.stdout.split('\n') }}"
  66. when: matrix_purge_media_type == "Local Media"
  67. - name: Print size of remote media repository before purge
  68. debug:
  69. msg: "{{ remote_media_size_before.stdout.split('\n') }}"
  70. when: matrix_purge_media_type == "Remote Media"
  71. - name: Print size of remote media repository after purge
  72. debug:
  73. msg: "{{ remote_media_size_after.stdout.split('\n') }}"
  74. when: matrix_purge_media_type == "Remote Media"
  75. - name: Set boolean value to exit playbook
  76. set_fact:
  77. end_playbook: true
  78. - name: End playbook early if this task is called.
  79. meta: end_play
  80. when: end_playbook is defined and end_playbook|bool