-
Notifications
You must be signed in to change notification settings - Fork 8
/
provision.yml
197 lines (197 loc) · 7.01 KB
/
provision.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---
- name: Install Devopsbox
hosts: localhost
connection: local
gather_facts: true
become: true
vars:
user: vagrant
devops_tools:
- { name: awscli, version: 2.7.34 }
- { name: bat, version: 0.22.1 }
- { name: direnv, version: 2.32.1 }
- { name: exa, version: 0.10.1 }
- { name: direnv, version: 2.32.1 }
- { name: helm, version: 3.9.4 }
- { name: kubectl, version: 1.25.0 }
- { name: glab, version: 1.22.0 }
- { name: github-cli, version: 2.16.1 }
- { name: gohugo, version: 0.103.1 }
- { name: hadolint, version: 2.10.0 }
- { name: jq, version: 1.6 }
- { name: k9s, version: 0.26.5 }
- { name: kind, version: 0.16.0 }
- { name: krew, version: 0.4.3 }
- { name: kubectl, version: 1.25.2 }
- { name: kubectx, version: 0.9.4 }
- { name: kustomize, version: 4.5.7 }
- { name: minikube, version: 1.27.0 }
- { name: mkcert, version: 1.4.4 }
- { name: nomad, version: 1.3.5 }
- { name: packer, version: 1.8.3 }
- { name: popeye, version: v0.10.1 }
- { name: polaris, version: 7.1.4 }
- { name: rclone, version: 1.59.2 }
- { name: tekton-cli, version: 0.26.0 }
- { name: terraform, version: 1.3.0 }
- { name: tflint, version: 0.40.1 }
- { name: tfsec, version: 1.28.0 }
- { name: trivy, version: 0.32.0 }
- { name: vault, version: 1.11.3 }
- { name: yq, version: 4.27.5 }
tasks:
- name: Check swap State
ansible.builtin.stat:
path: /swapfile
register: swap_file_check
when: ansible_virtualization_type != "docker"
- name: Umount swap | {{ inventory_hostname }}
ansible.posix.mount:
name: swap
fstype: swap
state: absent
when: ansible_virtualization_type != "docker" and swap_file_check.stat.exists
- name: Swap Off | {{ inventory_hostname }}
ansible.builtin.shell:
cmd: swapoff -a
when: ansible_virtualization_type != "docker" and ansible_swaptotal_mb > 0
- name: Configure keyboard
ansible.builtin.copy:
src: "files/{{ item }}"
dest: "/etc/default/{{ item }}"
force: true
owner: root
group: root
mode: 0640
loop:
- keyboard
- locale
- name: Import tasks to install package for {{ ansible_os_family | lower }} distribution
ansible.builtin.include_tasks: "{{ ansible_os_family | lower }}.yml"
- name: Set timezone
community.general.timezone:
name: "Europe/Paris"
tags: keyboard
- name: Add user to groups
ansible.builtin.user:
shell: /usr/bin/zsh
name: "{{ user }}"
groups: docker,libvirt,kvm
append: true
- name: Check zsh install
ansible.builtin.stat:
path: "/home/{{ user }}/.oh-my-zsh"
register: ohmyzsh_file_check
become: false
- name: Get Oh my zsh
become: false
ansible.builtin.shell: curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh
tags: zsh
when: not ohmyzsh_file_check.stat.exists
- name: Uncomment PATH
ansible.builtin.lineinfile:
path: "/home/{{ user }}/.zshrc"
regexp: '^# export PATH.*$'
line: 'export PATH=$HOME/.local/bin:$PATH'
become: false
tags: path
- name: Install oh_my_zsh theme
ansible.builtin.git:
repo: 'https://github.com/romkatv/powerlevel10k.git'
dest: "/home/{{ user }}/.oh-my-zsh/custom/themes/powerlevel10k"
version: HEAD
become: false
- name: Install oh_my_zsh plugin zsh-syntax-highlighting
ansible.builtin.git:
repo: 'https://github.com/zsh-users/zsh-syntax-highlighting.git'
dest: "/home/{{ user }}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
force: true
version: HEAD
become: false
- name: Install oh_my_zsh plugin zsh-autosuggestions
ansible.builtin.git:
repo: 'https://github.com/zsh-users/zsh-autosuggestions.git'
dest: "/home/{{ user }}/.oh-my-zsh/custom/plugins/zsh-autosuggestions"
force: true
become: false
- name: Add plugin to .zshrc
ansible.builtin.lineinfile:
path: "/home/{{ user }}/.zshrc"
regexp: '^plugins=.*$'
line: 'plugins=(git gcloud docker kubectl colored-man-pages ansible asdf aws ubuntu direnv fzf docker-compose zsh-syntax-highlighting zsh-autosuggestions helm pip poetry python ripgrep sudo terraform vagrant vault zsh-interactive-cd)'
become: false
- name: change theme zshrc
ansible.builtin.lineinfile:
path: "/home/{{ user }}/.zshrc"
regexp: '^ZSH_THEME=.*$'
line: 'ZSH_THEME="powerlevel10k/powerlevel10k"'
become: false
- name: add PATH
ansible.builtin.lineinfile:
path: "/home/{{ user }}/.zshrc"
state: present
regexp: '^# export (PATH=\")({{ item }}:)?((?(2).*?(?!(?:.\"))|.*?(?!(?:{{ item }}))))(:{{ item }})?((?(4).*|\"))'
line: '\1\3:{{ item }}\5'
backrefs: yes
loop:
- "$HOME/.local/bin"
- "$HOME/.asdf/bin"
tags: path
become: false
- name: Install asdf
ansible.builtin.git:
repo: 'https://github.com/asdf-vm/asdf.git'
dest: "/home/{{ user }}/.asdf"
version: v0.10.2
tags: asdf
become: false
- name: Add asdf to .zshrc
ansible.builtin.lineinfile:
path: "/home/{{ user }}/.zshrc"
regexp: "{{ item}}"
line: "{{ item}}"
with_items:
- ". $HOME/.asdf/asdf.sh"
- "fpath=(${ASDF_DIR}/completions $fpath)"
- "autoload -Uz compinit && compinit"
tags: asdf
become: false
- name: Add plugin asdf
ansible.builtin.shell: "zsh -lc 'source /home/{{ user }}/.asdf/asdf.sh && /home/{{ user }}/.asdf/bin/asdf plugin add {{ item.name }}' || true"
with_items: "{{ devops_tools }}"
become: false
tags: asdf
- name: Install Tools with asdf
ansible.builtin.shell: "zsh -lc 'source /home/{{ user }}/.asdf/asdf.sh && /home/{{ user }}/.asdf/bin/asdf install {{ item.name }} {{ item.version }}'"
with_items: "{{ devops_tools }}"
become: false
tags: asdf
- name: Define global version asdf
ansible.builtin.shell: "zsh -lc 'source /home/{{ user }}/.asdf/asdf.sh && /home/{{ user }}/.asdf/bin/asdf global {{ item.name }} {{ item.version }}'"
with_items: "{{ devops_tools }}"
become: false
tags: asdf
- name: pipx
community.general.pipx:
name: "{{ item }}"
with_items:
- pip-tools
- cookiecutter
- black
- pipdeptree
- poetry
- thefuck
- kube-shell
- tldr
- name: Install pip packages
ansible.builtin.pip:
requirements: "/home/{{ user }}/my-vagrant-box/requirements.txt"
become: false
tags: pip
- name: Install vagrant plugin libvirt
ansible.builtin.shell: "vagrant plugin install {{ item }}"
become: false
tags: vagrant
with_items:
- vagrant-libvirt
- vagrant-hostmanager