Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

78 строки
2.6 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 # noqa command-instead-of-module
  23. delegate_to: 127.0.0.1
  24. become: false
  25. register: git_describe
  26. changed_when: false
  27. ansible.builtin.shell:
  28. git describe
  29. --always
  30. --tags
  31. --dirty
  32. --long
  33. --all
  34. - ansible.builtin.set_fact:
  35. git_hash: "{{ git_describe.stdout }}"
  36. - name: Git hash
  37. ansible.builtin.debug:
  38. msg: "Git hash: {{ git_hash }}"
  39. - name: Save git_hash.yml on target
  40. ansible.builtin.copy:
  41. content: "{{ git_hash }}"
  42. dest: "{{ matrix_base_data_path }}/git_hash.yml"
  43. owner: "{{ matrix_user_username }}"
  44. group: "{{ matrix_user_groupname }}"
  45. mode: '0660'
  46. rescue:
  47. - name: GIT not found error
  48. ansible.builtin.debug:
  49. msg: >-
  50. Couldn't find GIT on the local machine. Continuing without saving the GIT hash.
  51. You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
  52. when: "git_describe.stderr.find('git: not found') != -1"
  53. - name: Get GIT hash error
  54. ansible.builtin.fail:
  55. msg: >-
  56. Error when trying to get the GIT hash. Please consult the error message above.
  57. You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
  58. when: "git_describe.stderr.find('git: not found') == -1"
  59. - name: Ensure Matrix network is created in Docker
  60. community.docker.docker_network:
  61. name: "{{ matrix_docker_network }}"
  62. driver: bridge
  63. - name: Ensure matrix-remove-all script created
  64. ansible.builtin.template:
  65. src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2"
  66. dest: "{{ matrix_local_bin_path }}/matrix-remove-all"
  67. mode: 0750