6 Commits

Author SHA1 Message Date
5728aba7df Don't include system-info role in WSL 2022-08-27 17:44:22 +01:00
76b6d63064 Improve bat role 2022-08-27 17:40:00 +01:00
189371d7f2 Fix macOS playbook import 2022-08-12 21:16:29 +01:00
491a9a07b5 Merge op role into 1password role
Additionally:

* Stop using Chocolatey packages for 1password as they are not up to
  date, instead download and install directly.
* Switch to apt repository on Debian.
* Add zsh completions for macOS and Dabian.
* Add powershell completions for Windows.
2022-08-12 21:16:29 +01:00
c4e87f2022 Implement system-info role on Debian 2022-07-29 18:01:03 +01:00
09e7ec3ad4 Merge op role into 1password role
Additionally:

* Stop using Chocolatey packages for 1password as they are not up to
  date, instead download and install directly.
* Switch to apt repository on Debian.
* Add zsh completions for macOS and Dabian.
* Add powershell completions for Windows.
2022-07-03 11:25:05 +01:00
20 changed files with 274 additions and 142 deletions

View File

@@ -6,17 +6,19 @@
- role: neovim - role: neovim
- role: tmux - role: tmux
- role: system-info - role: system-info
when: '"WSL" not in ansible_kernel'
- role: ag - role: ag
- role: bat - role: bat
- role: fzf - role: fzf
- role: git - role: git
- role: op
- role: tree - role: tree
- role: llvm - role: llvm
- role: nodejs - role: nodejs
- role: python - role: python
- role: 1password
- role: wsl - role: wsl
when: '"WSL" in ansible_kernel' when: '"WSL" in ansible_kernel'

View File

@@ -7,9 +7,9 @@
- role: system-info - role: system-info
- role: ag - role: ag
- role: bat
- role: fzf - role: fzf
- role: git - role: git
- role: op
- role: tree - role: tree
- role: llvm - role: llvm

View File

@@ -1,5 +1,5 @@
--- ---
- import_playbook: unix.yaml - import_playbook: Unix.yaml
- hosts: localhost - hosts: localhost

View File

@@ -1,5 +1,9 @@
--- ---
- name: install homebrew package - name: install homebrew package
homebrew_cask: homebrew_cask:
name: 1password name:
- 1password
- 1password-cli
state: latest state: latest
- include_tasks: zsh-completion.yaml

View File

@@ -1 +1,38 @@
# TODO: https://support.1password.com/install-linux/#debian-or-ubuntu ---
- name: add apt signing key
become: true
apt_key:
url: https://downloads.1password.com/linux/keys/1password.asc
keyring: /etc/apt/trusted.gpg.d/1password-archive-keyring.gpg
state: present
- when: ansible_machine == 'x86_64'
set_fact:
arch: amd64
- assert:
that: arch is defined
fail_msg: 'Architecture not currently supported: {{ansible_machine}}'
- name: add apt repository
become: true
apt_repository:
repo: >-
deb [arch={{arch}}
signed-by=/etc/apt/trusted.gpg.d/1password-archive-keyring.gpg]
https://downloads.1password.com/linux/debian/{{arch}} stable main
- name: install gui package
when: '"WSL" not in ansible_kernel'
become: true
apt:
name: 1password
state: latest
- name: install cli package
become: true
apt:
name: 1password-cli
state: latest
- include_tasks: zsh-completion.yaml

View File

@@ -1,12 +1,107 @@
--- ---
- name: install chocolatey package # NOTE: The 1Password chocolatey packages are not up to date.
win_chocolatey:
name: # GUI
- 1password - set_fact:
state: latest app_exe: '{{ansible_env.LOCALAPPDATA}}/1Password/app/8/1Password.exe'
installer_exe: '{{ansible_env.TEMP}}/1PasswordSetup-latest.exe'
- name: check if already installed
win_stat:
path: '{{app_exe}}'
register: app_stat
- name: get installed version
when: app_stat.stat.exists == True
win_command: '{{app_exe}} --version'
register: app_version
changed_when: false
- when: app_stat.stat.exists == True
set_fact:
installed_version: '{{app_version.stdout.strip()}}'
- name: download latest installer
win_get_url:
url: https://downloads.1password.com/win/1PasswordSetup-latest.exe
dest: '{{installer_exe}}'
- name: get installer version
win_shell: |
(Get-ItemProperty {{installer_exe}}).VersionInfo.ProductVersion
register: installer_product_version
changed_when: false
# FIXME: The [5:] is to account for a mystery "\e[6 q" prefix, not sure if this
# is consistent across machines or some other oddity.
- set_fact:
installer_version: '{{installer_product_version.stdout.strip()[5:]}}'
- name: run installer
when: installed_version is not defined or installed_version != installer_version
win_command: '{{installer_exe}}'
- name: create start menu shortcut - name: create start menu shortcut
win_shortcut: win_shortcut:
src: '{{ansible_env.LOCALAPPDATA}}/1Password/app/7/1Password.exe' src: '{{app_exe}}'
dest: '{{ansible_env.ProgramData}}/Microsoft/Windows/Start Menu/Programs/1Password.lnk' dest: '{{ansible_env.ProgramData}}/Microsoft/Windows/Start Menu/Programs/1Password.lnk'
icon: '{{ansible_env.LOCALAPPDATA}}/1Password/app/7/1Password.exe,0' icon: '{{app_exe}},0'
# CLI
- set_fact:
cli_dir: '{{ansible_env.LOCALAPPDATA}}\1Password\cli'
cli_zip: '{{ansible_env.TEMP}}/op_windows_amd64.zip'
- set_fact:
cli_exe: '{{cli_dir}}\op.exe'
- name: check if op already installed
win_stat:
path: '{{cli_exe}}'
register: cli_stat
- name: get installed op version
when: cli_stat.stat.exists == True
win_command: '{{cli_exe}} --version'
register: cli_version
changed_when: false
- when: cli_stat.stat.exists == True
set_fact:
cli_installed_version: '{{cli_version.stdout.strip()}}'
- name: get list of op releases
win_uri:
url: https://raw.githubusercontent.com/kbenzie/op-release-scraper/main/op-releases.json
return_content: true
register: releases
- set_fact:
latest: '{{releases.json[0]}}'
- name: download latest op zip archive
when: cli_installed_version is not defined or cli_installed_version != latest.version
win_get_url:
url: '{{latest.downloads.Windows.amd64}}'
dest: '{{cli_zip}}'
- name: unzip op zip archive
when: cli_installed_version is not defined or cli_installed_version != latest.version
win_unzip:
src: '{{cli_zip}}'
dest: '{{cli_dir}}'
- name: add op install directory to user PATH
win_path:
scope: user
name: Path
elements: '{{cli_dir}}'
- name: get op powershell completion script
win_command: op completion powershell
register: powershell_completion_script
changed_when: false
- name: create op powershell completion file
win_copy:
content: '{{powershell_completion_script.stdout}}'
dest: '{{cli_dir}}/opProfile.psm1'

View File

@@ -0,0 +1,10 @@
---
- name: get op zsh completion script
command: op completion zsh
register: zsh_completion_script
changed_when: false
- name: create op zsh completion file
copy:
content: '{{zsh_completion_script.stdout}}'
dest: ~/.local/share/zsh/site-functions/_op

View File

@@ -1,13 +1,13 @@
--- ---
- name: install apt package - set_fact:
become: true use_github: '{{
apt: ansible_distribution == "Ubuntu" and
name: bat ansible_distribution_version == "18.04"
state: latest }}'
- debug: msg={{use_github}}
- name: update bat alternative - when: use_github
become: true include_tasks: deb.yaml
alternatives:
name: bat - when: not use_github
path: /usr/bin/batcat include_tasks: apt.yaml
link: /usr/local/bin/bat

View File

@@ -1,5 +1,5 @@
--- ---
- name: install chocolatey package - name: install chocolatey package
win_chocolatey: win_chocolatey:
name: op name: Bat
state: latest state: latest

13
roles/bat/tasks/apt.yaml Normal file
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

65
roles/bat/tasks/deb.yaml Normal file
View File

@@ -0,0 +1,65 @@
---
- name: get latest github release
uri:
url: https://api.github.com/repos/sharkdp/bat/releases/latest
register: latest
- set_fact:
latest_version: '{{latest.json.tag_name[1:]}}'
bat_exe: '/usr/bin/bat'
- name: check if already installed
stat:
path: '{{bat_exe}}'
register: bat_stat
- name: get installed version
when: bat_stat.stat.exists == True
command: '{{bat_exe}} --version'
register: bat_version
changed_when: false
- when: bat_stat.stat.exists == True
set_fact:
installed_version:
'{{bat_version.stdout.strip() | regex_replace("^.*(\d+\.\d+\.\d+).*$", "\1")}}'
- when: ansible_machine == "x86_64"
set_fact:
arch: amd64
- assert:
that: arch is defined
fail_msg: 'Architecture not currently supported: {{ansible_machine}}'
- set_fact:
assets: '{{latest.json.assets}}'
asset_query: '[?contains(name, `bat-musl_`)] | [?contains(name, `amd64.deb`)] | [0]'
pkg_dir: '{{ansible_env.HOME}}/.local/pkg/bat'
- set_fact:
asset: '{{assets | to_json | from_json | json_query(asset_query)}}'
bat_deb: '{{pkg_dir}}/bat.deb'
- name: create directory for deb file download
file:
state: directory
path: '{{pkg_dir}}'
- name: download .deb file
when: installed_version is not defined or installed_version != latest_version
get_url:
url: '{{asset.browser_download_url}}'
dest: '{{bat_deb}}'
- name: install .deb file
when: installed_version is not defined or installed_version != latest_version
become: true
apt:
deb: '{{bat_deb}}'
- name: remove .deb file
when: installed_version is not defined or installed_version != latest_version
file:
state: absent
path: '{{bat_deb}}'
changed_when: false

View File

@@ -1,5 +0,0 @@
---
- name: install homebrew package
homebrew_cask:
name: 1password-cli
state: latest

View File

@@ -1,38 +0,0 @@
---
- name: get html of latest versions
uri:
url: https://raw.githubusercontent.com/kbenzie/op-release-scraper/main/op-releases.json
register: op_releases
- when: ansible_machine == "x86"
set_fact: {op_arch: '386'}
- when: ansible_machine == "x86_64"
set_fact: {op_arch: 'amd64'}
- when: ansible_machine == "arm"
set_fact: {op_arch: 'arm'}
- when: ansible_machine == "arm64"
set_fact: {op_arch: 'arm64'}
- set_fact:
op_zip_url: '{{op_releases.json[0].downloads.Linux[op_arch]}}'
- name: create directory for downloaded package
file:
state: directory
dest: ~/.local/src/op
- name: download latest release package
get_url:
url: '{{op_zip_url}}'
dest: ~/.local/src/op/op.zip
- name: extract zip package
unarchive:
src: ~/.local/src/op/op.zip
dest: ~/.local/src/op
- name: create symbolic links
file:
src: ~/.local/src/op/op
dest: ~/.local/bin/op
state: link

View File

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

View File

@@ -1,5 +1,25 @@
--- ---
# TODO: - name: install apt packages
# cp $script_dir/system-info.service ~/.config/systemd/user/system-info.service become: true
# systemctl --user enable system-info apt:
# systemctl --user start system-info name:
- gawk
- sysstat
state: latest
- name: create systemd user unit directory
file:
state: directory
dest: ~/.config/systemd/user
- name: install system-info systemd unit
copy:
src: ~/.config/tmux/system-info/system-info.service
dest: ~/.config/systemd/user/system-info.service
- name: enable system-info service
systemd:
name: system-info
scope: user
enabled: true
state: started

View File

@@ -1,3 +0,0 @@
---
- set_fact:
download_url: https://cdn-2.webcatalog.io/webcatalog/WebCatalog-{{latest.version}}-universal.dmg

View File

@@ -1,31 +0,0 @@
---
- assert: {that: [ansible_machine == 'x86_64']}
- set_fact:
filename: 'WebCatalog-{{latest.version}}.AppImage'
# TODO: Support arm64: 'WebCatalog-{{latest.version}}-arm64.AppImage'
- name: create directory for download
file:
state: directory
dest: ~/.local/src/webcatalog
- name: download AppImage
get_url:
url: 'https://cdn-2.webcatalog.io/webcatalog/{{filename}}'
dest: '~/.local/src/webcatalog/{{filename}}'
- name: make AppImage executable
file:
dest: '~/.local/src/webcatalog/{{filename}}'
mode: a+x
- name: create symbolic link
file:
src: '~/.local/src/webcatalog/{{filename}}'
dest: '~/.local/bin/WebCatalog'
state: link
- name: create desktop file
template:
dest: io.webcatalog.WebCatalog.desktop

View File

@@ -1,5 +0,0 @@
---
- set_fact:
filename: WebCatalog%20Setup%20{{latest.version}}.exe
- name: download

View File

@@ -1,19 +0,0 @@
---
- name: get latest releases
uri:
url: https://raw.githubusercontent.com/kbenzie/webcatalog-release-scraper/main/webcatalog-releases.json
register: releases
- set_fact:
latest: '{{releases.json[0]}}'
- include_tasks: '{{ansible_os_family}}.yaml'
# TODO: Generate these links from the changelog from 42.0.0 up
- debug: msg=https://cdn-2.webcatalog.io/webcatalog/WebCatalog-{{latest.version}}-universal.dmg
- debug: msg=https://cdn-2.webcatalog.io/webcatalog/WebCatalog%20Setup%20{{latest.version}}.exe
- debug: msg=https://cdn-2.webcatalog.io/webcatalog/WebCatalog-{{latest.version}}.AppImage
- debug: msg=https://cdn-2.webcatalog.io/webcatalog/WebCatalog-{{latest.version}}-arm64.AppImage
# NOTE: Otherwise use https://github.com/webcatalog/webcatalog-legacy/releases

View File

@@ -1,11 +0,0 @@
[Desktop Entry]
Name=WebCatalog
Exec={{command}}
Terminal=false
Type=Application
Icon=webcatalog
StartupWMClass=WebCatalog
X-AppImage-Version={{latest.version}}
Comment=Turn Any Websites Into Real Desktop Apps
MimeType=x-scheme-handler/webcatalog;
Categories=Utility;