setup-cockpit/roles/git/tasks/main.yml

46 lines
1 KiB
YAML

---
- name: Install git (Archlinux)
become: true
pacman:
name:
- git
when: ansible_distribution == 'Archlinux'
- name: Install git (Debian)
become: true
apt:
name:
- git
when: ansible_distribution == 'Debian'
- name: Copy global gitignore
copy:
src: ignore
dest: ~/.config/git/ignore
- name: Check values for git_username
git_config:
scope: file
file: ~/.gitconfig
name: user.name
register: git_username
- name: Check values for git_useremail
git_config:
scope: file
file: ~/.gitconfig
name: user.email
register: git_useremail
- name: Set vars for global gitconfig
vars:
username_if_absent: "{{ ansible_facts['env']['USER'] }}@{{ ansible_hostname }}"
set_fact:
username: "{{ (git_username.config_value != '') | ternary(git_username.config_value, username_if_absent) }}"
useremail: "{{ (git_useremail.config_value != '') | ternary(git_useremail.config_value, git_email) }}"
- name: Copy global gitconfig
template:
src: gitconfig.j2
dest: ~/.gitconfig
backup: true