2022-04-13 15:28:10 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: "{{ repository_path }} is versioned with git"
|
|
|
|
command: "git init ."
|
|
|
|
args:
|
|
|
|
chdir: "{{ repository_path }}"
|
|
|
|
creates: "{{ repository_path }}/.git/"
|
|
|
|
warn: false
|
|
|
|
register: git_init
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Git user.email is configured"
|
2022-04-13 15:28:10 +02:00
|
|
|
git_config:
|
|
|
|
name: user.email
|
|
|
|
repo: "{{ repository_path }}"
|
|
|
|
scope: local
|
|
|
|
value: "root@{{ inventory_hostname }}.{{ general_technical_realm }}"
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "{{ repository_path }}/.git is restricted to root"
|
|
|
|
file:
|
|
|
|
path: "{{ repository_path }}/.git"
|
|
|
|
owner: root
|
|
|
|
mode: "0700"
|
|
|
|
state: directory
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "{{ repository_path }}/.gitignore is present"
|
2022-04-13 17:53:09 +02:00
|
|
|
copy:
|
2022-08-04 18:03:23 +02:00
|
|
|
src: gitignore
|
2022-04-13 17:53:09 +02:00
|
|
|
dest: "{{ repository_path }}/.gitignore"
|
2022-04-13 15:28:10 +02:00
|
|
|
owner: root
|
|
|
|
mode: "0600"
|
2022-10-19 18:23:54 +02:00
|
|
|
force: false
|
2022-08-04 18:03:23 +02:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "Some entries MUST be in the {{ repository_path }}/.gitignore file"
|
|
|
|
lineinfile:
|
|
|
|
dest: "{{ repository_path }}/.gitignore"
|
|
|
|
line: "{{ item }}"
|
|
|
|
loop: "{{ gitignore_items | default([]) }}"
|
2022-04-13 15:28:10 +02:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Set vim as default editor"
|
2022-04-13 15:28:10 +02:00
|
|
|
git_config:
|
|
|
|
name: core.editor
|
|
|
|
scope: global
|
|
|
|
value: vim
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Does {{ repository_path }}/ have any commit?"
|
2022-04-13 15:28:10 +02:00
|
|
|
command: "git log"
|
|
|
|
args:
|
|
|
|
chdir: "{{ repository_path }}"
|
|
|
|
warn: false
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
register: git_log
|
|
|
|
check_mode: false
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Initial commit is present?"
|
2022-04-13 15:28:10 +02:00
|
|
|
shell: "git add -A . && git commit -m \"Initial commit via Ansible\""
|
|
|
|
args:
|
|
|
|
chdir: "{{ repository_path }}"
|
|
|
|
warn: false
|
|
|
|
register: git_commit
|
|
|
|
when: git_log.rc != 0 or (git_init is defined and git_init is changed)
|
|
|
|
tags:
|
|
|
|
- etc-git
|