diff --git a/playbooks/apt.yaml b/playbooks/apt.yaml new file mode 100644 index 0000000..4dea15f --- /dev/null +++ b/playbooks/apt.yaml @@ -0,0 +1,49 @@ +--- +- name: Install packages + hosts: localhost + connection: local + become: false + tasks: + - name: Install apt packages + become: true + ansible.builtin.apt: + autoclean: true + autoremove: true + install_recommends: true + pkg: + - ansible + - curl + - fcitx5 + - foot + - git + - grimshot + - lxpolkit + - network-manager-gnome + - nextcloud-desktop + - npm + - pass + - pipx + - python3-yamlfix + - sway + - sway-backgrounds + - sway-notification-center + - swayidle + - swaylock + - waybar + - wget + - wl-clipboard + - wofi + - yq + - zsh + state: latest + update_cache: true + - name: Remove apt packages + become: true + ansible.builtin.apt: + autoclean: true + autoremove: true + install_recommends: true + pkg: + - nano + state: absent + update_cache: true diff --git a/playbooks/nvim.yaml b/playbooks/nvim.yaml new file mode 100644 index 0000000..24b5331 --- /dev/null +++ b/playbooks/nvim.yaml @@ -0,0 +1,93 @@ +--- +- name: Set nvim/lvim + hosts: localhost + vars: + uid: "{{ lookup('env','USER') }}" + LV_BRANCH: release-1.3/neovim-0.9 + tabby_password: "{{ lookup('ansible.builtin.pipe','pass show tabby-lab.sunet.se/tabby') }}" + connection: local + become: false + tasks: + - name: Have nvim allready installed + stat: + path: /usr/local/bin/nvim + register: have_nvim + - name: Get neovim + ansible.builtin.command: + chdir: /tmp + cmd: wget https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz + creates: /tmp/nvim-linux64.tar.gz + when: not have_nvim.stat.exists + - name: Unpack neovim + ansible.builtin.command: + chdir: /tmp + cmd: tar xf nvim-linux64.tar.gz + creates: /tmp/nvim-linux64 + when: not have_nvim.stat.exists + - name: Install neovim + become: true + ansible.builtin.command: + chdir: /tmp/nvim-linux64 + cmd: cp -a bin/ lib/ share/ /usr/local/ + creates: [/usr/local/bin/nvim] + when: not have_nvim.stat.exists + - name: Install neovim man pages + become: true + ansible.builtin.command: + chdir: /tmp/nvim-linux64 + cmd: cp -a man/ /usr/local/share/ + creates: [/usr/local/share/man/man1/nvim.1] + when: not have_nvim.stat.exists + - name: Remove neovim tar ball + ansible.builtin.command: + chdir: /tmp + cmd: rm nvim-linux64.tar.gz + removes: /tmp/nvim-linux64.tar.gz + when: not have_nvim.stat.exists + - name: Remove neovim install files + ansible.builtin.command: + chdir: /tmp + cmd: rm -rf nvim-linux64/ + removes: /tmp/nvim-linux64 + when: not have_nvim.stat.exists + - name: Get lunarvim + ansible.builtin.command: + chdir: /tmp + cmd: wget https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh + creates: /tmp/install.sh + when: not have_nvim.stat.exists + - name: Install lunarvim + ansible.builtin.command: + cmd: bash /tmp/install.sh + creates: /home/{{ uid }}/.local/bin/lvim + when: not have_nvim.stat.exists + - name: Remove lunarvim install script + ansible.builtin.command: + cmd: rm /tmp/install.sh + removes: /tmp/install.sh + when: not have_nvim.stat.exists + - name: Make my lvim real vim + become: true + ansible.builtin.file: + src: "/home/{{ uid }}/.local/bin/lvim" + dest: /usr/local/bin/vim + state: link + when: not have_nvim.stat.exists + - name: Install lunarvim config + ansible.builtin.template: + src: ../templates/config.lua.j2 + dest: "/home/{{ uid }}/.config/lvim/config.lua" + owner: "{{ uid }}" + group: "{{ uid }}" + mode: '0644' + - name: Create sources dir + ansible.builtin.file: + dest: "/home/{{ uid }}/sources" + state: directory + when: not have_nvim.stat.exists + - name: Get tabby plugin + ansible.builtin.command: + chdir: "/home/{{ uid }}/sources/" + cmd: git clone https://github.com/TabbyML/tabby.git + creates: "/home/{{ uid }}/sources/tabby" + when: not have_nvim.stat.exists diff --git a/playbooks/ssh.yaml b/playbooks/ssh.yaml new file mode 100644 index 0000000..6de4f13 --- /dev/null +++ b/playbooks/ssh.yaml @@ -0,0 +1,19 @@ +--- +- name: Set up ssh + vars: + uid: "{{ lookup('env','USER') }}" + hosts: localhost + connection: local + become: false + tasks: + - name: Create ssh dir + ansible.builtin.file: + dest: "/home/{{ uid }}/.ssh" + state: directory + - name: Install authorized keys + ansible.builtin.template: + src: ../templates/authorized_keys.j2 + dest: "/home/{{ uid }}/.ssh/authorized_keys" + owner: "{{ uid }}" + group: "{{ uid }}" + mode: '0600' diff --git a/playbooks/sway.yaml b/playbooks/sway.yaml new file mode 100644 index 0000000..e8fa063 --- /dev/null +++ b/playbooks/sway.yaml @@ -0,0 +1,24 @@ +--- +- name: Set up sway + vars: + uid: "{{ lookup('env','USER') }}" + hosts: localhost + connection: local + become: false + tasks: + - name: Install autotiling + ansible.builtin.command: + cmd: pipx install autotiling + creates: "/home/{{ uid }}/.local/bin/autotiling" + - name: Create sway dir + ansible.builtin.file: + dest: "/home/{{ uid }}/.config/sway" + state: directory + - name: Install sway config + ansible.builtin.template: + src: ../templates/sway_config.j2 + dest: "/home/{{ uid }}/.config/sway/config" + owner: "{{ uid }}" + group: "{{ uid }}" + mode: '0640' + diff --git a/playbooks/zsh.yaml b/playbooks/zsh.yaml new file mode 100644 index 0000000..d5f9092 --- /dev/null +++ b/playbooks/zsh.yaml @@ -0,0 +1,41 @@ +--- +- name: Install zsh + hosts: localhost + connection: local + become: false + vars: + uid: "{{ lookup('env','USER') }}" + tasks: + - name: Have zsh installed allready + stat: + path: "/home/{{ uid }}/.oh-my-zsh" + register: ohmyzsh + - name: Set zsh as default shell + become: true + ansible.builtin.command: + cmd: chsh -s /usr/bin/zsh {{ uid }} + when: not ohmyzsh.stat.exists + - name: Get Oh my zsh + ansible.builtin.command: + chdir: /tmp + cmd: wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh + creates: /tmp/install.sh + when: not ohmyzsh.stat.exists + - name: Install Oh my zsh + ansible.builtin.command: + cmd: bash /tmp/install.sh + creates: /home/{{ uid }}/.oh-my-zsh + when: not ohmyzsh.stat.exists + - name: Remove Oh my zsh install script + ansible.builtin.command: + cmd: rm /tmp/install.sh + removes: /tmp/install.sh + when: not ohmyzsh.stat.exists + - name: Install zshrc + ansible.builtin.template: + src: ../templates/zshrc.j2 + dest: "/home/{{ uid }}/.zshrc" + owner: "{{ uid }}" + group: "{{ uid }}" + mode: '0644' + diff --git a/setup.yaml b/setup.yaml index 94c4150..c614eaa 100644 --- a/setup.yaml +++ b/setup.yaml @@ -1,171 +1,10 @@ --- +- import_playbook: playbooks/apt.yaml +- import_playbook: playbooks/nvim.yaml +- import_playbook: playbooks/zsh.yaml +- import_playbook: playbooks/ssh.yaml +- import_playbook: playbooks/sway.yaml - name: Set up my computer hosts: localhost - vars: - uid: micke - LV_BRANCH: release-1.3/neovim-0.9 - tabby_password: "{{ lookup('ansible.builtin.pipe','pass show tabby-lab.sunet.se/tabby') }}" connection: local become: false - tasks: - - name: Install apt packages - become: true - ansible.builtin.apt: - autoclean: true - autoremove: true - install_recommends: true - pkg: - - ansible - - curl - - fcitx5 - - foot - - git - - grimshot - - lxpolkit - - network-manager-gnome - - nextcloud-desktop - - npm - - pass - - pipx - - python3-yamlfix - - sway - - sway-backgrounds - - sway-notification-center - - swayidle - - swaylock - - waybar - - wget - - wl-clipboard - - wofi - - yq - - zsh - state: latest - update_cache: true - - name: Remove apt packages - become: true - ansible.builtin.apt: - autoclean: true - autoremove: true - install_recommends: true - pkg: - - nano - state: absent - update_cache: true - - name: Set zsh as default shell - become: true - ansible.builtin.command: - cmd: chsh -s /usr/bin/zsh {{ uid }} - - name: Get Oh my zsh - ansible.builtin.command: - chdir: /tmp - cmd: wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh - creates: /tmp/install.sh - - name: Install Oh my zsh - ansible.builtin.command: - cmd: bash /tmp/install.sh - creates: /home/{{ uid }}/.oh-my-zsh - - name: Remove Oh my zsh install script - ansible.builtin.command: - cmd: rm /tmp/install.sh - removes: /tmp/install.sh - - name: Get neovim - ansible.builtin.command: - chdir: /tmp - cmd: wget https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz - creates: /tmp/nvim-linux64.tar.gz - - name: Unpack neovim - ansible.builtin.command: - chdir: /tmp - cmd: tar xf nvim-linux64.tar.gz - creates: /tmp/nvim-linux64 - - name: Install neovim - become: true - ansible.builtin.command: - chdir: /tmp/nvim-linux64 - cmd: cp -a bin/ lib/ share/ /usr/local/ - creates: [/usr/local/bin/nvim] - - name: Install neovim man pages - become: true - ansible.builtin.command: - chdir: /tmp/nvim-linux64 - cmd: cp -a man/ /usr/local/share/ - creates: [/usr/local/share/man/man1/nvim.1] - - name: Remove neovim tar ball - ansible.builtin.command: - chdir: /tmp - cmd: rm nvim-linux64.tar.gz - removes: /tmp/nvim-linux64.tar.gz - - name: Remove neovim install files - ansible.builtin.command: - chdir: /tmp - cmd: rm -rf nvim-linux64/ - removes: /tmp/nvim-linux64 - - name: Get lunarvim - ansible.builtin.command: - chdir: /tmp - cmd: wget https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh - creates: /tmp/install.sh - - name: Install lunarvim - ansible.builtin.command: - cmd: bash /tmp/install.sh - creates: /home/{{ uid }}/.local/bin/lvim - - name: Remove lunarvim install script - ansible.builtin.command: - cmd: rm /tmp/install.sh - removes: /tmp/install.sh - - name: Make my lvim real vim - become: yes - ansible.builtin.file: - src: "/home/{{ uid }}/.local/bin/lvim" - dest: /usr/local/bin/vim - state: link - - name: Install zshrc - ansible.builtin.template: - src: zshrc.j2 - dest: "/home/{{ uid }}/.zshrc" - owner: "{{ uid }}" - group: "{{ uid }}" - mode: '0644' - - name: Install lunarvim config - ansible.builtin.template: - src: config.lua.j2 - dest: "/home/{{ uid }}/.config/lvim/config.lua" - owner: "{{ uid }}" - group: "{{ uid }}" - mode: '0644' - - name: Create sources dir - ansible.builtin.file: - dest: "/home/{{ uid }}/sources" - state: directory - - name: Get tabby plugin - ansible.builtin.command: - chdir: "/home/{{ uid }}/sources/" - cmd: git clone https://github.com/TabbyML/tabby.git - creates: "/home/{{ uid }}/sources/tabby" - - name: Create ssh dir - ansible.builtin.file: - dest: "/home/{{ uid }}/.ssh" - state: directory - - name: Install authorized keys - ansible.builtin.template: - src: authorized_keys.j2 - dest: "/home/{{ uid }}/.ssh/authorized_keys" - owner: "{{ uid }}" - group: "{{ uid }}" - mode: '0600' - - name: Install autotiling - ansible.builtin.command: - cmd: pipx install autotiling - creates: "/home/{{ uid }}/.local/bin/autotiling" - - name: Create sway dir - ansible.builtin.file: - dest: "/home/{{ uid }}/.config/sway" - state: directory - - name: Install sway config - ansible.builtin.template: - src: sway_config.j2 - dest: "/home/{{ uid }}/.config/sway/config" - owner: "{{ uid }}" - group: "{{ uid }}" - mode: '0640' -