Giter VIP home page Giter VIP logo

Comments (11)

bendem avatar bendem commented on June 5, 2024 2

I have a problem which I think might be related, if not I'll open another issue:
image
This is for a yaml file in ansible/playbooks/sso/tasks/openldap/.
I have the same problem with vars of all types (group_vars, host_vars, vars, defaults):
image

Basically, anything under playbooks/* is interpreted as a playbook, no matter the parent directory.

On that note, it might be cool if things under files and templates were left alone since they are not actually ansible files.

from vscode-ansible.

ssbarnea avatar ssbarnea commented on June 5, 2024 1

It looks like vars_prompt also affected:
with a most basic example: from https://docs.ansible.com/ansible/latest/user_guide/playbooks_prompts.html

---
- hosts: all
  vars_prompt:

    - name: username
      prompt: What is your username?
      private: no

    - name: password
      prompt: What is your password?

  tasks:

    - name: Print a message
      ansible.builtin.debug:
        msg: 'Logging in as {{ username }}'

I'm getting this error:

image

$ apt-cache policy code
code:
  Installed: 1.55.2-1618307277

redhat.vscode-yaml Preview v0.18.0
zbr.vscode-ansible Preview 0.3.2

Please let me know if it's not related and needs a separated issue.

The bug is valid and the correct place to raise it is at https://github.com/ansible-community/schemas -- as this is missing from the schema. It should not be hard to add it.

Update: I already made a PR to add it ansible/schemas#32 -- look at it and you will know how to add the next bit we find missing.

from vscode-ansible.

ssbarnea avatar ssbarnea commented on June 5, 2024

I have no idea why it gets confused as based on https://github.com/ansible-community/vscode-ansible/blob/master/package.json#L104-L115 it should pick the first pattern that matches, which is groups_vars. Do you happen to have these under a path that looks like playbooks/group_vars/all.yml ? -- is if you do, it would still have to work.

from vscode-ansible.

tsia avatar tsia commented on June 5, 2024

The group_vars folder actually is at the root of the project.

from vscode-ansible.

ssbarnea avatar ssbarnea commented on June 5, 2024

I can confirm the bug, in fact it seems that whatever I do vars files seems to endup using the playbook schema. Looking at the config, I see no reason for this to happen.

The bug seems related to a recent merge made to redhat-developer/yaml-language-server#417 and I wonder if next release of YAML extension will adress it,... or make things even worse.

Test cases:

  • playbooks/all.yml - should use ansible-playbook schema
  • group_vars/all.yml - should use ansible-vars schema
  • playbooks/group_vars/all.yml - should use ansible-vars schema, even if both patterns are matching. I do think there is a real chance this may go wrong as I do remember that vscode original globbing was not very smart and a single * could expand to anything. I am also not sure if the order of the patterns is respected either. We do list playbooks at the end for good reasons: to avoid folders like vars/tasks/handlers nested inside playbooks/ to endup being recognized as playbooks.

I hope that @JPinkney or @joshuawilson may give us some insights here. Maybe the can help us by adding some extra tests that assure we can write patterns to distinguish between those cases.

from vscode-ansible.

JPinkney avatar JPinkney commented on June 5, 2024

I can probably take a look as to what's causing on the yaml side later today

from vscode-ansible.

ssbarnea avatar ssbarnea commented on June 5, 2024

I tested with vscode-ansible@master and I can confirm that now case 1 and 2 are now working (clear improvement), but 3 is not. playbooks/group_vars/all.yml is still identified as a playbook instead of a vars file and I do not know how to define patterns that avoid overlapping.

If you look at https://github.com/ansible-community/vscode-ansible/blob/master/package.json#L117 you will see that vars pattern is listed before the playbook one, so it should be picked first, right?

from vscode-ansible.

JPinkney avatar JPinkney commented on June 5, 2024

If you look at https://github.com/ansible-community/vscode-ansible/blob/master/package.json#L117 you will see that vars pattern is listed before the playbook one, so it should be picked first, right?

It evaluates everything equally, there is no way to prioritise one or the other. Let me try it with redhat-developer/yaml-language-server#417 and i'll see if that fixes it

from vscode-ansible.

JPinkney avatar JPinkney commented on June 5, 2024

I played around with playbooks/group_vars/all.yml and it looks like both schemas (vars and playbook) are currently being set. You can see this if you do:

allUsers
  aa

you'll see an error with:

Ansible Vars Schema

Incorrect type. Expected "ansible-vars.json".yaml-schema: Ansible Vars Schema
Incorrect type. Expected "array".yaml-schema: Ansible Playbook Schema

from vscode-ansible.

EpiqSty avatar EpiqSty commented on June 5, 2024

It looks like vars_prompt also affected:
with a most basic example: from https://docs.ansible.com/ansible/latest/user_guide/playbooks_prompts.html

---
- hosts: all
  vars_prompt:

    - name: username
      prompt: What is your username?
      private: no

    - name: password
      prompt: What is your password?

  tasks:

    - name: Print a message
      ansible.builtin.debug:
        msg: 'Logging in as {{ username }}'

I'm getting this error:

image

$ apt-cache policy code
code:
  Installed: 1.55.2-1618307277

redhat.vscode-yaml Preview v0.18.0
zbr.vscode-ansible Preview 0.3.2

Please let me know if it's not related and needs a separated issue.

from vscode-ansible.

ssbarnea avatar ssbarnea commented on June 5, 2024

We are unable to reproduce this with current version of the extension, please upgrade and report if you can see the error.

from vscode-ansible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.