Matrix Docker Ansible eploy
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 

112 rader
3.7 KiB

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