1 Commits

Author SHA1 Message Date
1186cfe33f Update neovim role to work on Ubuntu 18.04 2022-05-03 20:08:13 +01:00
52 changed files with 119 additions and 579 deletions

View File

@@ -1,20 +0,0 @@
---
- hosts: localhost
roles:
- role: zsh
- role: neovim
- role: tmux
- role: system-info
- role: ag
- role: bat
- role: git
- role: tree
- role: llvm
- role: nodejs
- role: python
- role: wsl
when: '"WSL" in ansible_kernel'

View File

@@ -1,3 +0,0 @@
---
- import_playbook: Unix.yaml
- import_playbook: Windows.yaml

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,27 +7,8 @@
- name: clone config repo
win_git:
repo: git@code.infektor.net:config/AutoHotKey.git
dest: '{{autohotkey_repo_dir}}'
dest: '{{ansible_env.LOCALAPPDATA}}/AutoHotKey'
branch: master
- name: create 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
# TODO: - name: create scheduled task
# win_scheduled_task:

View File

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

View File

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

View File

@@ -1,13 +0,0 @@
---
- 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

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

View File

@@ -1,100 +0,0 @@
#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

@@ -1,15 +0,0 @@
---
- 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

@@ -1,14 +0,0 @@
---
- 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

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

View File

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

View File

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

View File

@@ -1,66 +0,0 @@
---
- name: get latest stable github release
uri:
url: https://api.github.com/repos/llvm/llvm-project/releases/latest
register: llvm_latest
- set_fact:
llvm_major_version:
'{{llvm_latest.json.tag_name[8:llvm_latest.json.tag_name.find(".")]}}'
- set_fact:
llvm_apt_repo_url:
'http://apt.llvm.org/{{ansible_distribution_release}}/'
llvm_apt_category:
'llvm-toolchain-{{ansible_distribution_release}}-{{llvm_major_version}}'
- name: add upstream deb repository
become: true
apt_repository:
repo: 'deb {{llvm_apt_repo_url}} {{llvm_apt_category}} main'
state: present
filename: llvm
update_cache: false
- name: add upstream deb-src repository
become: true
apt_repository:
repo: 'deb-src {{llvm_apt_repo_url}} {{llvm_apt_category}} main'
state: present
filename: llvm
update_cache: false
- name: add apt repository key
become: true
apt_key:
url: https://apt.llvm.org/llvm-snapshot.gpg.key
id: 6084F3CF814B57C1CF12EFD515CF4D18AF4F7421
state: present
- name: update apt cache
become: true
apt:
update_cache: true
- name: install apt packages
become: true
apt:
name:
- clang-{{llvm_major_version}}
- clang-format-{{llvm_major_version}}
- clang-tidy-{{llvm_major_version}}
- clang-tools-{{llvm_major_version}}
- clangd-{{llvm_major_version}}
- llvm-{{llvm_major_version}}
state: latest
install_recommends: true
- name: update alternatives
become: true
alternatives:
link: '/usr/bin/{{item}}'
name: '{{item}}'
path: '/usr/bin/{{item}}-{{llvm_major_version}}'
priority: '{{llvm_major_version}}0'
with_items:
- clang-format
- clangd

View File

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

View File

@@ -1,5 +0,0 @@
---
- include_tasks: '{{ansible_os_family}}.yaml'
when: ansible_os_family in ['Darwin', 'Windows']
- include_tasks: '{{ansible_distribution}}.yaml'
when: ansible_os_family not in ['Darwin', 'Windows']

View File

@@ -1,7 +1,11 @@
---
- name: install homebrew packages
homebrew:
name: neovim
name:
- neovim
- llvm
- node
- the_silver_searcher
state: latest
- include_tasks: unix.yaml

View File

@@ -1,13 +1,11 @@
---
- name: install apt packages
- name: install Debian-unstable apt packages
become: true
apt:
name:
- clang
- neovim
- clang-format
- clang-tidy
- clang-tools
- clangd
- llvm
- silversearcher-ag
state: latest
install_recommends: true

View File

@@ -1,8 +1,31 @@
---
- name: install apt package
become: true
apt:
name: neovim
state: latest
- include_tasks: '{{ansible_distribution}}-{{ansible_distribution_version}}.yaml'
- include_tasks: 'unix.yaml'
- include_tasks: unix.yaml
- 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

@@ -0,0 +1,34 @@
---
- name: get releases json from github
uri:
url: https://api.github.com/repos/neovim/neovim/releases
register: releases
- name: query the latest stable release
set_fact:
stable: '{{releases.json | json_query("[?tag_name==`stable`]")}}'
- name: query the nvim-linux64.deb.sha256sum asset
set_fact:
sha_asset: '{{stable[0].assets | json_query("[?name==`nvim-linux64.deb.sha256sum`]")}}'
- name: query the nvim-linux64.deb asset
set_fact:
deb_asset: '{{stable[0].assets | json_query("[?name==`nvim-linux64.deb`]")}}'
- name: create directory for downloads
file:
state: directory
path: ~/.cache/nvim/deb
- name: download nvim-linux64.deb with checksum
get_url:
url: '{{deb_asset[0].browser_download_url}}'
dest: ~/.cache/nvim/deb/nvim-linux64.deb
checksum: 'sha256:{{sha_asset[0].browser_download_url}}'
- name: install nvim-linux64.deb package
become: true
apt:
deb: ~/.cache/nvim/deb/nvim-linux64.deb
# TODO: clangd, clang-format, clang-tidy
- name: install Ubuntu-18.04 apt packages
become: true
apt:
name:
- silversearcher-ag

View File

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

View File

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

View File

@@ -1,28 +0,0 @@
---
- 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

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

View File

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

View File

@@ -1,11 +0,0 @@
---
- 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

@@ -1,11 +0,0 @@
---
- 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

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

View File

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

View File

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

View File

@@ -1,5 +0,0 @@
---
# 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

@@ -1,58 +0,0 @@
---
- 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

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

View File

@@ -1,5 +0,0 @@
---
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

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

View File

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

View File

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

View File

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

View File

@@ -1,31 +0,0 @@
---
- 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

@@ -1,17 +0,0 @@
---
- 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

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

View File

@@ -1,5 +0,0 @@
---
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
user:
name: '{{ansible_user_id}}'
name: '{{lookup("env", "USER")}}'
shell: '{{zsh.stdout}}'
become: true

9
unix.yaml Normal file
View File

@@ -0,0 +1,9 @@
---
- hosts: localhost
roles:
- role: zsh
- role: tmux
- role: neovim
- role: git
- role: python

20
windows.yaml Normal file
View File

@@ -0,0 +1,20 @@
---
- import_playbook: unix.yaml
- hosts: localhost
# FIXME: Roles which depend on the win_git module can't be in the same
# playbook on the first run because the wsl role hasn't added the win_git
# module to the modules path yet.
roles:
- role: wsl
- hosts: windows
roles:
- role: powershell
- role: neovim
- role: git
- role: python
- role: autohotkey
- role: 1password