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.
 
 

77 lines
2.5 KiB

  1. ---
  2. - name: Ensure Matrix base path exists
  3. ansible.builtin.file:
  4. path: "{{ item }}"
  5. state: directory
  6. mode: "{{ matrix_base_data_path_mode }}"
  7. owner: "{{ matrix_user_username }}"
  8. group: "{{ matrix_user_groupname }}"
  9. with_items:
  10. - "{{ matrix_base_data_path }}"
  11. - name: Preserve vars.yml on the server for easily restoring if it gets lost later on
  12. ansible.builtin.copy:
  13. src: "{{ matrix_vars_yml_snapshotting_src }}"
  14. dest: "{{ matrix_base_data_path }}/vars.yml"
  15. owner: "{{ matrix_user_username }}"
  16. group: "{{ matrix_user_groupname }}"
  17. mode: '0660'
  18. when: "matrix_vars_yml_snapshotting_enabled | bool"
  19. - name: Save current git-repo status on the target to aid with restoring in case of problems
  20. when: "matrix_playbook_commit_hash_preservation_enabled|bool"
  21. block:
  22. - name: Get local git hash
  23. delegate_to: 127.0.0.1
  24. become: false
  25. register: git_describe
  26. ansible.builtin.shell:
  27. git describe
  28. --always
  29. --tags
  30. --dirty
  31. --long
  32. --all
  33. - ansible.builtin.set_fact:
  34. git_hash: "{{ git_describe.stdout }}"
  35. - name: Git hash
  36. ansible.builtin.debug:
  37. msg: "Git hash: {{ git_hash }}"
  38. - name: Save git_hash.yml on target
  39. ansible.builtin.copy:
  40. content: "{{ git_hash }}"
  41. dest: "{{ matrix_base_data_path }}/git_hash.yml"
  42. owner: "{{ matrix_user_username }}"
  43. group: "{{ matrix_user_groupname }}"
  44. mode: '0660'
  45. rescue:
  46. - name: GIT not found error
  47. ansible.builtin.debug:
  48. msg: >-
  49. Couldn't find GIT on the local machine. Continuing without saving the GIT hash.
  50. You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
  51. when: "git_describe.stderr.find('git: not found') != -1"
  52. - name: Get GIT hash error
  53. ansible.builtin.fail:
  54. msg: >-
  55. Error when trying to get the GIT hash. Please consult the error message above.
  56. You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
  57. when: "git_describe.stderr.find('git: not found') == -1"
  58. - name: Ensure Matrix network is created in Docker
  59. community.docker.docker_network:
  60. name: "{{ matrix_docker_network }}"
  61. driver: bridge
  62. - name: Ensure matrix-remove-all script created
  63. ansible.builtin.template:
  64. src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2"
  65. dest: "{{ matrix_local_bin_path }}/matrix-remove-all"
  66. mode: 0750