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.
 
 

65 lines
1.8 KiB

  1. ---
  2. - name: Ensure Matrix group is created
  3. group:
  4. name: "{{ matrix_user_username }}"
  5. state: present
  6. register: matrix_group
  7. - name: Set Matrix Group GID Variable
  8. set_fact:
  9. matrix_user_gid: "{{ matrix_group.gid }}"
  10. - name: Ensure Matrix user is created
  11. user:
  12. name: "{{ matrix_user_username }}"
  13. state: present
  14. group: "{{ matrix_user_username }}"
  15. register: matrix_user
  16. - name: Set Matrix Group UID Variable
  17. set_fact:
  18. matrix_user_uid: "{{ matrix_user.uid }}"
  19. - name: Ensure Matrix base path exists
  20. file:
  21. path: "{{ item }}"
  22. state: directory
  23. mode: "{{ matrix_base_data_path_mode }}"
  24. owner: "{{ matrix_user_username }}"
  25. group: "{{ matrix_user_username }}"
  26. with_items:
  27. - "{{ matrix_base_data_path }}"
  28. # `docker_network` doesn't work as expected when the given network
  29. # is a substring of a network that already exists.
  30. #
  31. # See:
  32. # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/12
  33. # - https://github.com/ansible/ansible/issues/32926
  34. #
  35. # Due to that, we employ a workaround below.
  36. #
  37. # - name: Ensure Matrix network is created in Docker
  38. # docker_network:
  39. # name: "{{ matrix_docker_network }}"
  40. # driver: bridge
  41. - name: Check existence of Matrix network in Docker
  42. shell:
  43. cmd: "docker network ls -q --filter='name=^{{ matrix_docker_network }}$'"
  44. register: result_check_docker_network
  45. changed_when: false
  46. check_mode: no
  47. - name: Create Matrix network in Docker
  48. shell:
  49. cmd: "docker network create --driver=bridge {{ matrix_docker_network }}"
  50. when: "result_check_docker_network.stdout == '' and not ansible_check_mode"
  51. - name: Ensure matrix-remove-all script created
  52. template:
  53. src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2"
  54. dest: "{{ matrix_local_bin_path }}/matrix-remove-all"
  55. mode: 0750