19 Commits

Author SHA1 Message Date
f7a5e3728f Fix zsh role to set zsh as default shell 2022-05-27 20:15:41 +01:00
d1cfa8c98e Add obsidian role for macOS and Windows 2022-05-24 20:41:34 +01:00
64ecd88c93 Fix whitespace in powershell role 2022-05-24 19:05:36 +01:00
7642c62ecf Add windows-terminal role for Windows 2022-05-23 21:11:21 +01:00
1117ca00f7 Add system-info role for Windows 2022-05-22 14:05:05 +01:00
de8c0a119d Add macOS.ahk scheduled task 2022-05-22 10:07:33 +01:00
2eaf11b8a5 Add distrobox role for Debian 2022-05-21 23:34:02 +01:00
bcbaa9dfcf Change nvim-qt Windows shortcut working directory 2022-05-12 21:02:53 +01:00
d6e09f2317 Add firefox role for Windows 2022-05-12 20:50:03 +01:00
179273c22b Add git chocolatey package install 2022-05-12 20:29:45 +01:00
51d48f7f49 Actually use llvm role 2022-05-12 20:10:09 +01:00
c2f1cd3201 Add bat role for Debian and macOS 2022-05-12 19:58:43 +01:00
c9d2e66438 Add tree role for Debina, macOS, and Windows 2022-05-12 19:58:15 +01:00
f6e60b8417 Remove macOS duplication 2022-05-11 22:43:44 +01:00
e1745bd162 Fix python Debian package install 2022-05-11 22:43:25 +01:00
44c1e5ccff Add nodejs role for Debian, macOS, and Windows 2022-05-11 22:33:18 +01:00
5dfb92522e Add ag role for Debian, macOS, and Windows 2022-05-11 22:27:18 +01:00
14c14353f8 Add llvm role for Debian sid, Ubuntu 18.04, macOS, and Windows 2022-05-08 19:59:07 +01:00
3061ade54f Don't install llvm (and related) with neovim 2022-05-07 15:05:20 +01:00
50 changed files with 557 additions and 85 deletions

View File

@@ -14,7 +14,18 @@
roles: roles:
- role: powershell - role: powershell
- role: neovim - role: neovim
- role: system-info
- role: ag
- role: git - role: git
- role: tree
- role: llvm
- role: nodejs
- role: python - role: python
- role: autohotkey
- role: 1password - role: 1password
- role: autohotkey
- role: firefox
- role: obsidian
- role: windows-terminal

7
macOS.yaml Normal file
View File

@@ -0,0 +1,7 @@
---
- import_playbook: unix.yaml
- hosts: localhost
roles:
- role: obsidian

View File

@@ -0,0 +1,5 @@
---
- name: install homebrew package
apt:
name: the_silver_searcher
state: latest

View File

@@ -0,0 +1,6 @@
---
- name: install apt package
become: true
apt:
name: silversearcher-ag
state: latest

View File

@@ -0,0 +1,5 @@
---
- name: install choco package
win_chocolatey:
name: ag
state: latest

2
roles/ag/tasks/main.yaml Normal file
View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -7,8 +7,27 @@
- name: clone config repo - name: clone config repo
win_git: win_git:
repo: git@code.infektor.net:config/AutoHotKey.git repo: git@code.infektor.net:config/AutoHotKey.git
dest: '{{ansible_env.LOCALAPPDATA}}/AutoHotKey' dest: '{{autohotkey_repo_dir}}'
branch: master branch: master
# TODO: - name: create scheduled task - name: create scheduled task
# win_scheduled_task: win_scheduled_task:
path: Benie
name: macOS.ahk
state: present
enable: true
triggers:
- type: logon
enabled: true
- type: registration
enabled: true
actions:
- path: '{{autohotkey_repo_dir}}/macOS.ahk'
disallow_start_if_on_batteries: false
stop_if_going_on_batteries: false
execution_time_limit: PT0S
logon_type: interactive_token
multiple_instances: 3
run_level: highest
start_when_available: true
wake_to_run: false

View File

@@ -0,0 +1,2 @@
---
autohotkey_repo_dir: '{{ansible_env.LOCALAPPDATA}}/AutoHotKey'

View File

@@ -0,0 +1,5 @@
---
- name: install homebrew package
homebrew:
name: bat
state: latest

View File

@@ -0,0 +1,13 @@
---
- name: install apt package
become: true
apt:
name: bat
state: latest
- name: update bat alternative
become: true
alternatives:
name: bat
path: /usr/bin/batcat
link: /usr/local/bin/bat

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -0,0 +1,100 @@
#compdef distrobox
_distrobox() {
local context curcontext="$curcontext" state line ret=1
typeset -A opt_args
_arguments -C \
'(-h --help)'{-h,--help}'[show help]' \
'(-V --version)'{-V,--version}'[show version]' \
'1: :->command' \
'*:: :->arguments'
case $state in;
(command)
local commands;
commands=(
'create:create the distrobox'
'enter:enter the distrobox'
'export:application and service exporting'
'list:list containers'
'rm:remove containers'
'stop:stop containers'
)
_describe -t commands 'distrobox command' commands "$@" \
&& ret=0 ;;
(arguments)
case $line[1] in
(create)
_arguments \
'(-h --help)'{-h,--help}'[show this message]' \
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' \
'(-V --version)'{-V,--version}'[show version]' \
'(-i --image)'{-i,--image}'[image to use for the container]: :' \
'(-n --name)'{-n,--name}'[name for the distrobox]: :' \
'(-H --home)'{-H,--home}'[select a custom HOME directory for the container]: :' \
'*--volume[additional volumes to add to the container]: :_directories' \
'(-a --additional-flags)'{-a,--additional-flags}'[additional flags to pass to the container manager command]: :' \
'(-I --init)'{-I,--init}'[use init system (like systemd) inside the container]: :' \
'(-d --dry-run)'{-d,--dry-run}'[only print the container manager command generated]' \
&& ret=0 ;;
(enter)
_arguments -S \
'(-h --help)'{-h,--help}'[show this message]' \
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' \
'(-V --version)'{-V,--version}'[show version]' \
'(-n --name)'{-n,--name}'[name for the distrobox]: :' \
'(-T --no-tty)'{-T,--no-tty}'[do not instantiate a tty]' \
'(-a --additional-flags)'{-a,--additional-flags}'[additional flags to pass to the container manager command]: :' \
'(-d --dry-run)'{-d,--dry-run}'[only print the container manager command generated]' \
'(-e --)'{-e,--}'[end arguments execute the rest as command to execute at login]:*:' \
&& ret=0 ;;
(export)
_arguments -S \
'(-h --help)'{-h,--help}'[show this message]' \
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' \
'(-V --version)'{-V,--version}'[show version]' \
'(-a --app)'{-a,--app}'[name of the application to export]: :' \
'(-b --bin)'{-b,--bin}'[absolute path of the binary to export]: :' \
'(-s --service)'{-s,--service}'[name of the service to export]: :' \
'(-d --delete)'{-d,--delete}'[delete exported application or service]: :' \
'(-el --export-label)'{-el,--export-label}'[label to add to exported application name]: :' \
'(-ep --export-path)'{-ep,--export-path}'[path where to export the binary]: :' \
'(-ef --extra-flags)'{-ef,--export-flags}'[extra flags to add to the command]: :' \
'(-S --sudo)'{-S,--sudo}'[specify if the exported item should be run as sudo]' \
&& ret=0 ;;
(list)
_arguments -S \
'(-h --help)'{-h,--help}'[show this message]' \
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' \
'(-V --version)'{-V,--version}'[show version]' \
&& ret=0 ;;
(rm)
_arguments -S \
'(-h --help)'{-h,--help}'[show this message]' \
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' \
'(-V --version)'{-V,--version}'[show version]' \
'(-n --name)'{-n,--name}'[name for the distrobox]: :' \
'(-f --force)'{-f,--force}'[force deletion]' \
&& ret=0 ;;
(stop)
_arguments -S \
'(-h --help)'{-h,--help}'[show this message]' \
'(-v --verbose)'{-v,--verbose}'[show more verbosity]' \
'(-V --version)'{-V,--version}'[show version]' \
'(-n --name)'{-n,--name}'[name for the distrobox]: :' \
'(-Y --yes)'{-Y,--yes}'[non-interactive, stop without asking]' \
&& ret=0 ;;
esac ;;
esac
return $ret
}
_distrobox "$@"

View File

@@ -0,0 +1,15 @@
---
- name: install apt package
when: ansible_distribution == "Debian" and
ansible_distribution_version == "unstable"
become: true
apt:
name: distrobox
state: latest
- name: install distrobox zsh completions
when: ansible_distribution == "Debian" and
ansible_distribution_version == "unstable"
copy:
src: _distrobox
dest: '{{ansible_env.HOME}}/.local/share/zsh/site-functions/_distrobox'

View File

@@ -0,0 +1,14 @@
---
- name: install chocolatey package
win_chocolatey:
name: firefox
package_params: >-
/l:en-GB
/NoDesktopShortcut
/NoAutoUpdate
state: latest
# - TODO: create extensions directory
# file:
# path: '{{ansible_env.ProgramFiles}}/Mozilla Firefox/distribution/extensions'
# state: directory

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -1,4 +1,15 @@
--- ---
- name: install chocolatey package
win_chocolatey:
name: git
package_params: >-
/GitAndUnixToolsOnPath
/NoShellIntegration
/NoGuiHereIntegration
/NoCredentialManager
/NoOpenSSH
state: latest
- name: clone config repos - name: clone config repos
win_git: win_git:
repo: '{{item.repo}}' repo: '{{item.repo}}'
@@ -6,4 +17,7 @@
version: master version: master
with_items: '{{git_config_repos}}' with_items: '{{git_config_repos}}'
# TODO: - name: install pip packages # - TODO: install pip packages
# win_pip:
# name: '{{git_pip_packages}}'
# state: latest

View File

@@ -0,0 +1,5 @@
---
- name: install homebrew package
homebrew:
name: llvm
state: latest

View File

@@ -0,0 +1,13 @@
---
- name: install apt packages
become: true
apt:
name:
- clang
- clang-format
- clang-tidy
- clang-tools
- clangd
- llvm
state: latest
install_recommends: true

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_distribution}}-{{ansible_distribution_version}}.yaml'

View File

@@ -0,0 +1,50 @@
---
- name: get list of releases from github
uri:
url: https://api.github.com/repos/llvm/llvm-project/releases
register: releases
- name: select latest release with Ubuntu binaries
set_fact:
release: '{{releases.json | json_query("[?assets | [?contains(name, `x86_64-linux-gnu-ubuntu`)]] | [0]")}}'
- name: select from latest available release with x86_64-linux-gnu-ubuntu asset
set_fact:
asset: '{{release | json_query("assets | [?contains(name, `x86_64-linux-gnu-ubuntu`)] | [?ends_with(name, `.tar.xz`)] | [0]")}}'
- name: process release name for /usr/local/lib/{{package_name}}
set_fact:
package_name: '{{release.name | lower | regex_replace(" (\d+)\.\d+\.\d+", "-\1")}}'
- name: set path for archive download
set_fact:
archive_path: '/tmp/{{asset.name}}'
- name: download release archive
get_url:
url: '{{asset.browser_download_url}}'
dest: '{{archive_path}}'
- name: create package directory
become: true
file:
path: '/usr/local/lib/{{package_name}}'
state: directory
# TODO: don't extract when not actually doing a n update
- name: extract release archive
become: true
unarchive:
src: '{{archive_path}}'
dest: '/usr/local/lib/{{package_name}}'
extra_opts: ['--strip-components', '1']
- name: create symlinks from /usr/local/lib/{package_name}} to /usr/local/bin
become: true
file:
src: '{{item}}'
dest: '/usr/local/bin/{{item | basename}}'
state: link
with_fileglob: '/usr/local/lib/{{package_name}}/bin/*'
# TODO: cleanup old installs?

View File

@@ -0,0 +1,5 @@
---
- name: install chocolatey package
win_chocolatey:
name: llvm
state: latest

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -1,23 +1,7 @@
--- ---
- name: install homebrew packages - name: install homebrew packages
homebrew: homebrew:
name: name: neovim
- neovim
- llvm
- node
- the_silver_searcher
state: latest state: latest
- name: clone config repo - include_tasks: unix.yaml
git:
repo: git@code.infektor.net:config/vim.git
dest: ~/.config/nvim
version: master
# TODO: - name: set repo email
- name: install pip packages
pip:
name: '{{neovim_pip_packages}}'
state: latest
extra_args: --user

View File

@@ -2,52 +2,7 @@
- name: install apt package - name: install apt package
become: true become: true
apt: apt:
name: name: neovim
- neovim
- clang-format
- clang-tidy
- clangd
- silversearcher-ag
state: latest state: latest
- name: clone config repo - include_tasks: unix.yaml
git:
repo: git@code.infektor.net:config/vim.git
dest: ~/.config/nvim
version: master
# TODO: - name: set repo email
- name: install pip packages
pip:
name: '{{neovim_pip_packages}}'
state: latest
extra_args: --user
- name: nodejs get json containing latest version
uri:
url: https://nodejs.org/dist/index.json
register: latest
- name: nodejs create directory for downloaded package
file:
state: directory
dest: ~/.local/src
- name: nodejs download latest package
get_url:
url: 'https://nodejs.org/dist/{{latest.json[0].version}}/node-{{latest.json[0].version}}-linux-x64.tar.gz'
dest: ~/.local/src/node.tar.gz
- name: nodejs extract downloaded package
unarchive:
src: ~/.local/src/node.tar.gz
dest: ~/.local/src
remote_src: true
- name: nodejs create symlink links
file:
state: link
src: '~/.local/src/node-{{latest.json[0].version}}-linux-x64/bin/{{item}}'
dest: '~/.local/bin/{{item}}'
with_items: [corepack, node, npm, npx]

View File

@@ -1,11 +1,7 @@
--- ---
- name: install choco packages - name: install choco packages
win_chocolatey: win_chocolatey:
name: name: neovim
- neovim
- ag
- llvm
- nodejs
state: latest state: latest
- name: clone config repo - name: clone config repo
@@ -14,15 +10,16 @@
dest: '{{ansible_env.LOCALAPPDATA}}/nvim' dest: '{{ansible_env.LOCALAPPDATA}}/nvim'
version: master version: master
# TODO: - name: neovim set repo email # - TODO: neovim set repo email
# win_git_config: # win_git_config:
# TODO: - name: neovim install pip packages # - TODO: neovim install pip packages
# win_pip: # win_pip:
# name: '{{neovim_pip_packages}}' # name: '{{neovim_pip_packages}}'
# state: latest # state: latest
- name: create nvim start menu shortcut - name: create nvim start menu shortcut
win_shortcut: win_shortcut:
src: '{{ansible_env.ChocolateyToolsLocation}}/neovim/nvim-win64/bin/nvim-qt.exe' src: '{{ansible_env.ChocolateyToolsLocation}}/neovim/nvim-win64/bin/nvim-qt.exe'
dest: '{{ansible_env.ProgramData}}/Microsoft/Windows/Start Menu/Programs/nvim.lnk' dest: '{{ansible_env.ProgramData}}/Microsoft/Windows/Start Menu/Programs/nvim-qt.lnk'
icon: '{{ansible_env.ChocolateyToolsLocation}}/neovim/nvim-win64/bin/nvim-qt.exe,0' icon: '{{ansible_env.ChocolateyToolsLocation}}/neovim/nvim-win64/bin/nvim-qt.exe,0'
directory: '{{ansible_env.USERPROFILE}}'

View File

@@ -0,0 +1,14 @@
---
- name: clone config repo
git:
repo: git@code.infektor.net:config/vim.git
dest: ~/.config/nvim
version: master
# TODO: - name: set repo email
- name: install pip packages
pip:
name: '{{neovim_pip_packages}}'
state: latest
extra_args: --user

View File

@@ -0,0 +1,5 @@
---
- name: install homebrew package
homebrew:
name: node
state: latest

View File

@@ -0,0 +1,28 @@
---
- name: get json containing latest version
uri:
url: https://nodejs.org/dist/index.json
register: latest
- name: create directory for downloaded package
file:
state: directory
dest: ~/.local/src
- name: download latest package
get_url:
url: 'https://nodejs.org/dist/{{latest.json[0].version}}/node-{{latest.json[0].version}}-linux-x64.tar.gz'
dest: ~/.local/src/node.tar.gz
- name: extract downloaded package
unarchive:
src: ~/.local/src/node.tar.gz
dest: ~/.local/src
remote_src: true
- name: create symlink links
file:
state: link
src: '~/.local/src/node-{{latest.json[0].version}}-linux-x64/bin/{{item}}'
dest: '~/.local/bin/{{item}}'
with_items: [corepack, node, npm, npx]

View File

@@ -0,0 +1,5 @@
---
- name: install choco package
win_chocolatey:
name: nodejs
state: latest

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -0,0 +1,11 @@
---
- name: install homebrew package
homebrew:
name: obsidian
state: latest
- name: clone notes repository
git:
repo: git@github.com:kbenzie/notes.git
dest: '{{ansible_env.HOME}}/Documents/Notes'
branch: main

View File

@@ -0,0 +1,11 @@
---
- name: install chocolatey package
win_chocolatey:
name: obsidian
state: latest
- name: clone notes repository
win_git:
repo: git@github.com:kbenzie/notes.git
dest: '{{ansible_env.USERPROFILE}}/Documents/Notes'
branch: main

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -7,7 +7,7 @@
- name: install chocolatey package - name: install chocolatey package
win_chocolatey: win_chocolatey:
name: Cmder name: Cmder
state: latest state: latest
- name: install PsReadline module - name: install PsReadline module

View File

@@ -1,5 +1,6 @@
--- ---
- name: install apt packages - name: install apt packages
become: true
apt: apt:
name: name:
- python3 - python3

View File

@@ -0,0 +1,4 @@
---
# TODO:
# cp $script_dir/system-info.plist ~/Library/LaunchAgents/system-info.plist
# launchctl load -w ~/Library/LaunchAgents/system-info.plist

View File

@@ -0,0 +1,5 @@
---
# TODO:
# cp $script_dir/system-info.service ~/.config/systemd/user/system-info.service
# systemctl --user enable system-info
# systemctl --user start system-info

View File

@@ -0,0 +1,58 @@
---
- name: install chocolatey packages
win_chocolatey:
name: openhardwaremonitor
state: latest
# - TODO: update config file
# C:\ProgramData\chocolatey\lib\OpenHardwareMonitor\tools\OpenHardwareMonitor\OpenHardwareMonitor.config
- name: create OpenHardwareMonitor scheduled task
win_scheduled_task:
path: Benie
name: OpenHardwareMonitor
state: present
enable: true
triggers:
- type: logon
enabled: true
- type: registration
enabled: true
actions:
- path: '{{openhardwaremonitor_exe}}'
working_directory: '{{openhardwaremonitor_install_dir}}'
disallow_start_if_on_batteries: false
stop_if_going_on_batteries: false
execution_time_limit: PT0S
logon_type: interactive_token
multiple_instances: 3
run_level: highest
start_when_available: true
wake_to_run: false
- name: create system-info-WSL.sh scheduled task
win_scheduled_task:
path: Benie
name: system-info-WSL.sh
state: present
enable: true
triggers:
- type: logon
enabled: true
- type: registration
enabled: true
actions:
- path: '{{wsl_exe}}'
arguments: '-d Debian -e /home/benie/.config/tmux/system-info/system-info-WSL.sh'
disallow_start_if_on_batteries: false
stop_if_going_on_batteries: false
execution_time_limit: PT0S
logon_type: password
username: '{{ansible_user}}'
password: '{{ansible_password}}'
multiple_instances: 3
run_level: limited
start_when_available: true
wake_to_run: false
# - TODO: configure firewall

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -0,0 +1,5 @@
---
openhardwaremonitor_exe: 'OpenHardwareMonitor.exe'
openhardwaremonitor_install_dir: '{{ansible_env.ProgramData}}\chocolatey\lib\OpenHardwareMonitor\tools\OpenHardwareMonitor'
wsl_exe: '{{ansible_env.SystemRoot}}/System32/wsl.exe'

View File

@@ -0,0 +1,5 @@
---
- name: install homebrew pacakge
homebrew:
name: tree
state: latest

View File

@@ -0,0 +1,6 @@
---
- name: install apt package
become: true
apt:
name: tree
state: latest

View File

@@ -0,0 +1,5 @@
---
- name: install choco package
win_chocolatey:
name: tree
state: latest

View File

@@ -0,0 +1,2 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'

View File

@@ -0,0 +1,31 @@
---
- name: get list of existing actions
set_fact:
actions: '{{settings.actions}}'
action_keys: '{{settings.actions | json_query("[].keys")}}'
- name: add next tab action key mapping
when: '"alt+shift+]" not in action_keys'
set_fact:
actions: >-
{{
actions + [{
"command": {"action": "nextTab", "tabSwitcherMode": "disabled"},
"keys": "alt+shift+]"
}]
}}
- name: add previous tab action key mapping
when: '"alt+shift+[" not in action_keys'
set_fact:
actions: >-
{{
actions + [{
"command": {"action": "prevTab", "tabSwitcherMode": "disabled"},
"keys": "alt+shift+["
}]
}}
- name: set actions in settings
set_fact:
settings: '{{settings | combine({"actions": actions})}}'

View File

@@ -0,0 +1,17 @@
---
- name: read settings.json file
slurp:
src: '{{windows_terminal_settings_json}}'
register: slurped_settings
- name: decode settings into fact
set_fact:
settings: '{{slurped_settings.content | b64decode | from_json}}'
- import_tasks: actions.yaml
# TODO: - import_tasks: profiles.yaml
- name: write settings.json file
copy:
content: '{{settings | to_nice_json}}'
dest: '{{windows_terminal_settings_json}}'

View File

@@ -0,0 +1,5 @@
---
# TODO: defaults
# TODO: modify powershell commandline
# TODO: modify command prompt commandline
# TODO: modify debian icon

View File

@@ -0,0 +1,5 @@
---
windows_terminal_local_app_data:
'{{ansible_env.LOCALAPPDATA}}/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe'
windows_terminal_settings_json:
'{{windows_terminal_local_app_data}}/LocalState/settings.json'

View File

@@ -78,6 +78,6 @@
- name: set default shell - name: set default shell
user: user:
name: '{{lookup("env", "USER")}}' name: '{{ansible_user_id}}'
shell: '{{zsh.stdout}}' shell: '{{zsh.stdout}}'
become: true become: true

View File

@@ -3,7 +3,15 @@
roles: roles:
- role: zsh - role: zsh
- role: tmux
- role: neovim - role: neovim
- role: tmux
- role: system-info
- role: ag
- role: bat
- role: git - role: git
- role: tree
- role: llvm
- role: nodejs
- role: python - role: python