Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

85 行
2.7 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. block:
  21. - name: Get local git hash
  22. delegate_to: 127.0.0.1
  23. become: false
  24. register: git_describe
  25. shell:
  26. git describe
  27. --always
  28. --tags
  29. --dirty
  30. --long
  31. --all
  32. - set_fact:
  33. git_hash: "{{ git_describe.stdout }}"
  34. - name: Git hash
  35. debug:
  36. msg: "Git hash: {{ git_hash }}"
  37. - name: Save git hash in git_hash.yml
  38. become: false
  39. local_action:
  40. copy
  41. content="git_hash_last_run{{ ":" }} {{ git_hash }}\n"
  42. dest="{{ matrix_vars_yml_snapshotting_src }}/git_hash.yml"
  43. - name: Copy git_hash.yml file to target
  44. copy:
  45. src: "{{ matrix_vars_yml_snapshotting_src }}/git_hash.yml"
  46. dest: "{{ matrix_base_data_path }}/git_hash.yml"
  47. owner: "{{ matrix_user_username }}"
  48. group: "{{ matrix_user_groupname }}"
  49. mode: '0660'
  50. rescue:
  51. - name: GIT not found error
  52. ansible.builtin.debug:
  53. msg: >-
  54. Couldn't find GIT on the local machine. Continuing without saving the GIT hash.
  55. You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
  56. when: "git_describe.stderr.find('not found') != -1"
  57. - name: GIT hash error
  58. ansible.builtin.fail:
  59. msg: >-
  60. Error when trying to get the GIT hash.
  61. You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
  62. when: "git_describe.stderr.find('not found') == -1"
  63. when: "matrix_vars_yml_snapshotting_enabled|bool and matrix_playbook_commit_hash_preservation_enabled|bool"
  64. - name: Ensure Matrix network is created in Docker
  65. community.docker.docker_network:
  66. name: "{{ matrix_docker_network }}"
  67. driver: bridge
  68. - name: Ensure matrix-remove-all script created
  69. ansible.builtin.template:
  70. src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2"
  71. dest: "{{ matrix_local_bin_path }}/matrix-remove-all"
  72. mode: 0750