-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.yml
72 lines (65 loc) · 1.89 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
# tasks file for git
- name: import assert.yml
ansible.builtin.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 }}"
loop_control:
label: "{{ item.dest }}"
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