From d2b7c0fd5d126a2b1e78417dd91bc7b7a4c4f37b Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 28 Jan 2021 14:27:05 +0100 Subject: [PATCH] Updated arch config --- arch.yaml | 3 +- roles/dotfiles/tasks/main.yaml | 1 + roles/git/tasks/main.yaml | 1 - roles/neovim-appimage/tasks/main.yaml | 67 +++++++++++++++++++++++++++ roles/neovim/tasks/main.yaml | 30 +++--------- roles/sudo/tasks/main.yaml | 22 +++++++++ roles/sudo/vars/main.yaml | 3 ++ roles/tools/tasks/main.yaml | 1 + roles/user-account/tasks/main.yaml | 19 ++++++-- wsl-debian.yaml | 2 +- 10 files changed, 119 insertions(+), 30 deletions(-) create mode 100644 roles/neovim-appimage/tasks/main.yaml create mode 100644 roles/sudo/tasks/main.yaml create mode 100644 roles/sudo/vars/main.yaml diff --git a/arch.yaml b/arch.yaml index d07e9c0..924a2fc 100644 --- a/arch.yaml +++ b/arch.yaml @@ -7,10 +7,11 @@ become: yes roles: - user-account + - sudo - dotfiles - git - tmux - zsh - neovim + - vimwiki - tools - - dev-machine diff --git a/roles/dotfiles/tasks/main.yaml b/roles/dotfiles/tasks/main.yaml index 530bdfb..e90b33a 100644 --- a/roles/dotfiles/tasks/main.yaml +++ b/roles/dotfiles/tasks/main.yaml @@ -3,6 +3,7 @@ package: name: - git + - openssh state: latest - name: clone dotfiles diff --git a/roles/git/tasks/main.yaml b/roles/git/tasks/main.yaml index 285ccae..52f4901 100644 --- a/roles/git/tasks/main.yaml +++ b/roles/git/tasks/main.yaml @@ -3,7 +3,6 @@ package: name: - git - - git-flow state: latest - name: install git config diff --git a/roles/neovim-appimage/tasks/main.yaml b/roles/neovim-appimage/tasks/main.yaml new file mode 100644 index 0000000..23120f4 --- /dev/null +++ b/roles/neovim-appimage/tasks/main.yaml @@ -0,0 +1,67 @@ +--- +- name: install prerequisites (apt) + package: + name: + - nodejs + - npm + - python + - python-pip + - ripgrep + state: latest + +- name: install prerequisites (pip) + become_user: "{{ account.name }}" + pip: + name: + - pynvim + state: latest + extra_args: --user + +- name: download neovim appimage + get_url: + url: https://github.com/neovim/neovim/releases/latest/download/nvim.appimage + dest: /tmp + mode: "0755" + +- name: extract neovim appimage + shell: | + rm -rf /usr/local/bin/nvim.appimage + /tmp/nvim.appimage --appimage-extract + mv squashfs-root /usr/local/bin/nvim.appimage + chmod -R 4755 /usr/local/bin/nvim.appimage + chmod -R -s /usr/local/bin/nvim.appimage + rm -f /tmp/nvim.appimage + args: + chdir: /tmp + +- name: install neovim link + alternatives: + name: nvim + path: /usr/local/bin/nvim.appimage/usr/bin/nvim + link: /usr/bin/nvim + +- 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: "{{ 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/neovim/tasks/main.yaml b/roles/neovim/tasks/main.yaml index a3d76eb..6676331 100644 --- a/roles/neovim/tasks/main.yaml +++ b/roles/neovim/tasks/main.yaml @@ -4,7 +4,8 @@ name: - nodejs - npm - - python3 + - python + - python-pip - ripgrep state: latest @@ -16,28 +17,11 @@ state: latest extra_args: --user -- name: download neovim appimage - get_url: - url: https://github.com/neovim/neovim/releases/latest/download/nvim.appimage - dest: /tmp - mode: "0755" - -- name: extract neovim appimage - shell: | - rm -rf /usr/local/bin/nvim.appimage - /tmp/nvim.appimage --appimage-extract - mv squashfs-root /usr/local/bin/nvim.appimage - chmod -R 4755 /usr/local/bin/nvim.appimage - chmod -R -s /usr/local/bin/nvim.appimage - rm -f /tmp/nvim.appimage - args: - chdir: /tmp - -- name: install neovim link - alternatives: - name: nvim - path: /usr/local/bin/nvim.appimage/usr/bin/nvim - link: /usr/bin/nvim +- name: install neovim + package: + name: + - neovim + state: latest - name: create nvim plugin directory become_user: "{{ account.name }}" diff --git a/roles/sudo/tasks/main.yaml b/roles/sudo/tasks/main.yaml new file mode 100644 index 0000000..18a2d71 --- /dev/null +++ b/roles/sudo/tasks/main.yaml @@ -0,0 +1,22 @@ +--- +- name: install sudo + package: + name: + - sudo + state: latest + +- name: add user to sudoer group + user: + name: "{{ account.name }}" + groups: "{{ sudo_group }}" + append: yes + +- name: activate sudoers group + lineinfile: + dest: /etc/sudoers + state: present + regexp: "^%{{ sudo_group }}" + line: "%{{ sudo_group }} ALL=(ALL) ALL" + insertafter: "^#\\s*%{{ sudo_group }}" + firstmatch: true + validate: "visudo -cf %s" diff --git a/roles/sudo/vars/main.yaml b/roles/sudo/vars/main.yaml new file mode 100644 index 0000000..dc93c05 --- /dev/null +++ b/roles/sudo/vars/main.yaml @@ -0,0 +1,3 @@ +--- +sudo_group: "{{ 'sudo' if ansible_facts['os_family'] == 'Debian' else 'wheel' }}" + diff --git a/roles/tools/tasks/main.yaml b/roles/tools/tasks/main.yaml index 052a16a..918fce4 100644 --- a/roles/tools/tasks/main.yaml +++ b/roles/tools/tasks/main.yaml @@ -4,6 +4,7 @@ name: - tree state: latest + - name: install debian tools package: name: diff --git a/roles/user-account/tasks/main.yaml b/roles/user-account/tasks/main.yaml index 3b84e6d..1d3b949 100644 --- a/roles/user-account/tasks/main.yaml +++ b/roles/user-account/tasks/main.yaml @@ -6,7 +6,6 @@ create_home: yes state: present update_password: always - groups: sudo register: account - name: ensure .ssh exists @@ -19,8 +18,20 @@ - name: copy ssh key become_user: "{{ account.name }}" copy: - src: "{{ item }}" + src: "ssh/" dest: "/home/{{ account.name }}/.ssh/" mode: "0600" - with_fileglob: - - "/mnt/c/Users/mandl/.ssh/id_rsa*" + +- name: ensure .gnupg exists + become_user: "{{ account.name }}" + file: + path: "/home/{{ account.name }}/.gnupg" + state: directory + mode: "0700" + +- name: copy gpg keys + become_user: "{{ account.name }}" + copy: + src: "gnupg/" + dest: "/home/{{ account.name }}/.gnupg/" + mode: "0600" diff --git a/wsl-debian.yaml b/wsl-debian.yaml index 8e3b02d..42cb8ab 100644 --- a/wsl-debian.yaml +++ b/wsl-debian.yaml @@ -14,7 +14,7 @@ - git - tmux - zsh - - neovim + - neovim-appimage - vimwiki - tools - dev-machine