From 8e6e03d55c1093ca728ef6afc17fe312331b031d Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 31 May 2020 12:17:10 +0200 Subject: [PATCH] Started to split tasks into roles --- roles/misc/tasks/main.yaml | 46 +++++++++++++ roles/neovim/tasks/main.yaml | 33 +++++++++ roles/oh-my-zsh/tasks/main.yaml | 13 ++++ roles/update-packages/tasks/main.yaml | 8 +++ roles/user-account/tasks/main.yaml | 18 +++++ wsl-debian.yaml | 98 ++------------------------- 6 files changed, 125 insertions(+), 91 deletions(-) create mode 100644 roles/misc/tasks/main.yaml create mode 100644 roles/neovim/tasks/main.yaml create mode 100644 roles/oh-my-zsh/tasks/main.yaml create mode 100644 roles/update-packages/tasks/main.yaml create mode 100644 roles/user-account/tasks/main.yaml diff --git a/roles/misc/tasks/main.yaml b/roles/misc/tasks/main.yaml new file mode 100644 index 0000000..fa9e478 --- /dev/null +++ b/roles/misc/tasks/main.yaml @@ -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" + diff --git a/roles/neovim/tasks/main.yaml b/roles/neovim/tasks/main.yaml new file mode 100644 index 0000000..ce40be4 --- /dev/null +++ b/roles/neovim/tasks/main.yaml @@ -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 + + diff --git a/roles/oh-my-zsh/tasks/main.yaml b/roles/oh-my-zsh/tasks/main.yaml new file mode 100644 index 0000000..2b34d6f --- /dev/null +++ b/roles/oh-my-zsh/tasks/main.yaml @@ -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" + diff --git a/roles/update-packages/tasks/main.yaml b/roles/update-packages/tasks/main.yaml new file mode 100644 index 0000000..3a2dbf3 --- /dev/null +++ b/roles/update-packages/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- name: update installed packages + apt: + name: "*" + state: latest + autoclean: yes + autoremove: yes + update_cache: yes diff --git a/roles/user-account/tasks/main.yaml b/roles/user-account/tasks/main.yaml new file mode 100644 index 0000000..8dc9048 --- /dev/null +++ b/roles/user-account/tasks/main.yaml @@ -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 + diff --git a/wsl-debian.yaml b/wsl-debian.yaml index d7fa145..2a1c427 100644 --- a/wsl-debian.yaml +++ b/wsl-debian.yaml @@ -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