vscode-ansible icon indicating copy to clipboard operation
vscode-ansible copied to clipboard

Support for WSL instance created by Podman for Windows

Open maroskukan opened this issue 1 year ago • 1 comments

Problem

Greetings,

I am curious if the following setup should work or not. I have installed podman for windows and created the podman-machine-default WSL2 instance. I have enabled the rootful mode. Starting container instances from Windows environment works. e.g. podman run...

I went further and using VSCode in Windows and connected to this WSL instance using the WSL plugin. Next I have installed the ansible plugin inside this it with default settings. See log below.

VSCode OUTPUT after Installing the extension on instance podman-machine-default connect via WSL extension https://gist.github.com/maroskukan/484e2bb24f9c5d2c790e57b198f0204e

From VS Code point of view, all looks well, the EE is recognized

Screenshot 2023-06-12 065508

However when I try to execute a playbook, I end up with the following OUTPUT and TERMINAL messages.

VSCode OUTPUT after Run Ansible Playbook via.../Run playbook via ansible-playbook

https://gist.github.com/maroskukan/fb9028ffc06e5ea66417ab5ee27381b8

VSCode TERMINAL Output after Run Ansible Playbook via.../Run playbook via ansible-playbook

ansible-playbook /mnt/c/users/mk/code/maroskukan/ansible-demo/playbook.yml

You will be automatically entered into a nested process namespace where
systemd is running. If you need to access the parent namespace, hit ctrl-d
or type exit. This also means to log out you need to exit twice.

[user@DESKTOP-O89K23I ~]$ ansible-playbook /mnt/c/users/mk/code/maroskukan/ansible-demo/playbook.yml
-bash: ansible-playbook: command not found

For some reason the extension is calling this ansible-playbook inside this "nested" container hosted on podman-machine-default and not the creator-ee. When I check the requested EE image was pulled down successfully.

[user@DESKTOP-O89K23I ~]$ podman image ls
REPOSITORY                  TAG         IMAGE ID      CREATED      SIZE
ghcr.io/ansible/creator-ee  latest      f43046ebd79c  3 weeks ago  747 MB

Also running the EE itself from podman machine works

[user@DESKTOP-O89K23I ~]$ podman run --rm --workdir /mnt/c/users/mk/code/maroskukan/ansible-demo -v /mnt/c/users/mk/code/maroskukan/ansible-demo:/mnt/c/users/mk/code/maroskukan/ansible-demo -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name als_796559b4-5e82-41f0-a1b3-60c3a5c6ad48 ghcr.io/ansible/creator-ee:latest command -v ansible-lint
/usr/local/bin/ansible-lint

Perhaps this is not supported at all and I need a separate WSL instance or some tweaks to podman instance would be required. However it would be great if I could have just one instance and be able to work from Windows as well as using this extensions on that WSL instance.

Solution

Ansible-playbook would be invoked inside defined execution environment created by podman inside wsl instance.

Alternatives

Perhaps this is related how podman-default-machine instance is constructed and not the extension itself.

Additional context

No response

maroskukan avatar Jun 12 '23 14:06 maroskukan

Similar issue here, the following installed on Windows 10:

  • VSCode 1.89.1 with Ansible extension v24.5.2
  • Podman Desktop for Windows v1.10.2

The 'podman' command runs fine from both command shell or powershell in Windows i.e. can launch execution environment container image (ee-supported-rhel8) without issue. Configured the ansible extension execution environment options to use podman and the EE container image, and get this error:

vs-anisble-error

The Ansible extension looks to be running a command to check podman binary, however command used by the extension is only suitable for Linux not for Windows.

Could the the Ansible extension be updated to support the container engine running on Windows?

ulysses-31 avatar May 28 '24 02:05 ulysses-31