forked from evolix/ansible-roles
59 lines
1.2 KiB
YAML
59 lines
1.2 KiB
YAML
---
|
|
|
|
- name: Git is installed
|
|
apt:
|
|
name: git
|
|
state: present
|
|
when: ansible_os_family == "Debian"
|
|
|
|
- name: Git is installed
|
|
openbsd_pkg:
|
|
name: git
|
|
state: present
|
|
when: ansible_os_family == "OpenBSD"
|
|
|
|
- name: /etc is versioned with git
|
|
command: "git init ."
|
|
args:
|
|
chdir: /etc
|
|
creates: /etc/.git/
|
|
register: git_init
|
|
|
|
- name: Git user.email is configured
|
|
ini_file:
|
|
dest: /etc/.git/config
|
|
section: user
|
|
option: email
|
|
value: "<root@{{ ansible_fqdn | default('localhost.localdomain') }}>"
|
|
|
|
- name: /etc/.git is secure
|
|
file:
|
|
path: /etc/.git
|
|
owner: root
|
|
mode: "0700"
|
|
state: directory
|
|
|
|
- name: /etc/.gitignore is present
|
|
copy:
|
|
src: gitignore
|
|
dest: /etc/.gitignore
|
|
owner: root
|
|
mode: "0600"
|
|
|
|
- name: does /etc/ have any commit?
|
|
command: "git log"
|
|
args:
|
|
chdir: /etc
|
|
changed_when: False
|
|
failed_when: False
|
|
register: git_log
|
|
#check_mode: no (for migration to Ansible 2.2)
|
|
always_run: yes
|
|
|
|
- name: initial commit is present?
|
|
shell: "git add -A . && git commit -m \"Initial commit via Ansible\""
|
|
args:
|
|
chdir: /etc
|
|
register: git_commit
|
|
when: git_log.rc != 0 or (git_init is defined and git_init.changed)
|