Compare commits
3 Commits
a9aa1bdaaf
...
5210a451b2
Author | SHA1 | Date | |
---|---|---|---|
5210a451b2 | |||
d18a9550c9 | |||
1995bf3bc2 |
@ -6,8 +6,9 @@
|
|||||||
$module = [Ansible.Basic.AnsibleModule]::Create($args, @{
|
$module = [Ansible.Basic.AnsibleModule]::Create($args, @{
|
||||||
options = @{
|
options = @{
|
||||||
name = @{
|
name = @{
|
||||||
type = "str"
|
type = "list"
|
||||||
default = $null
|
elements = "str"
|
||||||
|
required = $true
|
||||||
}
|
}
|
||||||
state = @{
|
state = @{
|
||||||
type = "str"
|
type = "str"
|
||||||
@ -18,7 +19,7 @@ $module = [Ansible.Basic.AnsibleModule]::Create($args, @{
|
|||||||
supports_check_mode = $false
|
supports_check_mode = $false
|
||||||
})
|
})
|
||||||
|
|
||||||
$name = $module.Params.name
|
$names = $module.Params.name
|
||||||
$state = $module.Params.state
|
$state = $module.Params.state
|
||||||
$winget = Get-ExecutablePath "winget"
|
$winget = Get-ExecutablePath "winget"
|
||||||
$noPackageString = "No installed package found matching input criteria."
|
$noPackageString = "No installed package found matching input criteria."
|
||||||
@ -48,46 +49,48 @@ function Test-UpgradeAvailable {
|
|||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($state) {
|
foreach ($name in $names) {
|
||||||
"absent" {
|
switch ($state) {
|
||||||
if (Test-Installed) {
|
"absent" {
|
||||||
$command = "`"$winget`" uninstall `"$name`""
|
if (Test-Installed) {
|
||||||
$result = Run-Command -command $command
|
$command = "`"$winget`" uninstall `"$name`""
|
||||||
if ($result.rc -ne 0) {
|
$result = Run-Command -command $command
|
||||||
$module.Result.rc = $result.rc
|
if ($result.rc -ne 0) {
|
||||||
|
$module.Result.rc = $result.rc
|
||||||
|
$module.Result.stdout = $result.stdout
|
||||||
|
$module.FailJson("Failed to uninstall package `"$name`"")
|
||||||
|
}
|
||||||
$module.Result.stdout = $result.stdout
|
$module.Result.stdout = $result.stdout
|
||||||
$module.FailJson("Failed to uninstall package `"$name`"")
|
$module.Result.changed = $true
|
||||||
}
|
}
|
||||||
$module.Result.stdout = $result.stdout
|
|
||||||
$module.Result.changed = $true
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
"latest" {
|
"latest" {
|
||||||
if (Test-UpgradeAvailable) {
|
if (Test-UpgradeAvailable) {
|
||||||
$command = "`"$winget`" install `"$name`""
|
$command = "`"$winget`" install `"$name`""
|
||||||
$result = Run-Command -command $command
|
$result = Run-Command -command $command
|
||||||
if ($result.rc -ne 0) {
|
if ($result.rc -ne 0) {
|
||||||
$module.Result.rc = $result.rc
|
$module.Result.rc = $result.rc
|
||||||
|
$module.Result.stdout = $result.stdout
|
||||||
|
$module.FailJson("Failed to install package `"$name`"")
|
||||||
|
}
|
||||||
$module.Result.stdout = $result.stdout
|
$module.Result.stdout = $result.stdout
|
||||||
$module.FailJson("Failed to install package `"$name`"")
|
$module.Result.changed = $true
|
||||||
}
|
}
|
||||||
$module.Result.stdout = $result.stdout
|
|
||||||
$module.Result.changed = $true
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
"present" {
|
"present" {
|
||||||
if (!(Test-Installed)) {
|
if (!(Test-Installed)) {
|
||||||
$command = "`"$winget`" install `"$name`""
|
$command = "`"$winget`" install `"$name`""
|
||||||
$result = Run-Command -command $command
|
$result = Run-Command -command $command
|
||||||
if ($result.rc -ne 0) {
|
if ($result.rc -ne 0) {
|
||||||
$module.Result.rc = $result.rc
|
$module.Result.rc = $result.rc
|
||||||
|
$module.Result.stdout = $result.stdout
|
||||||
|
$module.FailJson("Failed to install package `"$name`"")
|
||||||
|
}
|
||||||
$module.Result.stdout = $result.stdout
|
$module.Result.stdout = $result.stdout
|
||||||
$module.FailJson("Failed to install package `"$name`"")
|
$module.Result.changed = $true
|
||||||
}
|
}
|
||||||
$module.Result.stdout = $result.stdout
|
|
||||||
$module.Result.changed = $true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ options:
|
|||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Name of the package to manage.
|
- Name of the package to manage.
|
||||||
type: str
|
type: list[str]
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Indicates the desired package state. V(latest) ensures that the latest
|
- Indicates the desired package state. V(latest) ensures that the latest
|
||||||
|
@ -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:
|
win_chocolatey:
|
||||||
name: neovim
|
name: neovim
|
||||||
state: latest
|
state: absent
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
vim_config_dir: '{{ansible_env.LOCALAPPDATA}}\nvim'
|
vim_config_dir: '{{ansible_env.LOCALAPPDATA}}\nvim'
|
||||||
@ -14,39 +20,15 @@
|
|||||||
dest: '{{vim_config_dir}}'
|
dest: '{{vim_config_dir}}'
|
||||||
branch: main
|
branch: main
|
||||||
|
|
||||||
# - TODO: neovim install pip packages
|
# TODO: Create neovim-qt start menu shortcut
|
||||||
# win_pip:
|
# Need a reliable way to get the path to nvim-qt which doesn't reply on
|
||||||
# name: '{{neovim_pip_packages}}'
|
# where.exe or similar as it won't work on first install due to environment
|
||||||
# state: latest
|
# variable update. winget installs the equalsraf.neovim-qt package in
|
||||||
|
# {{ansible_env.ProgramFiles}}\neovim-qt {{neovim_qt_version}}\bin\nvim.qt.exe
|
||||||
- name: create nvim start menu shortcut
|
# so if I can get the version out of winget that would be a start.
|
||||||
win_shortcut:
|
# - name: create nvim start menu shortcut
|
||||||
src: '{{ansible_env.ChocolateyToolsLocation}}/neovim/nvim-win64/bin/nvim-qt.exe'
|
# win_shortcut:
|
||||||
dest: '{{ansible_env.ProgramData}}/Microsoft/Windows/Start Menu/Programs/nvim-qt.lnk'
|
# src: '{{neovim_qt_exe}}'
|
||||||
icon: '{{ansible_env.ChocolateyToolsLocation}}/neovim/nvim-win64/bin/nvim-qt.exe,0'
|
# dest: '{{ansible_env.ProgramData}}/Microsoft/Windows/Start Menu/Programs/nvim-qt.lnk'
|
||||||
directory: '{{ansible_env.USERPROFILE}}'
|
# icon: '{{neovim_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
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
---
|
---
|
||||||
neovim_pip_packages:
|
neovim_pip_packages:
|
||||||
- cmake-language-server
|
|
||||||
- cmakelint
|
|
||||||
- compdb
|
- compdb
|
||||||
- vim-vint
|
|
||||||
- yamllint
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user