-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible-git.yml
125 lines (116 loc) · 3.96 KB
/
ansible-git.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# git setup playbook
#
# ansible-git.yml
---
- name: git setup
hosts: all
tasks:
- name: check mandatory variables are defined
assert:
that:
- user is defined
- name: install git
dnf:
name: git
state: present
- name: setup git stuff in .bashrc
blockinfile:
path: "/home/{{ user }}/.bashrc"
marker: "# {mark} git ANSIBLE MANAGED BLOCK"
block: |
# git-rebase-from tool
alias git-rebase-from="~/data/tools/git-rebase-from.sh"
# git shortcut for pretty graph view
alias git-graph="git log --graph --oneline --decorate --branches --remotes --tags"
# git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# PS1 is default promt format variable
# \u - user
# \w - working directory
export PS1="\u@ \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
- name: get new git config stats
stat:
path: "/home/{{ user }}/data/config/dot-gitconfig"
register: new_gitconfig
- name: setup git config
file:
src: "/home/{{ user }}/data/config/dot-gitconfig"
dest: "/home/{{ user }}/.gitconfig"
state: link
force: true
become_user: "{{ user }}"
when: new_gitconfig.stat.exists == true
- name: get new git ignore list stats
stat:
path: "/home/{{ user }}/data/config/dot-gitignore"
register: new_gitignore
- name: setup git ignore list
file:
src: "/home/{{ user }}/data/config/dot-gitignore"
dest: "/home/{{ user }}/.gitignore"
state: link
force: true
become_user: "{{ user }}"
when: new_gitignore.stat.exists == true
- name: create osoukup GitHub repo directory
file:
path: "/home/{{ user }}/osoukup"
state: directory
- name: get auto-install-key stats
stat:
path: "/home/{{ user }}/.ssh/auto-install-key"
register: auto_install_key
# setup osoukup GitHub repositories if auto-install-key present
- name: setup osoukup GitHub repositories
block:
- name: ensure correct permissions for private key
file:
path: "/home/{{ user }}/.ssh/auto-install-key"
mode: 0600
- name: clone osoukup setup git repo
git:
repo: "git@github.com:osoukup/setup.git"
dest: "/home/{{ user }}/osoukup/setup"
accept_hostkey: yes
key_file: "/home/{{ user }}/.ssh/auto-install-key"
become_user: "{{ user }}"
- name: setup osoukup setup repo .git/config
blockinfile:
path: "/home/{{ user }}/osoukup/setup/.git/config"
marker: "# {mark} git ANSIBLE MANAGED BLOCK"
block: |
[user]
email = osoukup.mail@gmail.com
name = osoukup
- name: clone osoukup ctrlp.vim git repo
git:
repo: "git@github.com:osoukup/ctrlp.vim.git"
dest: "/home/{{ user }}/osoukup/ctrlp.vim"
accept_hostkey: yes
key_file: "/home/{{ user }}/.ssh/auto-install-key"
become: yes
become_user: "{{ user }}"
- name: setup osoukup ctrlp.vim repo .git/config
blockinfile:
path: "/home/{{ user }}/osoukup/ctrlp.vim/.git/config"
marker: "# {mark} git ANSIBLE MANAGED BLOCK"
block: |
[user]
email = osoukup.mail@gmail.com
name = osoukup
when: auto_install_key.stat.exists == true
- name: setup user-wide git config
copy:
dest: "/home/{{ user }}/.gitconfig"
content: |
[user]
name = osoukup
email = osoukup@redhat.com
[core]
editor = /usr/bin/vimx
- name: install gitk
dnf:
name: gitk
state: present