etc-git: add tags for Ansible

This commit is contained in:
Jérémy Lecour 2018-03-16 14:20:25 +01:00 committed by Jérémy Lecour
parent b92d697db1
commit 98486fd771
3 changed files with 29 additions and 5 deletions

View file

@ -19,7 +19,7 @@ The **patch** part changes incrementally at each release.
* packweb-apache: choose mysql variant (default: `debian`) * packweb-apache: choose mysql variant (default: `debian`)
* haproxy: install Munin plugins * haproxy: install Munin plugins
* proftpd: use proftpd_accounts list for manage ftp accounts * proftpd: use proftpd_accounts list for manage ftp accounts
* etc-git: add tags for Ansible
### Changed ### Changed
* elasticsearch: use ES_TMPDIR variable for custom tmpdir, (from `/etc/default/elasticsearch` instead of changing `/etc/elesticsearch/jvm.options`). * elasticsearch: use ES_TMPDIR variable for custom tmpdir, (from `/etc/default/elasticsearch` instead of changing `/etc/elesticsearch/jvm.options`).

View file

@ -8,13 +8,15 @@
when: not ansible_check_mode when: not ansible_check_mode
ignore_errors: yes ignore_errors: yes
tags: tags:
- commit-etc - etc-git
- commit-etc
- debug: - debug:
var: git_status var: git_status
verbosity: 3 verbosity: 3
tags: tags:
- commit-etc - etc-git
- commit-etc
- name: fetch current Git user.email - name: fetch current Git user.email
git_config: git_config:
@ -22,11 +24,17 @@
repo: /etc repo: /etc
register: git_config_user_email register: git_config_user_email
ignore_errors: yes ignore_errors: yes
tags:
- etc-git
- commit-etc
- name: "set commit author" - name: "set commit author"
set_fact: set_fact:
commit_author: '{% if ansible_env.SUDO_USER is not defined %}root{% else %}{{ ansible_env.SUDO_USER }}{% endif %}' commit_author: '{% if ansible_env.SUDO_USER is not defined %}root{% else %}{{ ansible_env.SUDO_USER }}{% endif %}'
commit_email: '{% if git_config_user_email.config_value is not defined or git_config_user_email.config_value == "" %}root@localhost{% else %}{{ git_config_user_email.config_value }}{% endif %}' commit_email: '{% if git_config_user_email.config_value is not defined or git_config_user_email.config_value == "" %}root@localhost{% else %}{{ git_config_user_email.config_value }}{% endif %}'
tags:
- etc-git
- commit-etc
- name: "/etc modifications are committed" - name: "/etc modifications are committed"
shell: "git add -A . && git commit -m \"{{ commit_message | mandatory }}\" --author \"{{ commit_author | mandatory }} <{{ commit_email | mandatory }}>\"" shell: "git add -A . && git commit -m \"{{ commit_message | mandatory }}\" --author \"{{ commit_author | mandatory }} <{{ commit_email | mandatory }}>\""
@ -36,10 +44,12 @@
when: not ansible_check_mode and git_status.stdout != "" when: not ansible_check_mode and git_status.stdout != ""
ignore_errors: yes ignore_errors: yes
tags: tags:
- commit-etc - etc-git
- commit-etc
- debug: - debug:
var: etc_commit_end_run var: etc_commit_end_run
verbosity: 4 verbosity: 4
tags: tags:
- commit-etc - etc-git
- commit-etc

View file

@ -4,6 +4,8 @@
apt: apt:
name: git name: git
state: present state: present
tags:
- etc-git
- name: /etc is versioned with git - name: /etc is versioned with git
command: "git init ." command: "git init ."
@ -12,6 +14,8 @@
creates: /etc/.git/ creates: /etc/.git/
warn: no warn: no
register: git_init register: git_init
tags:
- etc-git
- name: Git user.email is configured - name: Git user.email is configured
git_config: git_config:
@ -19,6 +23,8 @@
repo: /etc repo: /etc
scope: local scope: local
value: "root@{{ ansible_fqdn | default('localhost') }}" value: "root@{{ ansible_fqdn | default('localhost') }}"
tags:
- etc-git
- name: /etc/.git is secure - name: /etc/.git is secure
file: file:
@ -26,6 +32,8 @@
owner: root owner: root
mode: "0700" mode: "0700"
state: directory state: directory
tags:
- etc-git
- name: /etc/.gitignore is present - name: /etc/.gitignore is present
copy: copy:
@ -33,6 +41,8 @@
dest: /etc/.gitignore dest: /etc/.gitignore
owner: root owner: root
mode: "0600" mode: "0600"
tags:
- etc-git
- name: does /etc/ have any commit? - name: does /etc/ have any commit?
command: "git log" command: "git log"
@ -43,6 +53,8 @@
failed_when: False failed_when: False
register: git_log register: git_log
check_mode: no check_mode: no
tags:
- etc-git
- name: initial commit is present? - name: initial commit is present?
shell: "git add -A . && git commit -m \"Initial commit via Ansible\"" shell: "git add -A . && git commit -m \"Initial commit via Ansible\""
@ -51,3 +63,5 @@
warn: no warn: no
register: git_commit register: git_commit
when: git_log.rc != 0 or (git_init is defined and git_init.changed) when: git_log.rc != 0 or (git_init is defined and git_init.changed)
tags:
- etc-git