Fix 1password-cli install on Windows

This commit is contained in:
Kenneth Benzie 2025-08-13 23:03:28 +01:00
parent 2286452f5b
commit b6b18b2b94

View File

@ -18,51 +18,27 @@
icon: '{{app_exe}},0'
# CLI
- name: install scoop cli package
community.windows.win_scoop:
state: present
name: 1password-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: create cli directory
win_file:
state: directory
path: '{{cli_dir}}'
- name: get installed op version
when: cli_stat.stat.exists == True
win_command: '{{cli_exe}} --version'
register: cli_version
changed_when: false
- name: remove old op executable
win_file:
state: absent
path: '{{cli_dir}}\op.exe'
- 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}}'
environment: '{{proxy_environment}}'
- 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
- name: remove old op install directory from user PATH
win_path:
state: absent
scope: user
name: Path
elements: '{{cli_dir}}'
@ -70,7 +46,7 @@
- name: get op powershell completion script
win_command:
argv:
- '{{ansible_env.LOCALAPPDATA}}/1Password/cli/op.exe'
- '{{ansible_env.LOCALAPPDATA}}\Scoop\shims\op.exe'
- completion
- powershell
register: powershell_completion_script