Started to split tasks into roles
This commit is contained in:
parent
10088f03c7
commit
8e6e03d55c
46
roles/misc/tasks/main.yaml
Normal file
46
roles/misc/tasks/main.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
- name: install basic packages
|
||||
package:
|
||||
name:
|
||||
- git
|
||||
- tmux
|
||||
- tree
|
||||
state: latest
|
||||
|
||||
- name: clone dotfiles
|
||||
become_user: "{{ account.name }}"
|
||||
git:
|
||||
repo: https://github.com/mandlm/dotfiles.git
|
||||
dest: "{{ account.home }}/.dotfiles"
|
||||
accept_hostkey: yes
|
||||
update: no
|
||||
|
||||
- name: install zsh config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/zsh"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.zshrc"
|
||||
|
||||
- name: install tmux plugin manager
|
||||
become_user: "{{ account.name }}"
|
||||
git:
|
||||
repo: https://github.com/tmux-plugins/tpm.git
|
||||
dest: "{{ account.home }}/.tmux/plugins/tpm"
|
||||
accept_hostkey: yes
|
||||
update: no
|
||||
|
||||
- name: install tmux config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/tmux"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.tmux.conf"
|
||||
|
||||
- name: install git config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/git"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.gitconfig"
|
||||
|
33
roles/neovim/tasks/main.yaml
Normal file
33
roles/neovim/tasks/main.yaml
Normal file
@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: install required packages
|
||||
package:
|
||||
name:
|
||||
- neovim
|
||||
- ripgrep
|
||||
state: latest
|
||||
|
||||
- name: create nvim plugin directory
|
||||
become_user: "{{ account.name }}"
|
||||
file:
|
||||
path: "{{ account.home }}/.local/share/nvim/site/autoload/"
|
||||
state: directory
|
||||
|
||||
- name: install vim-plug
|
||||
become_user: "{{ account.name }}"
|
||||
get_url:
|
||||
url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
dest: "{{ account.home }}/.local/share/nvim/site/autoload/plug.vim"
|
||||
|
||||
- name: install nvim config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/nvim"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.config/nvim/init.vim"
|
||||
|
||||
- name: install nvim plugins
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
cmd: nvim +PlugInstall +PlugUpdate +qall
|
||||
|
||||
|
13
roles/oh-my-zsh/tasks/main.yaml
Normal file
13
roles/oh-my-zsh/tasks/main.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: install required packages
|
||||
package:
|
||||
name:
|
||||
- curl
|
||||
state: latest
|
||||
|
||||
- name: install oh-my-zsh
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
cmd: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --keep-zshrc"
|
||||
creates: "{{ account.home }}/.oh-my-zsh"
|
||||
|
8
roles/update-packages/tasks/main.yaml
Normal file
8
roles/update-packages/tasks/main.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: update installed packages
|
||||
apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
autoclean: yes
|
||||
autoremove: yes
|
||||
update_cache: yes
|
18
roles/user-account/tasks/main.yaml
Normal file
18
roles/user-account/tasks/main.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: install required packages
|
||||
package:
|
||||
name:
|
||||
- zsh
|
||||
state: latest
|
||||
|
||||
- name: setup user account
|
||||
user:
|
||||
name: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
generate_ssh_key: yes
|
||||
create_home: yes
|
||||
shell: /usr/bin/zsh
|
||||
state: present
|
||||
update_password: always
|
||||
register: account
|
||||
|
@ -4,94 +4,10 @@
|
||||
username: mandlm
|
||||
password: $6$hfdjshdfkajdsh$DRgmUOQfm9DnvSv.l.WuQJpextzBpX5BCbSncXTts5dHazvKRxj8qUYAjju2/AGZqKOt8PTLC7w9yRR68ZHCG1
|
||||
become: yes
|
||||
tasks:
|
||||
- name: install basic packages
|
||||
package:
|
||||
name:
|
||||
- curl
|
||||
- git
|
||||
- neovim
|
||||
- ripgrep
|
||||
- tmux
|
||||
- tree
|
||||
- zsh
|
||||
state: latest
|
||||
update_cache: yes
|
||||
|
||||
- name: setup user account
|
||||
user:
|
||||
name: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
generate_ssh_key: yes
|
||||
create_home: yes
|
||||
shell: /usr/bin/zsh
|
||||
state: present
|
||||
update_password: always
|
||||
register: account
|
||||
|
||||
- name: clone dotfiles
|
||||
become_user: "{{ account.name }}"
|
||||
git:
|
||||
repo: https://github.com/mandlm/dotfiles.git
|
||||
dest: "{{ account.home }}/.dotfiles"
|
||||
accept_hostkey: yes
|
||||
update: no
|
||||
|
||||
- name: install zsh config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/zsh"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.zshrc"
|
||||
|
||||
- name: install tmux plugin manager
|
||||
become_user: "{{ account.name }}"
|
||||
git:
|
||||
repo: https://github.com/tmux-plugins/tpm.git
|
||||
dest: "{{ account.home }}/.tmux/plugins/tpm"
|
||||
accept_hostkey: yes
|
||||
update: no
|
||||
|
||||
- name: install tmux config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/tmux"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.tmux.conf"
|
||||
|
||||
- name: install git config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/git"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.gitconfig"
|
||||
|
||||
- name: install nvim config
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
chdir: "{{ account.home }}/.dotfiles/nvim"
|
||||
cmd: ./install.sh
|
||||
creates: "{{ account.home }}/.config/nvim/init.vim"
|
||||
|
||||
- name: install oh-my-zsh
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
cmd: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --keep-zshrc"
|
||||
creates: "{{ account.home }}/.oh-my-zsh"
|
||||
|
||||
- name: create nvim plugin directory
|
||||
become_user: "{{ account.name }}"
|
||||
file:
|
||||
path: "{{ account.home }}/.local/share/nvim/site/autoload/"
|
||||
state: directory
|
||||
|
||||
- name: install vim-plug
|
||||
become_user: "{{ account.name }}"
|
||||
get_url:
|
||||
url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
dest: "{{ account.home }}/.local/share/nvim/site/autoload/plug.vim"
|
||||
|
||||
- name: install nvim plugins
|
||||
become_user: "{{ account.name }}"
|
||||
shell:
|
||||
cmd: nvim +PlugInstall +PlugUpdate +qall
|
||||
gather_facts: no
|
||||
roles:
|
||||
- update-packages
|
||||
- user-account
|
||||
- misc
|
||||
- oh-my-zsh
|
||||
- neovim
|
||||
|
Reference in New Issue
Block a user