You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.0 KiB
YAML

---
- name: "install etckeeper (fedora)"
dnf: name={{ item }} state=present
with_items:
- git
- findutils
- hostname
- mailx
- etckeeper
when: ansible_distribution == 'Fedora'
- name: "install etckeeper (debian)"
apt: name={{ item }} state=present
with_items:
- git
- etckeeper
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- block:
- name: "package manager is dnf"
set_fact: highlevel_package_manager='dnf'
- name: "lowlevel package manager is rpm"
set_fact: lowlevel_package_manager='rpm'
when: ansible_distribution == 'Fedora'
- block:
- name: "package manager is apt"
set_fact: highlevel_package_manager='apt'
- name: "lowlevel package manager is dpkg"
set_fact: lowlevel_package_manager='dpkg'
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: "configure"
template: src=etckeeper.conf.j2
dest=/etc/etckeeper/etckeeper.conf
- name: "make sure bzr repository is absent"
file: path=/etc/.bzr state=absent
- name: "initialize git repository"
command: etckeeper init creates=/etc/.git/
- name: "check git user.name"
command: git config user.name
args:
chdir: /etc
warn: off
register: name_configured
ignore_errors: True
changed_when: False
- name: "configure git user.name"
command: git config user.name "{{etckeeper_user_name}}"
args:
chdir: /etc
warn: off
when: name_configured.stdout != etckeeper_user_name
- name: "check git user.email"
command: git config user.email
args:
chdir: /etc
warn: off
register: email_configured
ignore_errors: True
changed_when: False
- name: "configure git user.email"
command: git config user.email "{{etckeeper_user_email}}"
args:
chdir: /etc
warn: off
when: email_configured.stdout != etckeeper_user_email
- name: "enable commit mails"
template: src=post-commit-mail.j2
dest=/etc/.git/hooks/post-commit
mode=0755
when: etckeeper_mailto is defined