-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.yaml
executable file
·122 lines (111 loc) · 3.51 KB
/
bootstrap.yaml
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
#!/usr/bin/env ansible-playbook
- name: Bootstrap development environment
hosts: localhost
connection: local
vars:
SHELL_PROFILE: "{{ ansible_user_dir }}/.{{ ansible_user_shell | basename | regex_replace('$', '_') | regex_replace('zsh_', 'z') }}profile"
SHELL_RC: "{{ ansible_user_dir }}/.{{ ansible_user_shell | basename }}rc"
SHELL: "{{ ansible_user_shell | basename | quote }}"
general_packages:
- git
- curl
- coreutils
- htop
- diff-so-fancy
- tree
- buf
- goreleaser
k8s_packages:
- kubectl
- kubie
- helm
- stern
- krew
gui_packages:
- visual-studio-code
- warp
- jetbrains-toolbox
- podman-desktop
- vlc
tasks:
- name: Update homebrew packages
community.general.homebrew:
update_homebrew: true
- name: Install general packages with brew
community.general.homebrew:
name: "{{ item }}"
state: present
loop: "{{ general_packages }}"
when: ansible_system == 'Darwin'
- name: Install k8s packages with brew
community.general.homebrew:
name: "{{ item }}"
state: present
loop: "{{ k8s_packages }}"
when: ansible_system == 'Darwin'
- name: Install gui packages with brew
community.general.homebrew:
name: "{{ item }}"
state: present
loop: "{{ gui_packages }}"
ignore_errors: true
when: ansible_system == 'Darwin'
- name: Install Oh My ZSH
shell: sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
args:
creates: "/Users/{{ lookup('env', 'USER') }}/.oh-my-zsh"
- name: Install asdf
block:
- name: install asdf by Homebrew
community.general.homebrew:
name:
- asdf
- name: set env vars (zsh)
lineinfile:
dest: "{{ SHELL_RC }}"
state: present
line: "{{ item.line }}"
with_items:
- line: ". $(brew --prefix)/share/zsh/site-functions"
regexp: '^ \. \$(brew --prefix)/share/zsh/site-functions'
- line: '. $(brew --prefix asdf)/libexec/asdf.sh'
regexp: '^ \. \$(brew --prefix asdf)/libexec/asdf\.sh'
when: SHELL == 'zsh'
when: ansible_system == 'Darwin'
- name: Install nodejs with asdf
vars:
package_name: nodejs
package_url: https://github.com/asdf-vm/asdf-nodejs.git
version: "18.17.1"
block:
- name: Add plugin
shell: |
asdf plugin add {{ package_name }} {{ package_url }} || exit 0
- name: Install default version
shell: |
asdf install {{ package_name }} {{ version }}
asdf global {{ package_name }} {{ version }}
when: ansible_system == 'Darwin'
- name: Install golang with asdf
vars:
package_name: golang
package_url: https://github.com/asdf-community/asdf-golang.git
version: "1.21.0"
block:
- name: Add plugin
shell: |
asdf plugin add {{ package_name }} {{ package_url }} || exit 0
- name: Install default version
shell: |
asdf install {{ package_name }} {{ version }}
asdf global {{ package_name }} {{ version }}
- name: set env vars (zsh)
lineinfile:
dest: "{{ SHELL_RC }}"
state: present
line: "{{ item.line }}"
with_items:
- line: '. ~/.asdf/plugins/golang/set-env.zsh'
regexp: '^ \. \~/\.asdf/plugins/golang/set-env\.zsh'
when: SHELL == 'zsh'
when: ansible_system == 'Darwin'