73 lines
1.9 KiB
YAML
73 lines
1.9 KiB
YAML
---
|
|
# tasks file for git
|
|
|
|
- name: include assert.yml
|
|
import_tasks: assert.yml
|
|
run_once: yes
|
|
delegate_to: localhost
|
|
|
|
- name: install git
|
|
ansible.builtin.package:
|
|
name: "{{ git_packages }}"
|
|
state: present
|
|
|
|
- name: see if the specified user exists
|
|
ansible.builtin.getent:
|
|
database: passwd
|
|
key: "{{ git_username }}"
|
|
fail_key: no
|
|
when:
|
|
- git_username is defined
|
|
|
|
- name: create directory for git configuration
|
|
ansible.builtin.file:
|
|
path: /home/{{ git_username }}
|
|
state: directory
|
|
owner: "{{ git_username | default(omit) }}"
|
|
group: "{{ git_groupname | default(omit) }}"
|
|
mode: "0755"
|
|
when:
|
|
- getent_passwd is defined
|
|
- getent_passwd[git_username] != none
|
|
|
|
- name: place git configuration
|
|
ansible.builtin.template:
|
|
src: gitconfig.j2
|
|
dest: /home/{{ git_username }}/.gitconfig
|
|
mode: "0644"
|
|
when:
|
|
- git_user_email is defined
|
|
- git_user_name is defined
|
|
- git_username is defined
|
|
- getent_passwd[git_username] != none
|
|
|
|
- name: create repository_destination
|
|
ansible.builtin.file:
|
|
path: "{{ git_repository_destination }}"
|
|
state: directory
|
|
owner: "{{ git_username | default(omit) }}"
|
|
group: "{{ git_groupname | default(omit) }}"
|
|
mode: "0750"
|
|
when:
|
|
- git_username is defined
|
|
- git_repository_destination is defined
|
|
- getent_passwd[git_username] != none
|
|
|
|
- name: clone all roles
|
|
ansible.builtin.git:
|
|
repo: "{{ item.repo }}"
|
|
dest: "{{ git_repository_destination }}/{{ item.dest }}"
|
|
accept_hostkey: yes
|
|
version: "{{ item.version | default('HEAD') }}"
|
|
force: "{{ item.force | default(git_force) }}"
|
|
loop: "{{ git_repositories }}"
|
|
become: yes
|
|
become_user: "{{ git_username }}"
|
|
when:
|
|
- git_repositories is defined
|
|
- git_repository_destination is defined
|
|
- git_username is defined
|
|
- getent_passwd[git_username] != none
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|