2017-07-31 20:07:30 +00:00
|
|
|
---
|
|
|
|
|
2017-09-11 20:50:14 +00:00
|
|
|
- name: Ensure Matrix base path exists
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.file:
|
2017-09-11 20:50:14 +00:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
2019-01-14 13:28:37 +00:00
|
|
|
mode: "{{ matrix_base_data_path_mode }}"
|
2017-09-11 20:50:14 +00:00
|
|
|
owner: "{{ matrix_user_username }}"
|
2020-05-01 17:59:32 +00:00
|
|
|
group: "{{ matrix_user_groupname }}"
|
2017-09-11 20:50:14 +00:00
|
|
|
with_items:
|
2017-10-24 04:01:11 +00:00
|
|
|
- "{{ matrix_base_data_path }}"
|
2018-08-08 05:23:36 +00:00
|
|
|
|
2020-06-13 04:50:56 +00:00
|
|
|
- name: Preserve vars.yml on the server for easily restoring if it gets lost later on
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.copy:
|
2020-06-14 07:00:22 +00:00
|
|
|
src: "{{ matrix_vars_yml_snapshotting_src }}"
|
2020-06-13 04:50:56 +00:00
|
|
|
dest: "{{ matrix_base_data_path }}/vars.yml"
|
|
|
|
owner: "{{ matrix_user_username }}"
|
|
|
|
group: "{{ matrix_user_groupname }}"
|
|
|
|
mode: '0660'
|
2022-07-18 08:22:05 +00:00
|
|
|
when: "matrix_vars_yml_snapshotting_enabled | bool"
|
2020-06-13 04:50:56 +00:00
|
|
|
|
2022-06-19 09:30:28 +00:00
|
|
|
- name: Save current git-repo status on the target to aid with restoring in case of problems
|
|
|
|
block:
|
2022-10-31 21:57:16 +00:00
|
|
|
- name: Get local git hash
|
2022-06-19 09:30:28 +00:00
|
|
|
delegate_to: 127.0.0.1
|
|
|
|
become: false
|
|
|
|
register: git_describe
|
2022-10-31 21:57:16 +00:00
|
|
|
ansible.builtin.shell:
|
2022-06-19 09:30:28 +00:00
|
|
|
git describe
|
|
|
|
--always
|
|
|
|
--tags
|
|
|
|
--dirty
|
|
|
|
--long
|
|
|
|
--all
|
|
|
|
|
2022-10-31 21:57:16 +00:00
|
|
|
- ansible.builtin.set_fact:
|
2022-06-19 09:30:28 +00:00
|
|
|
git_hash: "{{ git_describe.stdout }}"
|
|
|
|
|
|
|
|
- name: Git hash
|
2022-10-31 21:57:16 +00:00
|
|
|
ansible.builtin.debug:
|
2022-06-19 09:30:28 +00:00
|
|
|
msg: "Git hash: {{ git_hash }}"
|
2022-10-31 21:57:16 +00:00
|
|
|
|
2022-10-30 13:04:33 +00:00
|
|
|
- name: Save git_hash.yml on target
|
2022-10-31 21:57:16 +00:00
|
|
|
ansible.builtin.copy:
|
2022-10-30 13:04:33 +00:00
|
|
|
content: "{{ git_hash }}"
|
2022-06-19 09:30:28 +00:00
|
|
|
dest: "{{ matrix_base_data_path }}/git_hash.yml"
|
|
|
|
owner: "{{ matrix_user_username }}"
|
|
|
|
group: "{{ matrix_user_groupname }}"
|
|
|
|
mode: '0660'
|
|
|
|
|
|
|
|
rescue:
|
|
|
|
- name: GIT not found error
|
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: >-
|
|
|
|
Couldn't find GIT on the local machine. Continuing without saving the GIT hash.
|
2022-10-30 13:00:04 +00:00
|
|
|
You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
|
2022-10-30 13:33:09 +00:00
|
|
|
when: "git_describe.stderr.find('git: not found') != -1"
|
2022-06-19 09:30:28 +00:00
|
|
|
|
2022-10-30 13:33:09 +00:00
|
|
|
- name: Get GIT hash error
|
2022-06-19 09:30:28 +00:00
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: >-
|
2022-10-30 13:37:45 +00:00
|
|
|
Error when trying to get the GIT hash. Please consult the error message above.
|
2022-10-30 13:00:04 +00:00
|
|
|
You can disable saving the GIT hash by setting 'matrix_playbook_commit_hash_preservation_enabled: false' in vars.yml
|
2022-10-30 13:33:09 +00:00
|
|
|
when: "git_describe.stderr.find('git: not found') == -1"
|
2022-06-19 09:30:28 +00:00
|
|
|
|
2022-10-30 13:07:39 +00:00
|
|
|
when: "matrix_playbook_commit_hash_preservation_enabled|bool"
|
2022-06-19 09:30:28 +00:00
|
|
|
|
2020-08-02 18:54:13 +00:00
|
|
|
- name: Ensure Matrix network is created in Docker
|
2022-10-28 11:20:17 +00:00
|
|
|
community.docker.docker_network:
|
2020-08-02 18:54:13 +00:00
|
|
|
name: "{{ matrix_docker_network }}"
|
|
|
|
driver: bridge
|
2018-11-28 10:02:51 +00:00
|
|
|
|
|
|
|
- name: Ensure matrix-remove-all script created
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.template:
|
2018-11-28 10:02:51 +00:00
|
|
|
src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2"
|
2020-03-24 18:27:58 +00:00
|
|
|
dest: "{{ matrix_local_bin_path }}/matrix-remove-all"
|
2018-11-28 10:02:51 +00:00
|
|
|
mode: 0750
|