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

59 lines
1.2 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: Reuse username
set_fact:
username: "{{ git_username.config_value }}"
when: git_username.config_value != ""
- name: Set new username
set_fact:
username: "{{ ansible_facts['env']['USER'] }}@{{ ansible_hostname }}"
when: git_username.config_value == ""
- name: Reuse useremail
set_fact:
useremail: "{{ git_useremail.config_value }}"
when: git_useremail.config_value != ""
- name: Set new useremail
set_fact:
useremail: "{{ git_email }}" # Set in vault
when: git_useremail.config_value == ""
- name: Copy global gitconfig
template:
src: gitconfig.j2
dest: ~/.gitconfig
backup: true