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

[BUG] New chocolatey version (2.x) - chocolatey states fail with an error #64622

Closed
AGirin opened this issue Jul 10, 2023 · 9 comments
Closed
Assignees
Labels
Bug broken, incorrect, or confusing behavior dependency underlying Salt dependency issue Execution-Module Sulfur v3006.2 Windows

Comments

@AGirin
Copy link

AGirin commented Jul 10, 2023

Description
States that ran fine with older version of chocolatey are now failing with latest chocolatey installed.

State that fails:

  - {{ include }}
...
telegraf:
  {{ pkg }}:
    {{ refresh }}
    - source: 'Private source'
    - require:
      - sls: {{ include }}
    - version: some version
  service.running:
    - enable: True
    - watch:
      - {{ watch_pkg }}: telegraf

This state works just fine on older chocolatey... But with new one we get this:

    Function: chocolatey.installed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\state.py", line 2385, in call
                  ret = self.states[cdata["full"]](
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1232, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1247, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1280, in wrapper
                  return f(*args, **kwargs)
                File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\states\chocolatey.py", line 118, in installed
                  version_info = __salt__["chocolatey.version"](
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1232, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1247, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\modules\chocolatey.py", line 1115, in version
                  available = list_(narrow=name, pre_versions=pre_versions, source=source)
                File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\modules\chocolatey.py", line 488, in list_
                  raise CommandExecutionError(err)
              salt.exceptions.CommandExecutionError: Running chocolatey failed: When using the '--source' option with the 'choco list' command, only a named alternative source can be provided.

Looks like commands that choleatey uses changed with the new version...

Old version:


    Chocolatey v0.11.3
    telegraf 1.27.1 [Approved] Downloads cached for licensed users
    1 packages found.

New version:

    Chocolatey v2.1.0
    When using the '--source' option with the 'choco list' command, only a named alternative source can be provided.

Looks like salt module will have to be updated to work with new chocolatey version...

@AGirin AGirin added Bug broken, incorrect, or confusing behavior needs-triage labels Jul 10, 2023
@OrangeDog OrangeDog added Windows dependency underlying Salt dependency issue labels Jul 11, 2023
@AGirin
Copy link
Author

AGirin commented Jul 11, 2023

For the record - I "fixed" it by removing this from chocolatey.py (under Install section):

       version_info = __salt__["chocolatey.version"](
            name=name, check_remote=True, source=source
        )
to:
        version_info = __salt__["chocolatey.version"](
            name=name, check_remote=True
        )
        

@AGirin
Copy link
Author

AGirin commented Jul 11, 2023

And this happens to all version of salt once Chocolatey is upgraded to 2.x..

@AGirin AGirin changed the title [BUG] version 3006.1 and new chocolatey version - chocolatey states fail with an error [BUG] New chocolatey version (2.x) - chocolatey states fail with an error Jul 11, 2023
@twangboy twangboy self-assigned this Jul 19, 2023
@twangboy twangboy added this to the Sulfur v3006.2 milestone Jul 19, 2023
@twangboy
Copy link
Contributor

Hey @AGirin, thanks for reporting this issue. I'm working on a fix for this: #64673

Would you mind verifying those changes fix the issue for you?

@AGirin
Copy link
Author

AGirin commented Jul 26, 2023

@twangboy Sure. Let me tkae a look at it.

@AGirin
Copy link
Author

AGirin commented Jul 26, 2023

@twangboy I think you fixed module section.. We have issues with state one as well...

@AGirin
Copy link
Author

AGirin commented Jul 26, 2023

@twangboy Unfortunately it does not seem to work... It does not error out now but I get nothing back..

sudo salt 'SERVER*' chocolatey.version telegraf
SERVER:
    ----------

Expected reslt is this:

SERVER:
    ----------
    telegraf:
        - 1.27.1

@twangboy
Copy link
Contributor

twangboy commented Aug 4, 2023

OK, I think that's fixed here: #64922

@AGirin
Copy link
Author

AGirin commented Aug 22, 2023

@twangboy I upgraded to 3006.2. Upraded choloatey to 2.2.2 and no luck...

chocolatey.chocolatey_version
<server>:
    ERROR: Chocolatey not installed. Use chocolatey.bootstrap to install the Chocolatey package manager.

chocolatey.version telegraf
<server>:
    ERROR: Chocolatey not installed. Use chocolatey.bootstrap to install the Chocolatey package manager.

chocolatey.bootstrap
<server>:
    WARNING: 'choco' was found at 'C:\ProgramData\chocolatey\bin\choco.exe'.
    WARNING: An existing Chocolatey installation was detected. Installation will not continue.

    For security reasons, this script will not overwrite existing installations.

So... Chocolatey is installed... But it is not..

Running commands on the server itself from PowerShell confirms that chocolatey is installed:

choco info telegraf
Chocolatey v2.2.2
telegraf 1.27.4 [Approved] Downloads cached for licensed users.

@AGirin
Copy link
Author

AGirin commented Aug 22, 2023

My "fix" still works though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior dependency underlying Salt dependency issue Execution-Module Sulfur v3006.2 Windows
Projects
None yet
Development

No branches or pull requests

3 participants