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

'ps' is not recognized as an internal or external command, #1158

Open
rod7760 opened this issue Jul 29, 2024 · 1 comment
Open

'ps' is not recognized as an internal or external command, #1158

rod7760 opened this issue Jul 29, 2024 · 1 comment
Labels
bug Label for all kind of bugs.

Comments

@rod7760
Copy link

rod7760 commented Jul 29, 2024

Describe the bug

choco install does not seem to work on windows 11 remote system.

To Reproduce

Create windows_deploy.py:

# windows_deploy.py
from pyinfra.operations import choco
from pyinfra.facts.choco import ChocoPackages

choco.install()
# TODO this doesn't work be ps is not recognized
choco.packages(
    name="Install Notepad++",
    packages=["notepadplusplus"],
)

Execute pyinfra:

pyinfra 192.168.80.130 windows_deploy.py --user vagrant --password vagrant --debug 

Actual behavior

  6s   infra 
/home/vagrant/Projects/infra/.venv/lib/python3.10/site-packages/paramiko/pkey.py:100: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "cipher": algorithms.TripleDES,
/home/vagrant/Projects/infra/.venv/lib/python3.10/site-packages/paramiko/transport.py:259: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "class": algorithms.TripleDES,
--> Loading config...
--> Loading inventory...
    [pyinfra_cli.inventory] Creating fake inventory...
    [pyinfra_cli.inventory] Checking possible group_data at: /home/vagrant/Projects/pyinfra-test/group_data

--> Connecting to hosts...
    [pyinfra.connectors.ssh] Connecting to: 192.168.80.130 ({'allow_agent': True, 'look_for_keys': True, '_pyinfra_ssh_forward_agent': False, '_pyinfra_ssh_config_file': None, '_pyinfra_ssh_known_hosts_file': None, '_pyinfra_ssh_strict_host_key_checking': 'accept-new', '_pyinfra_ssh_paramiko_connect_kwargs': None, 'username': 'vagrant', 'timeout': 10, 'password': 'vagrant'})
    [pyinfra.connectors.sshuserclient.client] Loading SSH config: None
    [192.168.80.130] Connected
    [pyinfra.api.state] Activating host: 192.168.80.130

--> Preparing operations...
--> Preparing Operations...
    Loading: windows_deploy.py
    [pyinfra.api.operation] Adding operation, {'choco.install'}, opOrder=(0, 4), opHash=18996c2767e7142774328ef0b335b99342919a9e
    [pyinfra.api.operation] Adding operation, {'Install Notepad++'}, opOrder=(0, 6), opHash=b774d0fdabe26575c0b79a9b49f216bd9af1d0e4
    [pyinfra.api.facts] Getting fact: choco.ChocoPackages () (ensure_hosts: None)
    [pyinfra.connectors.ssh] Running command on 192.168.80.130: (pty=False) ps -c 'choco list'
    [pyinfra.connectors.ssh] Waiting for exit status...
    [pyinfra.connectors.ssh] Command exit status: 1
    [192.168.80.130] 'ps' is not recognized as an internal or external command,
    [192.168.80.130] operable program or batch file.
    [192.168.80.130] Error: could not load fact: choco.ChocoPackages 
    [pyinfra.api.state] Failing hosts: 192.168.80.130

Expected behavior

Vim is installed on the windows machine.

Meta

pyinfra --support
 System: Linux
      Platform: Linux-5.15.0-116-generic-x86_64-with-glibc2.35
      Release: 5.15.0-116-generic
      Machine: x86_64
    pyinfra: v3.0.1
    Executable: /home/vagrant/Projects/infra/.venv/bin/pyinfra
    Python: 3.10.12 (CPython, GCC 11.4.0)
@rod7760 rod7760 added the bug Label for all kind of bugs. label Jul 29, 2024
@rod7760
Copy link
Author

rod7760 commented Jul 29, 2024

This seems to be caused by the following line in pyinfra/facts/choco.py:

    shell_executable = "ps"

Should the ps alias exist by default? Or am I expected to manually create it?

The following seems to fix the issue:

    shell_executable = "powershell.exe"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Label for all kind of bugs.
Projects
None yet
Development

No branches or pull requests

1 participant