Compare commits

...

3 Commits

4 changed files with 57 additions and 76 deletions

View File

@ -6,8 +6,9 @@
$module = [Ansible.Basic.AnsibleModule]::Create($args, @{
options = @{
name = @{
type = "str"
default = $null
type = "list"
elements = "str"
required = $true
}
state = @{
type = "str"
@ -18,7 +19,7 @@ $module = [Ansible.Basic.AnsibleModule]::Create($args, @{
supports_check_mode = $false
})
$name = $module.Params.name
$names = $module.Params.name
$state = $module.Params.state
$winget = Get-ExecutablePath "winget"
$noPackageString = "No installed package found matching input criteria."
@ -48,7 +49,8 @@ function Test-UpgradeAvailable {
return $true
}
switch ($state) {
foreach ($name in $names) {
switch ($state) {
"absent" {
if (Test-Installed) {
$command = "`"$winget`" uninstall `"$name`""
@ -90,6 +92,7 @@ switch ($state) {
$module.Result.changed = $true
}
}
}
}
$module.Result.rc = 0

View File

@ -11,7 +11,7 @@ options:
name:
description:
- Name of the package to manage.
type: str
type: list[str]
state:
description:
- Indicates the desired package state. V(latest) ensures that the latest

View File

@ -1,9 +1,15 @@
---
- name: install winget packages
win_winget:
name:
- neovim.neovim
- equalsraf.neovim-qt
state: latest
- name: install chocolatey packages
- name: remove chocolatey package
win_chocolatey:
name: neovim
state: latest
state: absent
- set_fact:
vim_config_dir: '{{ansible_env.LOCALAPPDATA}}\nvim'
@ -14,39 +20,15 @@
dest: '{{vim_config_dir}}'
branch: main
# - TODO: neovim install pip packages
# win_pip:
# name: '{{neovim_pip_packages}}'
# state: latest
- 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'
icon: '{{ansible_env.ChocolateyToolsLocation}}/neovim/nvim-win64/bin/nvim-qt.exe,0'
directory: '{{ansible_env.USERPROFILE}}'
- name: check for config repo tasks.yaml
win_stat:
path: '{{vim_config_dir}}/tasks.yaml'
register: config_repo_tasks
# TODO: this doesn't work for non localhost setups
# probably need to copy the tasks.yaml and plugins.yaml to the controller in a
# temporary directory then include them
- when: config_repo_tasks.stat.exists
fetch:
src: '{{vim_config_dir}}/tasks.yaml'
dest: vim_config_tasks.yaml
flat: true
changed_when: false
- when: config_repo_tasks.stat.exists
include_tasks: vim_config_tasks.yaml
- name: remove fetched tasks
file:
state: absent
path: vim_config_tasks.yaml
changed_when: false
delegate_to: localhost
# TODO: Create neovim-qt start menu shortcut
# Need a reliable way to get the path to nvim-qt which doesn't reply on
# where.exe or similar as it won't work on first install due to environment
# variable update. winget installs the equalsraf.neovim-qt package in
# {{ansible_env.ProgramFiles}}\neovim-qt {{neovim_qt_version}}\bin\nvim.qt.exe
# so if I can get the version out of winget that would be a start.
# - name: create nvim start menu shortcut
# win_shortcut:
# src: '{{neovim_qt_exe}}'
# dest: '{{ansible_env.ProgramData}}/Microsoft/Windows/Start Menu/Programs/nvim-qt.lnk'
# icon: '{{neovim_qt_exe}},0'
# directory: '{{ansible_env.USERPROFILE}}'

View File

@ -1,7 +1,3 @@
---
neovim_pip_packages:
- cmake-language-server
- cmakelint
- compdb
- vim-vint
- yamllint