Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check script for managed_updates manifest items always produces actionNeeded of false #123

Open
serrc-techops opened this issue Sep 30, 2022 · 5 comments

Comments

@serrc-techops
Copy link

serrc-techops commented Sep 30, 2022

When utilizing a check script for items in the managed_updates manifest key, actionNeeded is always going to be false. This is happening because installType == "update" is not included in the pkg > status > status.go > checkScript > actionNeeded If statement. A fix is:

// Application not installed if exit 0
if installType == "uninstall" {
	actionNeeded = !cmdSuccess
} else if installType == "install" || installType == "update" {
	actionNeeded = cmdSuccess
}
return actionNeeded, checkErr```
@danhutchings
Copy link
Contributor

Hi @serrc-techops !

Based on the nature of how managed_updates are intended to work, those items are to only update if they are installed. So, I'm curious why a file or registry check will not work for an item that is supposed to be installed already.

Does the item/app you are intending to manage the update on not provide a lot of good options for those two checks?

That said, I think you've raised an interesting issue nonetheless.

@serrc-techops
Copy link
Author

serrc-techops commented Oct 25, 2022 via email

@danhutchings
Copy link
Contributor

I appreciate your thorough explanation here. Thank you for that.

It sounds like a good path forward for your use case would potentially be this. For a managed_update or managed_install item, use a file check to check for the existence of a file on the system, including the hash or version. Then use a ps1 installer to carry out the Chocolatey install/update. I have yet to see any application that did not store at least some kind of binary on the file system. That is why I'm suggesting a file check.

Here's an example yaml config:
Manifest yaml:

managed_installs:
  - Slack
managed_updates:
  - Firefox

Catalog yaml:

Slack:
  item_name: Slack
  check:
    file:
      - path: C:\Program Files\Slack\slack.exe
        version: 4.27.154.0
  display_name: Slack
  installer:
    location: packages/slack/slack-choco-updater.ps1
    hash: cb3be42f1e17b50ca9eba8fc64a8b2a5530fecf2ed57a1021b52ae612a276a47
    type: ps1
  version: 4.27.154.0
Firefox:
  item_name: Firefox
  check:
    file:
      - path: C:\Program Files\Mozilla Firefox\firefox.exe
        version: 103.0.1.0
  display_name: Firefox
  installer:
    location: packages/slack/firefox-choco-updater.ps1
    hash: d0877e030bb400c9642027e279c7faad3633f4d49cada2ad94577253ab3711db
    type: ps1
  version: 103.0.1.0

@serrc-techops
Copy link
Author

serrc-techops commented Oct 25, 2022 via email

@danhutchings
Copy link
Contributor

Thanks for the additional context here. Gorilla catalogs are intended to be used as a desired state of items. You'll need to specify a version or hash so that Gorilla knows that a desired state is reached.

One thing Gorilla does via its file and registry checks is do a comparison to see if the installed version is newer than what is configured in the catalog(s). If the installed version is newer, it doesn't take any action. With that in mind, you could probably write up a separate script that polls the Chocolatey community for the most recent versions of the applications you are trying to manage, and then update the catalog(s). This will make it so that your catalog has up to date version information, and you can still use your Chocolatey script to install the app(s). This also accomplishes your goal of not wanting to maintain a Gorilla repo full of packages.

I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants