Matrix Docker Ansible eploy
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

111 linhas
3.7 KiB

  1. - name: Ensure dateutils 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 the internal IP of the matrix-synapse container
  17. shell: "/usr/bin/docker inspect --format '{''{range.NetworkSettings.Networks}''}{''{.IPAddress}''}{''{end}''}' matrix-synapse"
  18. register: awx_synapse_container_ip
  19. - name: Collect access token for @admin-janitor user
  20. shell: |
  21. curl -XPOST -d '{"type":"m.login.password", "user":"admin-janitor", "password":"{{ awx_janitor_user_password }}"}' "{{ awx_synapse_container_ip.stdout }}:{{ matrix_synapse_container_client_api_port }}/_matrix/client/r0/login" | jq '.access_token'
  22. register: awx_janitors_token
  23. no_log: True
  24. - name: Generate list of dates to purge to
  25. delegate_to: 127.0.0.1
  26. shell: "dateseq {{ awx_purge_from_date }} {{ awx_purge_to_date }}"
  27. register: awx_purge_dates
  28. - name: Calculate initial size of local media repository
  29. shell: du -sh /matrix/synapse/storage/media-store/local*
  30. register: awx_local_media_size_before
  31. when: awx_purge_media_type == "Local Media"
  32. async: 600
  33. ignore_errors: yes
  34. no_log: True
  35. - name: Calculate initial size of remote media repository
  36. shell: du -sh /matrix/synapse/storage/media-store/remote*
  37. register: awx_remote_media_size_before
  38. when: awx_purge_media_type == "Remote Media"
  39. async: 600
  40. ignore_errors: yes
  41. no_log: True
  42. - name: Purge local media with loop
  43. include_tasks: purge_media_local.yml
  44. loop: "{{ awx_purge_dates.stdout_lines | flatten(levels=1) }}"
  45. when: awx_purge_media_type == "Local Media"
  46. - name: Purge remote media with loop
  47. include_tasks: purge_media_remote.yml
  48. loop: "{{ awx_purge_dates.stdout_lines | flatten(levels=1) }}"
  49. when: awx_purge_media_type == "Remote Media"
  50. - name: Calculate final size of local media repository
  51. shell: du -sh /matrix/synapse/storage/media-store/local*
  52. register: awx_local_media_size_after
  53. when: awx_purge_media_type == "Local Media"
  54. ignore_errors: yes
  55. no_log: True
  56. - name: Calculate final size of remote media repository
  57. shell: du -sh /matrix/synapse/storage/media-store/remote*
  58. register: awx_remote_media_size_after
  59. when: awx_purge_media_type == "Remote Media"
  60. ignore_errors: yes
  61. no_log: True
  62. - name: Print size of local media repository before purge
  63. debug:
  64. msg: "{{ awx_local_media_size_before.stdout.split('\n') }}"
  65. when: awx_purge_media_type == "Local Media"
  66. - name: Print size of local media repository after purge
  67. debug:
  68. msg: "{{ awx_local_media_size_after.stdout.split('\n') }}"
  69. when: awx_purge_media_type == "Local Media"
  70. - name: Print size of remote media repository before purge
  71. debug:
  72. msg: "{{ awx_remote_media_size_before.stdout.split('\n') }}"
  73. when: awx_purge_media_type == "Remote Media"
  74. - name: Print size of remote media repository after purge
  75. debug:
  76. msg: "{{ awx_remote_media_size_after.stdout.split('\n') }}"
  77. when: awx_purge_media_type == "Remote Media"
  78. - name: Delete the AWX session token for executing modules
  79. awx.awx.tower_token:
  80. description: 'AWX Session Token'
  81. scope: "write"
  82. state: absent
  83. existing_token_id: "{{ awx_session_token.ansible_facts.tower_token.id }}"
  84. tower_host: "https://{{ awx_host }}"
  85. tower_oauthtoken: "{{ awx_session_token.ansible_facts.tower_token.token }}"
  86. - name: Set boolean value to exit playbook
  87. set_fact:
  88. awx_end_playbook: true
  89. - name: End playbook early if this task is called.
  90. meta: end_play
  91. when: awx_end_playbook is defined and awx_end_playbook|bool