ansible-roles/etc-git/tasks/main.yml
Jérémy Lecour bac9649a97 etc-git: invert conditions
If the "git init" command has not been executed, the variable is not defined.
2016-12-21 16:12:31 +01:00

37 lines
705 B
YAML

---
- name: Git is installed
apt:
name: git
state: present
- name: /etc is versioned with git
command: "git init ."
args:
chdir: /etc
creates: /etc/.git/
register: git_init
- name: /etc/.gitignore is present
copy:
src: gitignore
dest: /etc/.gitignore
owner: root
group: root
mode: 0600
- name: does /etc/ have any commit?
command: "git log"
args:
chdir: /etc
changed_when: False
failed_when: False
register: git_log
- 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)