-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-server.yml
137 lines (117 loc) · 3.71 KB
/
setup-server.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
---
- name: Setup Server
hosts: all
become: true
# INFO: Define variables
vars:
dotfiles_repo: https://github.com/mimukit/dotfiles.git
dotfiles_dir: "{{ ansible_env.HOME }}/dotfiles"
zshrc_source: "{{ dotfiles_dir }}/dot_zshrc"
starship_config_source: "{{ dotfiles_dir }}/dot_config/starship/"
tmux_config_source: "{{ dotfiles_dir }}/dot_config/tmux/"
nvim_config_source: "{{ dotfiles_dir }}/dot_config/nvim/"
# INFO: Define handlers
handlers:
- name: update apt cache
apt:
update_cache: yes
- name: restart zsh
shell: exec zsh
when: not ansible_os_family == 'Windows'
- name: install tmux plugins
shell: >
tmux start-server &&
tmux new-session -d &&
tmux source ~/.config/tmux/tmux.conf &&
~/.tmux/plugins/tpm/bin/install_plugins &&
tmux kill-server
when: not ansible_os_family == 'Windows'
- name: install fzf
shell: "{{ ansible_env.HOME }}/.fzf/install --all"
# INFO: Define tasks
tasks:
- name: Update and upgrade the system
apt:
update_cache: yes
upgrade: dist
- name: Check if nodesource is present in APT sources
shell: grep -r "nodesource" /etc/apt/sources.list /etc/apt/sources.list.d/
register: nodesource_check
ignore_errors: yes
- name: Add Node.js repository
shell: curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
when: nodesource_check.rc != 0
- name: Install required packages
apt:
name:
- bat
- btop
- curl
- eza
- git
- neovim
- nodejs
- python3.12-venv
- ripgrep
- tmux
- tree
- unzip
- zsh
state: present
- name: Clone dotfiles repository
git:
repo: "{{ dotfiles_repo }}"
dest: "{{ dotfiles_dir }}"
when: not ansible_os_family == 'Windows'
- name: Replace .zshrc with custom configuration
copy:
src: "{{ zshrc_source }}"
dest: "{{ ansible_env.HOME }}/.zshrc"
force: yes
notify: restart zsh
when: zshrc_source is file
- name: Install Starship prompt
shell: curl -sS https://starship.rs/install.sh | sh -s -- -y
args:
creates: /usr/local/bin/starship
- name: Copy Starship configuration
copy:
src: "{{ starship_config_source }}"
dest: "{{ ansible_env.HOME }}/.config/starship/"
force: yes
when: starship_config_source is directory
- name: Copy tmux configuration
copy:
src: "{{ tmux_config_source }}"
dest: "{{ ansible_env.HOME }}/.config/tmux"
force: yes
when: tmux_config_source is directory
- name: Clone Tmux Plugin Manager
git:
repo: https://github.com/tmux-plugins/tpm
dest: "{{ ansible_env.HOME }}/.tmux/plugins/tpm"
when: not ansible_os_family == 'Windows'
notify: install tmux plugins
- name: Clone and install fzf
git:
repo: https://github.com/junegunn/fzf.git
dest: "{{ ansible_env.HOME }}/.fzf"
notify: install fzf
when: not ansible_os_family == 'Windows'
- name: Copy Neovim configuration
copy:
src: "{{ nvim_config_source }}"
dest: "{{ ansible_env.HOME }}/.config/nvim"
force: yes
when: nvim_config_source is directory
- name: Remove dotfiles directory
file:
path: "{{ dotfiles_dir }}"
state: absent
- name: Open Zsh and source .zshrc to install plugins
shell: |
zsh -c "source ~/.zshrc"
args:
executable: /bin/zsh
- name: Open Neovim and synchronize plugins using LazyVim
command: nvim --headless +"Lazy sync" +qa