This commit is contained in:
2024-10-08 06:41:47 +02:00
parent 1ef33c16af
commit 7300938372
103 changed files with 619 additions and 198 deletions

View File

@@ -2,4 +2,5 @@
- name: Setup host
hosts: localhost
roles:
- role: terminal
- role: env_terminal
- role: env_develop

View File

@@ -1,3 +1,12 @@
- name: Show info
debug:
msg:
user: "{{ ansible_user }}"
home: "{{ ansible_env.HOME }}"
distribution: "{{ ansible_distribution }}"
family: "{{ ansible_os_family}}"
arch: "{{ ansible_architecture }}"
- name: Setting host facts
tags: always
ansible.builtin.set_fact:

View File

@@ -0,0 +1,2 @@
dependencies:
- role: base_info

View File

@@ -1,3 +1,6 @@
export TMPDIR="${TMPDIR:-/tmp}"
export PATH="$PATH:$HOME/.local/bin"
alias ls=eza
alias cat=bat
alias grep=rg

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: base_info

View File

@@ -3,6 +3,7 @@
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:

View File

@@ -0,0 +1,14 @@
---
terminal_pkgs:
- bat
- eza
- direnv
- fzf
- gnupg
- jq
- ripgrep
- neovim
- gh
- tmux
- zoxide
- sshpass

View File

@@ -1,4 +0,0 @@
---
dependencies:
- role: info
- role: system

View File

@@ -1,4 +0,0 @@
---
dev_pkgs: []
dev_casks: []
dev_flatpaks: []

View File

@@ -1,4 +0,0 @@
---
dependencies:
- role: info
- role: system

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: base_info

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: base_info

View File

@@ -0,0 +1,20 @@
---
- name: "Load vars : {{ context }}"
ansible.builtin.include_vars: "{{ item }}"
tags:
- install
with_first_found:
- files:
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- default.yml
paths: ../vars
skip: true
- name: "Install dependencies"
tags:
- install
when: env_develop_pkgs
ansible.builtin.package:
name: "{{ env_develop_pkgs }}"

View File

@@ -1,4 +1,4 @@
---
dev_pkgs:
env_develop_pkgs:
- rustup
- python3

View File

@@ -0,0 +1,11 @@
---
dependencies:
- role: base_info
- role: software_git
- role: software_zsh
- role: software_starship
- role: software_tmux
- role: software_ssh
- role: software_nvm
- role: software_nvim
- role: software_atuin

View File

@@ -1,4 +1,17 @@
---
- name: Copy config {{ context }}
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files/{{ context }}
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: "Copy templates : {{ context }}"
tags:
- config
@@ -12,7 +25,7 @@
label: "{{ item.path }}"
when: item.state == 'file'
- name: "Copy config : {{ context }}"
- name: Copy config {{ context }}
tags:
- config
ansible.builtin.copy:

View File

@@ -0,0 +1,33 @@
---
- name: "Unload vars : {{ context }}"
ansible.builtin.include_vars: ../vars/empty.yml
tags:
- install
- name: "Load vars : {{ context }}"
ansible.builtin.include_vars: "{{ item }}"
tags:
- install
with_first_found:
- files:
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- default.yml
paths: ../vars/{{ context }}
skip: true
- name: "Install dependencies : {{ context }}"
tags:
- install
when: terminal_pkgs
ansible.builtin.package:
name: "{{ terminal_pkgs }}"
- name: "Install casks : {{ context }}"
tags:
- install
when: terminal_casks
community.general.homebrew_cask:
name: "{{ terminal_casks }}"
state: installed

View File

@@ -0,0 +1,22 @@
---
- name: Install context dependencies
ansible.builtin.include_tasks: install.yml
loop: "{{ contexts }}"
loop_control:
loop_var: context
tags:
- config
- name: Install atuin
tags:
- install
ansible.builtin.include_role:
name: software_atuin
- name: Configure contexts
ansible.builtin.include_tasks: config.yml
loop: "{{ contexts }}"
loop_control:
loop_var: context
tags:
- config

View File

@@ -0,0 +1,4 @@
---
terminal_pkgs: []
terminal_casks: []
terminal_flatpaks: []

View File

@@ -0,0 +1,5 @@
---
terminal_pkgs:
- terraform
- awscli
- copier

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: base_info

View File

@@ -0,0 +1,39 @@
---
- name: Copy config
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: "Copy templates"
tags:
- config
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../templates
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'
- name: Copy config
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'

View File

@@ -1,14 +0,0 @@
---
mirror: "https://github.com/atuinsh/atuin/releases/download/"
version: v18.3.0
arch_map:
arm64: aarch64
aarch64: aarch64
system_map:
Darwin: apple-darwin
Linux: unknown-linux-gnu
atuin_url: "{{ mirror }}/{{version}}/atuin-{{ arch_map[ansible_architecture] }}-{{ system_map[ansible_system] }}.tar.gz"
download_dir: "/tmp/atuin.tar.gz"
unpack_dir: "/tmp/atuin"
unpack_file: "{{ unpack_dir }}/atuin-{{ arch_map[ansible_architecture] }}-{{ system_map[ansible_system] }}/atuin"

View File

@@ -1,4 +0,0 @@
---
dependencies:
- role: info
- role: system

View File

@@ -1,30 +0,0 @@
- name: Download atuin
tags: always
ansible.builtin.get_url:
url: "{{ atuin_url }}"
dest: "{{ download_dir }}"
- name: Create dir
tags: always
ansible.builtin.file:
path: "{{ unpack_dir }}"
state: directory
- name: Extract foo.tgz into /var/lib/foo
tags: always
ansible.builtin.unarchive:
src: "{{ download_dir }}"
dest: "{{ unpack_dir }}"
- name: Ensure dir
tags: always
ansible.builtin.file:
path: "{{ home }}/.scripts"
state: directory
- name: Move bin
tags: always
ansible.builtin.copy:
remote_src: true
mode: 755
src: "{{ unpack_file }}"
dest: "{{ home }}/.scripts/atuin"

View File

@@ -1,14 +0,0 @@
---
mirror: "https://github.com/starship/starship/releases/download/"
version: v1.20.1
arch_map:
arm64: aarch64
aarch64: aarch64
system_map:
Darwin: apple-darwin
Linux: unknown-linux-musl
download_url: "{{ mirror }}/{{version}}/starship-{{ arch_map[ansible_architecture] }}-{{ system_map[ansible_system] }}.tar.gz"
download_dir: "/tmp/starship.tar.gz"
unpack_dir: "/tmp/starship"
unpack_file: "{{ unpack_dir }}/starship"

View File

@@ -1,4 +0,0 @@
---
dependencies:
- role: info
- role: system

View File

@@ -0,0 +1,14 @@
---
software_atuin_mirror: https://github.com/atuinsh/atuin/releases/download/
software_atuin_version: v18.3.0
software_atuin_arch_map:
arm64: aarch64
aarch64: aarch64
software_atuin_system_map:
Darwin: apple-darwin
Linux: unknown-linux-gnu
software_atuin_download_url: "{{ software_atuin_mirror }}/{{ software_atuin_version }}/atuin-{{ software_atuin_arch_map[ansible_architecture] }}-{{ software_atuin_system_map[ansible_system] }}.tar.gz"
software_atuin_download_dir: /tmp/atuin.tar.gz
software_atuin_unpack_dir: /tmp/atuin
software_atuin_unpack_file: "{{ software_atuin_unpack_dir }}/atuin-{{ software_atuin_arch_map[ansible_architecture] }}-{{ software_atuin_system_map[ansible_system] }}/atuin"

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: base_info
- role: base_terminal

View File

@@ -0,0 +1,60 @@
---
- name: Download atuin
tags: always
ansible.builtin.get_url:
url: "{{ software_atuin_download_url }}"
dest: "{{ software_atuin_download_dir }}"
mode: "0600"
- name: Create dir
tags: always
ansible.builtin.file:
path: "{{ software_atuin_unpack_dir }}"
mode: "0755"
state: directory
- name: Unpacking atuin
tags: always
ansible.builtin.unarchive:
src: "{{ software_atuin_download_dir }}"
dest: "{{ software_atuin_unpack_dir }}"
- name: Ensure dir
tags: always
ansible.builtin.file:
path: "{{ home }}/.scripts"
mode: "0755"
state: directory
- name: Move bin
tags: always
ansible.builtin.copy:
remote_src: true
mode: "0755"
src: "{{ software_atuin_unpack_file }}"
dest: "{{ home }}/.local/bin/atuin"
- name: Setup config dirctories
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: Copy config {{ context }}
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: base_info

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: base_info

View File

@@ -0,0 +1,47 @@
---
- name: Install dependencies
tags:
- install
ansible.builtin.package:
name:
- git
- git-delta
- name: Copy config
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: "Copy templates"
tags:
- config
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../templates
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'
- name: Copy config
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: base_info
- role: base_terminal

View File

@@ -16,7 +16,7 @@
- config
- nvim
register: nviminstall
changed_when: "nviminstall.stdout != ''"
changed_when: nviminstall.stdout != ''
ansible.builtin.shell: nvim --headless +q
args:
executable: /bin/bash

View File

@@ -0,0 +1,56 @@
---
- name: Install dependencies
tags:
- install
ansible.builtin.package:
name:
- neovim
- git
- name: Setup config dirctories
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: Copy config {{ context }}
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'
- name: Configure neovim
tags:
- config
- nvim
ansible.builtin.git:
repo: https://github.com/morten-olsen/nvim
dest: "{{ home }}/.config/nvim"
accept_newhostkey: true
clone: true
update: true
force: true
- name: Prepare neovim
tags:
- config
- nvim
register: nviminstall
changed_when: nviminstall.stdout != ''
ansible.builtin.shell: nvim --headless +q
args:
executable: /bin/bash

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: base_info
- role: base_terminal

View File

@@ -0,0 +1,51 @@
---
- name: Install dependencies
ansible.builtin.package:
name:
- git
- name: Clone nvm
tags:
- install
ansible.builtin.git:
accept_newhostkey: true
clone: true
force: true
recursive: false
repo: https://github.com/nvm-sh/nvm
dest: "{{ home }}/.nvm"
- name: Install node and set version
tags:
- config
register: nodeinstall
ansible.builtin.shell: source {{ home }}/.nvm/nvm.sh && nvm install 22
changed_when: "'is already installed' not in nodeinstall.stderr"
args:
executable: /bin/bash
- name: Setup config dirctories
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: Copy config {{ context }}
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: base_info
- role: base_terminal

View File

@@ -0,0 +1,14 @@
---
software_starship_mirror: "https://github.com/starship/starship/releases/download/"
software_starship_version: v1.20.1
software_starship_arch_map:
arm64: aarch64
aarch64: aarch64
software_starship_system_map:
Darwin: apple-darwin
Linux: unknown-linux-musl
software_starship_download_url: "{{ software_starship_mirror }}/{{ software_starship_version }}/starship-{{ software_starship_arch_map[ansible_architecture] }}-{{ software_starship_system_map[ansible_system] }}.tar.gz"
software_starship_download_dir: "/tmp/starship.tar.gz"
software_starship_unpack_dir: "/tmp/starship"
software_starship_unpack_file: "{{ software_starship_unpack_dir }}/starship"

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: base_info
- role: base_terminal

View File

@@ -1,30 +1,34 @@
- name: Download starship
tags: always
ansible.builtin.get_url:
url: "{{ download_url }}"
dest: "{{ download_dir }}"
mode: "0600"
url: "{{ software_starship_download_url }}"
dest: "{{ software_starship_download_dir }}"
- name: Create dir
tags: always
ansible.builtin.file:
path: "{{ unpack_dir }}"
mode: "0755"
path: "{{ software_starship_unpack_dir }}"
state: directory
- name: Extract starship
tags: always
ansible.builtin.unarchive:
src: "{{ download_dir }}"
dest: "{{ unpack_dir }}"
src: "{{ software_starship_download_dir }}"
dest: "{{ software_starship_unpack_dir }}"
- name: Ensure dir
tags: always
ansible.builtin.file:
mode: "0755"
path: "{{ home }}/.scripts"
state: directory
- name: Move bin
tags: always
ansible.builtin.copy:
remote_src: true
mode: 755
src: "{{ unpack_file }}"
dest: "{{ home }}/.scripts/atuin"
mode: "0755"
src: "{{ software_starship_unpack_file }}"
dest: "{{ home }}/.local/bin/starship"

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: base_info
- role: base_terminal

View File

@@ -0,0 +1,39 @@
---
- name: Copy config
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: "Copy templates"
tags:
- config
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../templates
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'
- name: Copy config
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: base_info
- role: base_terminal

View File

@@ -0,0 +1,54 @@
---
- name: Install core dependencies
tags:
- install
ansible.builtin.package:
name:
- zsh
- name: Set shell
become: true
tags:
- config
ansible.builtin.user:
name: "{{ username }}"
shell: /usr/bin/zsh
- name: Copy config
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: "Copy templates"
tags:
- config
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../templates
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'
- name: Copy config
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'

View File

@@ -1,2 +0,0 @@
dependencies:
- role: info

View File

@@ -1 +0,0 @@
export TMPDIR="${TMPDIR:-/tmp}"

View File

@@ -1,2 +0,0 @@
export PATH="$PATH:$HOME/.scripts"

View File

@@ -1,5 +0,0 @@
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye > /dev/null

View File

@@ -1,4 +0,0 @@
---
dependencies:
- role: info
- role: system

View File

@@ -1,55 +0,0 @@
---
- name: Install core dependencies
tags:
- install
ansible.builtin.package:
name:
- zsh
- name: Set shell
become: true
tags:
- config
ansible.builtin.user:
name: "{{ username }}"
shell: /usr/bin/zsh
- name: Install context dependencies
ansible.builtin.include_tasks: install.yml
loop: "{{ contexts }}"
loop_control:
loop_var: context
tags:
- config
- name: Install atuin
tags:
- install
include_role:
name: software/atuin
- name: Install starship
tags:
- install
include_role:
name: software/starship
- name: Setup node
tags:
- config
- install
include_tasks: "nvm.yml"
- name: Setup nvim
tags:
- config
- nvim
include_tasks: "nvim.yml"
- name: Configure contexts
ansible.builtin.include_tasks: config.yml
loop: "{{ contexts }}"
loop_control:
loop_var: context
tags:
- config

View File

@@ -1,19 +0,0 @@
- name: Clone nvm
tags:
- install
ansible.builtin.git:
accept_newhostkey: true
clone: true
force: true
recursive: false
repo: https://github.com/nvm-sh/nvm
dest: "{{ home }}/.nvm"
- name: Install node and set version
tags:
- config
register: nodeinstall
ansible.builtin.shell: source {{ home }}/.nvm/nvm.sh && nvm install 22
changed_when: "'is already installed' not in nodeinstall.stderr"
args:
executable: /bin/bash

View File

@@ -1,7 +1,15 @@
---
- name: Setup host
- name: Setup desktop
hosts: desktops
roles:
- role: terminal
- role: desktop
- role: docker
- role: env_terminal
- role: env_develop
- role: server_ssh
- role: env_desktop
- name: Setup android
hosts: android
roles:
- role: env_terminal
- role: env_develop
- role: server_ssh