2019-11-05 17:00:22 +01:00
|
|
|
---
|
|
|
|
|
2023-03-20 23:33:19 +01:00
|
|
|
- ansible.builtin.include_role:
|
2019-11-29 14:00:25 +01:00
|
|
|
name: evolix/remount-usr
|
2022-12-28 09:03:37 +01:00
|
|
|
when: repository_path is search("/usr")
|
2019-11-05 17:00:22 +01:00
|
|
|
|
|
|
|
- name: "{{ repository_path }} is versioned with git"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "git init ."
|
2019-11-05 17:00:22 +01:00
|
|
|
args:
|
|
|
|
chdir: "{{ repository_path }}"
|
|
|
|
creates: "{{ repository_path }}/.git/"
|
|
|
|
register: git_init
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: Git user.email is configured
|
2023-03-20 23:33:19 +01:00
|
|
|
community.general.git_config:
|
2019-11-05 17:00:22 +01:00
|
|
|
name: user.email
|
|
|
|
repo: "{{ repository_path }}"
|
|
|
|
scope: local
|
|
|
|
value: "root@{{ ansible_fqdn | default('localhost') }}"
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "{{ repository_path }}/.git is restricted to root"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.file:
|
2019-11-05 17:00:22 +01:00
|
|
|
path: "{{ repository_path }}/.git"
|
|
|
|
owner: root
|
|
|
|
mode: "0700"
|
|
|
|
state: directory
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "{{ repository_path }}/.gitignore is present"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.copy:
|
2019-11-05 17:00:22 +01:00
|
|
|
src: gitignore
|
|
|
|
dest: "{{ repository_path }}/.gitignore"
|
|
|
|
owner: root
|
|
|
|
mode: "0600"
|
|
|
|
force: no
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "Some entries MUST be in the {{ repository_path }}/.gitignore file"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2019-11-05 17:00:22 +01:00
|
|
|
dest: "{{ repository_path }}/.gitignore"
|
|
|
|
line: "{{ item }}"
|
2021-05-04 14:18:40 +02:00
|
|
|
loop: "{{ gitignore_items | default([]) }}"
|
2019-11-05 17:00:22 +01:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "does {{ repository_path }}/ have any commit?"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "git log"
|
2019-11-05 17:00:22 +01:00
|
|
|
args:
|
|
|
|
chdir: "{{ repository_path }}"
|
|
|
|
changed_when: False
|
|
|
|
failed_when: False
|
|
|
|
register: git_log
|
|
|
|
check_mode: no
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: initial commit is present?
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "git add -A . && git commit -m \"Initial commit via Ansible\""
|
2019-11-05 17:00:22 +01:00
|
|
|
args:
|
|
|
|
chdir: "{{ repository_path }}"
|
|
|
|
register: git_commit
|
2021-05-09 23:06:42 +02:00
|
|
|
when: git_log.rc != 0 or (git_init is defined and git_init is changed)
|
2019-11-05 17:00:22 +01:00
|
|
|
tags:
|
2022-12-14 07:38:04 +01:00
|
|
|
- etc-git
|