ansible / vscode-ansible

vscode/vscodium extension for providing Ansible auto-completion and integrating quality assurance tools like ansible-lint, ansible syntax check, yamllint, molecule and ansible-test.
https://ansible.readthedocs.io/projects/vscode-ansible/
MIT License
357 stars 85 forks source link

Suggestions show all installed collections as part of 'ansible.builtin' #1164

Open robertcrews opened 5 months ago

robertcrews commented 5 months ago

Summary

I am experiencing an issue where only modules in 'ansible.builtin' namespace are recognized correctly or suggested. Additionally, any collections (community.vmware, community.general etc) are listed in suggestions as belonging in the 'ansible.builtin' namespace (see screen capture below). I've reinstalled the extensions, reinstalled vscode and deleted the .vscode* files and directories on the remote Linux host in an effort to let it set itself back up. I've also removed/reinstalled ansible-core, ansible-lint, the ansible collections etc all to no success. image I've checked to ensure that collections etc.. are all installed in the expected location ~/.ansible/. If I remove collections the modules still appear as suggestions (still in the incorrect name-space).

Extension version

2.13.148

VS Code version

1.87.2

Ansible Version

ansible [core 2.15.9]
  config file = /home/company.pvt/sa-rncrews/.ansible.cfg
  configured module search path = ['/home/company.pvt/sa-rncrews/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/company.pvt/sa-rncrews/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.18 (main, Sep 22 2023, 17:58:34) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.9)
  jinja version = 3.1.3
  libyaml = True

OS / Environment

Running VS code on windows 10, using Remote Development SSH to RHEL8.9 server. $ ansible-lint --version ansible-lint 6.14.3 using ansible 2.15.9 A new release of ansible-lint is available: 6.14.3 → 24.2.1

Relevant log output

[Trace - 1:49:32 PM] Sending request 'textDocument/definition - (433)'.
Params: {
    "textDocument": {
        "uri": "file:///home/company.pvt/sa-rncrews/code2/ansible/InfVmwareAnsible/create-snapshots.yml"
    },
    "position": {
        "line": 17,
        "character": 36
    }
}

[Trace - 1:49:32 PM] Received response 'textDocument/definition - (433)' in 7ms.
No result returned.

[Trace - 1:49:32 PM] Sending request 'textDocument/hover - (434)'.
Params: {
    "textDocument": {
        "uri": "file:///home/company.pvt/sa-rncrews/code2/ansible/InfVmwareAnsible/create-snapshots.yml"
    },
    "position": {
        "line": 17,
        "character": 36
    }
}

[Trace - 1:49:32 PM] Received response 'textDocument/hover - (434)' in 6ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "Use *community.vmware.vmware_guest_snapshot* instead."
    },
    "range": {
        "start": {
            "line": 17,
            "character": 6
        },
        "end": {
            "line": 17,
            "character": 43
        }
    }
}

[Trace - 1:49:33 PM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///home/company.pvt/sa-rncrews/code2/ansible/InfVmwareAnsible/create-snapshots.yml"
    }
}

Path for lint:  /bin/ansible-lint
Validating using ansible-lint
[Trace - 1:49:33 PM] Received request 'window/workDoneProgress/create - (10)'.
Params: {
    "token": "0118a073-3117-45bc-baf2-0acb14a4800d"
}

[Trace - 1:49:33 PM] Sending response 'window/workDoneProgress/create - (10)'. Processing request took 0ms
No result returned.

[Trace - 1:49:33 PM] Received notification '$/progress'.
Params: {
    "token": "0118a073-3117-45bc-baf2-0acb14a4800d",
    "value": {
        "kind": "begin",
        "title": "ansible-lint",
        "message": "Processing files..."
    }
}

[Trace - 1:49:35 PM] Received notification '$/progress'.
Params: {
    "token": "0118a073-3117-45bc-baf2-0acb14a4800d",
    "value": {
        "kind": "end"
    }
}

[Trace - 1:49:35 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///home/company.pvt/sa-rncrews/code2/ansible/InfVmwareAnsible/create-snapshots.yml",
    "diagnostics": [
        {
            "message": "missing required arguments: datacenter",
            "range": {
                "start": {
                    "line": 13,
                    "character": 0
                },
                "end": {
                    "line": 13,
                    "character": 2147483647
                }
            },
            "severity": 2,
            "source": "ansible-lint",
            "code": "args[module]",
            "codeDescription": {
                "href": "https://ansible-lint.readthedocs.io/rules/args/"
            }
        },
        {
            "message": "missing required arguments: datacenter",
            "range": {
                "start": {
                    "line": 16,
                    "character": 0
                },
                "end": {
                    "line": 16,
                    "character": 2147483647
                }
            },
            "severity": 2,
            "source": "ansible-lint",
            "code": "args[module]",
            "codeDescription": {
                "href": "https://ansible-lint.readthedocs.io/rules/args/"
            }
        },
        {
            "message": "You should use canonical module name `community.vmware.vmware_guest_snapshot` instead of `ansible.builtin.vmware_guest_snapshot`.",
            "range": {
                "start": {
                    "line": 16,
                    "character": 0
                },
                "end": {
                    "line": 16,
                    "character": 2147483647
                }
            },
            "severity": 1,
            "source": "ansible-lint",
            "code": "fqcn[canonical]",
            "codeDescription": {
                "href": "https://ansible-lint.readthedocs.io/rules/fqcn/"
            }
        }
    ]
}
robertcrews commented 5 months ago

I have had success with this from a alternate workstation connecting to a different remote host, so it would seem that this is something messed up either with my primary workstation or the language server on the remote host (or both).

fstrube commented 3 months ago

I have the same problem. All suggestions are in ansible.builtin. although ansible-lint reports that the canonical name should be used, e.g. community.general..

I recently had to reinstall Ansible via brew, so maybe something broke during that process?

Operating System MacOS 14.4

Ansible (installed via brew install ansible)

ansible [core 2.16.7]
  config file = /Users/fstrube/.ansible.cfg
  configured module search path = ['/Users/fstrube/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/9.6.0/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/fstrube/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] 
 (/usr/local/Cellar/ansible/9.6.0/libexec/bin/python)
  jinja version = 3.1.4
  libyaml = True

Ansible Collections

# /Users/fstrube/.ansible/collections/ansible_collections
Collection                               Version
---------------------------------------- -------
amazon.aws                               7.6.0
ansible.netcommon                        5.3.0
ansible.posix                            1.5.4
ansible.utils                            2.12.0
ansible.windows                          2.3.0
arista.eos                               6.2.2
awx.awx                                  23.9.0
azure.azcollection                       1.19.0
check_point.mgmt                         5.2.3
chocolatey.chocolatey                    1.5.1
cisco.aci                                2.9.0
cisco.asa                                4.0.3
cisco.dnac                               6.13.3
cisco.intersight                         2.0.9
cisco.ios                                5.3.0
cisco.iosxr                              6.1.1
cisco.ise                                2.9.1
cisco.meraki                             2.18.1
cisco.mso                                2.6.0
cisco.nxos                               5.3.0
cisco.ucs                                1.10.0
cloud.common                             2.1.4
cloudscale_ch.cloud                      2.3.1
community.aws                            7.2.0
community.azure                          2.0.0
community.ciscosmb                       1.0.9
community.crypto                         2.20.0
community.digitalocean                   1.26.0
community.dns                            2.9.1
community.docker                         3.10.1
community.general                        8.6.1
community.grafana                        1.8.0
community.hashi_vault                    6.2.0
community.hrobot                         1.9.2
community.library_inventory_filtering_v1 1.0.1
community.libvirt                        1.3.0
community.mongodb                        1.7.4
community.mysql                          3.9.0
community.network                        5.0.2
community.okd                            2.3.0
community.postgresql                     3.4.1
community.proxysql                       1.5.1
community.rabbitmq                       1.3.0
community.routeros                       2.15.0
community.sap                            2.0.0
community.sap_libs                       1.4.2
community.sops                           1.6.7
community.vmware                         4.4.0
community.windows                        2.2.0
community.zabbix                         2.4.0
containers.podman                        1.13.0
cyberark.conjur                          1.2.2
cyberark.pas                             1.0.25
dellemc.enterprise_sonic                 2.4.0
dellemc.openmanage                       8.7.0
dellemc.powerflex                        2.4.0
dellemc.unity                            1.7.1
f5networks.f5_modules                    1.28.0
fortinet.fortimanager                    2.5.0
fortinet.fortios                         2.3.6
frr.frr                                  2.0.2
gluster.gluster                          1.0.2
google.cloud                             1.3.0
grafana.grafana                          2.2.5
hetzner.hcloud                           2.5.0
hpe.nimble                               1.1.4
ibm.qradar                               2.1.0
ibm.spectrum_virtualize                  2.0.0
ibm.storage_virtualize                   2.3.1
infinidat.infinibox                      1.4.5
infoblox.nios_modules                    1.6.1
inspur.ispim                             2.2.1
inspur.sm                                2.3.0
junipernetworks.junos                    5.3.1
kaytus.ksmanage                          1.2.1
kubernetes.core                          2.4.2
lowlydba.sqlserver                       2.3.2
microsoft.ad                             1.5.0
netapp.aws                               21.7.1
netapp.azure                             21.10.1
netapp.cloudmanager                      21.22.1
netapp.elementsw                         21.7.0
netapp.ontap                             22.11.0
netapp.storagegrid                       21.12.0
netapp.um_info                           21.8.1
netapp_eseries.santricity                1.4.0
netbox.netbox                            3.18.0
ngine_io.cloudstack                      2.3.0
ngine_io.exoscale                        1.1.0
openstack.cloud                          2.2.0
openvswitch.openvswitch                  2.1.1
ovirt.ovirt                              3.2.0
purestorage.flasharray                   1.28.0
purestorage.flashblade                   1.17.0
purestorage.fusion                       1.6.1
sensu.sensu_go                           1.14.0
splunk.es                                2.1.2
t_systems_mms.icinga_director            2.0.1
telekom_mms.icinga_director              1.35.0
theforeman.foreman                       3.15.0
vmware.vmware_rest                       2.3.1
vultr.cloud                              1.12.1
vyos.vyos                                4.1.0
wti.remote                               1.0.5
jbericat commented 2 months ago

Hi there,

That's most likely because you didn't set the "collections_path" option correctly on your ansible.cfg file...

nick-seward commented 1 month ago

Confirming that I'm experiencing the same issue.

Screenshot 2024-07-26 at 5 47 50 AM

VS Code version

Version: 1.91.1 Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:07:46.768Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0

Extension Version

24.8.3

Ansible Version

ansible [core 2.17.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/Users/nseward/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/10.1.0/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/nseward/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/Cellar/ansible/10.1.0/libexec/bin/python)
  jinja version = 3.1.4
  libyaml = True

Ansible cfg file in my project

[defaults]
collections_path=/Users/nseward/.ansible/collections:/usr/share/ansible/collections:/opt/homebrew/Cellar/ansible/10.1.0/libexec/lib/python3.12/site-packages/ansible_collections

Ansible Collections

❯ ansible-galaxy collection list
/opt/homebrew/Cellar/ansible/10.1.0/libexec/lib/python3.12/site-packages/ansible_collections

Collection                               Version
---------------------------------------- -------
amazon.aws                               8.0.1
ansible.netcommon                        6.1.3
ansible.posix                            1.5.4
ansible.utils                            4.1.0
ansible.windows                          2.4.0
arista.eos                               9.0.0
awx.awx                                  24.5.0
azure.azcollection                       2.4.0
check_point.mgmt                         5.2.3
chocolatey.chocolatey                    1.5.1
cisco.aci                                2.9.0
cisco.asa                                5.0.1
cisco.dnac                               6.16.0
cisco.intersight                         2.0.9
cisco.ios                                8.0.0
cisco.iosxr                              9.0.0
cisco.ise                                2.9.2
cisco.meraki                             2.18.1
cisco.mso                                2.6.0
cisco.nxos                               8.1.0
cisco.ucs                                1.10.0
cloud.common                             3.0.0
cloudscale_ch.cloud                      2.3.1
community.aws                            8.0.0
community.ciscosmb                       1.0.9
community.crypto                         2.20.0
community.digitalocean                   1.26.0
community.dns                            3.0.1
community.docker                         3.10.4
community.general                        9.1.0
community.grafana                        1.9.1
community.hashi_vault                    6.2.0
community.hrobot                         2.0.1
community.library_inventory_filtering_v1 1.0.1
community.libvirt                        1.3.0
community.mongodb                        1.7.4
community.mysql                          3.9.0
community.network                        5.0.3
community.okd                            3.0.1
community.postgresql                     3.4.1
community.proxysql                       1.5.1
community.rabbitmq                       1.3.0
community.routeros                       2.16.0
community.sap_libs                       1.4.2
community.sops                           1.6.7
community.vmware                         4.4.0
community.windows                        2.2.0
community.zabbix                         2.5.1
containers.podman                        1.15.2
cyberark.conjur                          1.3.0
cyberark.pas                             1.0.25
dellemc.enterprise_sonic                 2.4.0
dellemc.openmanage                       9.3.0
dellemc.powerflex                        2.5.0
dellemc.unity                            2.0.0
f5networks.f5_modules                    1.28.0
fortinet.fortimanager                    2.5.0
fortinet.fortios                         2.3.6
frr.frr                                  2.0.2
google.cloud                             1.3.0
grafana.grafana                          5.2.0
hetzner.hcloud                           3.1.1
ibm.qradar                               3.0.0
ibm.spectrum_virtualize                  2.0.0
ibm.storage_virtualize                   2.3.1
ieisystem.inmanage                       2.0.0
infinidat.infinibox                      1.4.5
infoblox.nios_modules                    1.6.1
inspur.ispim                             2.2.3
inspur.sm                                2.3.0
junipernetworks.junos                    8.0.0
kaytus.ksmanage                          1.2.2
kubernetes.core                          3.2.0
lowlydba.sqlserver                       2.3.3
microsoft.ad                             1.6.0
netapp.cloudmanager                      21.22.1
netapp.ontap                             22.11.0
netapp.storagegrid                       21.12.0
netapp_eseries.santricity                1.4.0
netbox.netbox                            3.19.1
ngine_io.cloudstack                      2.3.0
ngine_io.exoscale                        1.1.0
openstack.cloud                          2.2.0
openvswitch.openvswitch                  2.1.1
ovirt.ovirt                              3.2.0
purestorage.flasharray                   1.28.1
purestorage.flashblade                   1.17.0
sensu.sensu_go                           1.14.0
splunk.es                                3.0.0
t_systems_mms.icinga_director            2.0.1
telekom_mms.icinga_director              2.1.2
theforeman.foreman                       4.0.0
vmware.vmware_rest                       3.0.1
vultr.cloud                              1.13.0
vyos.vyos                                4.1.0
wti.remote                               1.0.5