Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Autocompletion doesn't work when ExecutionEnvironment is enabled #472

Closed
nbruniaux opened this issue Oct 19, 2022 · 5 comments
Closed

Autocompletion doesn't work when ExecutionEnvironment is enabled #472

nbruniaux opened this issue Oct 19, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@nbruniaux
Copy link

Summary

Autocompletion doesn't work when EE is enabled

{
  "ansible.executionEnvironment.enabled": true,
  "ansible.ansible.useFullyQualifiedCollectionNames": true,
  "ansible.executionEnvironment.image": "quay.io/ansible/creator-ee:latest"
}

ansible-lint works fine.

Extension version

1.0.93

VS Code version

1.72.2

Ansible Version

$ ansible --version
ansible [core 2.13.5]
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.9.7 (default, Sep 13 2021, 08:18:39) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 3.0.3
  libyaml = True

OS / Environment

Red Hat Enterprise Linux release 8.6 (Ootpa)

Relevant log output

[Error - 11:35:31 AM] Volume mount source path '' does not exist. Ignoring this volume mount entry.
check for container image with command: 'podman image inspect quay.io/ansible/creator-ee:latest'
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_c22c519f-40fd-42f0-9132-62eafa61ab1b quay.io/ansible/creator-ee:latest command -v ansible-lint
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_f2f43fe1-492d-4e29-85f3-170209208ed2 quay.io/ansible/creator-ee:latest ansible-config dump
Path for lint:  /usr/local/bin/ansible-lint
Validating using ansible-lint
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks/SYS_UNIX:/home/user/ansible/my_playbooks/SYS_UNIX -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_8b89e2d6-4790-4858-ba51-0c3ca859e3ed quay.io/ansible/creator-ee:latest ansible-lint  --offline --nocolor -f codeclimate "/home/user/ansible/my_playbooks/SYS_UNIX/site.yml"
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_6e71b137-1e54-48b8-8001-3cd73beea604 quay.io/ansible/creator-ee:latest ansible --version
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_4290d649-c6b9-4528-9136-3a2f9d0a7536 quay.io/ansible/creator-ee:latest python3  -c "import sys; print(sys.path, end=\"\")"
podman images quay.io/ansible/creator-ee:latest --format="{{.ID}}" | head -n 1
Error: inspecting object: no such object: "quay_io_ansible_creator_ee_latest"
clean up container not required as container with name quay_io_ansible_creator_ee_latest does not exist
run container with command 'podman run --rm -it -d  -e ANSIBLE_FORCE_COLOR=0  --name quay_io_ansible_creator_ee_latest quay.io/ansible/creator-ee:latest bash'
time="2022-10-19T11:35:36+02:00" level=warning msg="The input device is not a TTY. The --tty and --interactive flags might not work properly"
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_a60b82ac-4c00-458e-9340-7142267ec9f0 quay.io/ansible/creator-ee:latest python3 --version
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_640f527f-6ce0-4412-9d44-b05107bf5f8c quay.io/ansible/creator-ee:latest python3 --version
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_47c60083-c799-4c04-94f7-994cdacc16e8 quay.io/ansible/creator-ee:latest python3 --version
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_c8827929-c794-494b-8f21-17e91842b944 quay.io/ansible/creator-ee:latest python3 --version
Identified plugin paths by AnsibleConfig service: 
 collections_paths: /home/runner/.ansible/collections,/usr/share/ansible/collections,,/usr/lib64/python310.zip,/usr/lib64/python3.10,/usr/lib64/python3.10/lib-dynload,/usr/local/lib64/python3.10/site-packages,/usr/local/lib/python3.10/site-packages,/usr/lib64/python3.10/site-packages,/usr/lib/python3.10/site-packages 
 module_locations: /home/runner/.ansible/plugins/modules,/usr/share/ansible/plugins/modules,/usr/local/lib/python3.10/site-packages/ansible/modules
[Info  - 11:35:37 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /home/runner/.ansible/collections/ansible_collections
Error: container d24b992001e2574008df9e3e19e29522998133be777c5690295c09fa9807d22f does not exist in database: no such container
[Error - 11:35:37 AM] [object Object]
[Info  - 11:35:37 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/share/ansible/collections/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:38 AM] [object Object]
[Info  - 11:35:38 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/lib64/python310.zip/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:38 AM] [object Object]
[Info  - 11:35:38 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/lib64/python3.10/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:38 AM] [object Object]
[Info  - 11:35:38 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/lib64/python3.10/lib-dynload/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:38 AM] [object Object]
[Info  - 11:35:38 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/local/lib64/python3.10/site-packages/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:39 AM] [object Object]
[Info  - 11:35:39 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/local/lib/python3.10/site-packages/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:39 AM] [object Object]
[Info  - 11:35:39 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/lib64/python3.10/site-packages/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:39 AM] [object Object]
[Info  - 11:35:39 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/lib/python3.10/site-packages/ansible_collections
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:39 AM] [object Object]
[Info  - 11:35:39 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /home/runner/.ansible/plugins/
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:39 AM] [object Object]
[Info  - 11:35:39 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/share/ansible/plugins/
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:39 AM] [object Object]
[Info  - 11:35:39 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/local/lib/python3.10/site-packages/ansible/plugins/
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:39 AM] [object Object]
[Info  - 11:35:39 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /home/runner/.ansible/plugins/modules/
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:40 AM] [object Object]
[Info  - 11:35:40 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/share/ansible/plugins/modules/
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:40 AM] [object Object]
[Info  - 11:35:40 AM] Executing command podman exec quay_io_ansible_creator_ee_latest ls /usr/local/lib/python3.10/site-packages/ansible/modules/
Error: no container with name or ID "quay_io_ansible_creator_ee_latest" found: no such container
[Error - 11:35:40 AM] [object Object]
Copied plugin paths by ExecutionEnvironment service: 
 collections_paths:  
 module_locations: 
Error: inspecting object: no such object: "quay_io_ansible_creator_ee_latest"
clean up container not required as container with name quay_io_ansible_creator_ee_latest does not exist
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_060bbc59-1e18-492e-83b1-7f0d309f929d quay.io/ansible/creator-ee:latest python3 -c "import sys; print(sys.executable)"
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_9709d418-d32e-4e81-9056-4bdb67d573d2 quay.io/ansible/creator-ee:latest python3 -c "import sys; print(sys.executable)"
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_f5fe23f5-62b6-4e3d-88e8-d77fc282dde1 quay.io/ansible/creator-ee:latest python3 -c "import sys; print(sys.executable)"
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_f4f45888-657c-4085-a5dc-94658a87097e quay.io/ansible/creator-ee:latest python3 -c "import sys; print(sys.executable)"
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_e55a3b56-2b18-4874-988f-3504e6383427 quay.io/ansible/creator-ee:latest ansible-lint --version
container engine invocation: podman run --rm --workdir /home/user/ansible/my_playbooks -v /home/user/ansible/my_playbooks:/home/user/ansible/my_playbooks -e ANSIBLE_FORCE_COLOR=0 --group-add=root --ipc=host --quiet --name ansible_language_server_9df5b528-edb7-4c14-8172-549f0c3fdc4e quay.io/ansible/creator-ee:latest ansible-lint --version
@nbruniaux nbruniaux added bug Something isn't working new Use track issue requiring triage labels Oct 19, 2022
@ptoal
Copy link

ptoal commented Nov 20, 2022

I am also experiencing this. Extension v.1.0.90 - 1.0.98

Reverting to v0.14.71 allows me to get autocomplete, flyover docs, etc.

Also of interesting note... Downgrading to 0.14.71, and then upgrading back to 1.0.90, results in this working again. I'm guessing that 0.14.71 is populating the cache.

@priyamsahoo
Copy link
Contributor

@nbruniaux, could you please try out what @ptoal suggested? Please let us know if the problem still exists.

@priyamsahoo priyamsahoo removed the new Use track issue requiring triage label Nov 28, 2022
@nbruniaux
Copy link
Author

Hello,

I couldn't test @ptoal's suggestion but autocompletion is now partially working for me.

selinux was in enforcing mode, I switched it to permissive mode and restarted vscode... autocompletion started working!
Also, when I switched back to selinux enforcing, it still works.

I still have a problem with adjacent collections, autocomplete doesn't work for them but it seems that an issue is already open for that: #123

@ptoal
Copy link

ptoal commented Nov 28, 2022

I did a bit more digging on this. I don't think it's specific to a version, after all. I may have been changing multiple things at the same time, during troubleshooting.

Taking a bit more of a methodical approach:

  1. Reset settings to default. Specify my custom EE, and turn tracing to verbose
  2. Execute podman rmi -a to remove all local images.
  3. rm -rf ~/.cache/ansible-language-server
  4. Start VSCode.
  5. Open an ansible file that uses a module only in my custom EE. (In this case: community.vmware.vmware_guest)

After resetting my ansible configuration in VSCode, things seem to be working correctly now.

I think what may have happened is that I had paths for my virtualenv in the extension settings and this caused a problem with the language server. I don't really know. All I know for sure is that before, the ~/.cache/ansible-language-server/<image>/<id>/usr/share/ansible/collections directory for the image didn't exist. Now, it exists with a copy of all the collections from the EE.

@priyamsahoo
Copy link
Contributor

@nbruniaux, thanks for updating. Feel free to close the issue if you do not face the issue anymore.
For the playbook adjacent collections' auto-completion, the PR is in WIP (#511) and will soon be functional.

Meanwhile, here's a quick tip to support the playbook adjacent collection:
Add an ansible.cfg file in the workspace's root and mention collections_path = path/to/your/collection, and reload the window.

This should work and should give auto-completions straight away.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants