Giter Site home page Giter Site logo

Comments (17)

shaded-enmity avatar shaded-enmity commented on May 27, 2024 1

@gorkem @languitar PTAL: Pending PR for SchemaStore with schemas for Ansible 2.0 through 2.5

from yaml-language-server.

JPinkney avatar JPinkney commented on May 27, 2024

Out of curiosity which version of the extension are you on? I just tried doing auto completion underneath yum and was able to get state underneath it. All the items in [1] where able to autocomplete for me just fine. Do you have anymore examples by any chance?

[1] - https://raw.githubusercontent.com/shaded-enmity/prototype/master/ansible_roles/docker/tasks/main.yml

from yaml-language-server.

shaded-enmity avatar shaded-enmity commented on May 27, 2024

I'm on 0.0.7 - here's a screencast of what is happening - yum gets completed properly, however when I start typing name I get a lot of suggestions from different modules (nagios, nova, nxos ..), and then the state key is not autosuggested at all.

from yaml-language-server.

JPinkney avatar JPinkney commented on May 27, 2024

It looks like there must be differences somewhere because even with that example on my machine it works fine. Also, with the schema it should be throwing an error (which it does in mine) because under yum name is supposed to be an array of strings.

I'm not sure what would be causing this issue. I'm assuming there is another extension that is autocompleting the results such as 'nova_compute' and 'nove_keypair? Because according to the schema they aren't listed.

from yaml-language-server.

JPinkney avatar JPinkney commented on May 27, 2024

I think I may have found the issue, try doing

"yaml.schemas": {
       "ansible.json": "/opt/ansible-schemas/*.yaml"
}

or alternatively (This is what I was using to test)

"yaml.schemas": {
        "https://raw.githubusercontent.com/shaded-enmity/ansible-schema-generator/master/examples/ansible.json": "/opt/ansible-schemas/*.yaml"
}

from yaml-language-server.

shaded-enmity avatar shaded-enmity commented on May 27, 2024

Ha! I misunderstood the meaning of key/values here (to make matters worse, my file had .yml suffix), so I was probably just getting some contextual completion. Thanks!

Does the schema validation/lookup support the anyOf operator? I'm using it to distinguish between "command/shell/script" modules and the rest, example (notice how shell is now a key/value):

- name: Some other task
  shell: "echo $SOME_VAR"
  args:
    chdir: /root/some/directory

shell doesn't show up in the completion list, but after I type that the args section completes alright.

from yaml-language-server.

JPinkney avatar JPinkney commented on May 27, 2024

It does support the anyOf operator, i'm just looking into why its not behaving the expected way. Even with the json language server it doesn't give the correct completion results.

from yaml-language-server.

shaded-enmity avatar shaded-enmity commented on May 27, 2024

Currently in transit, I just realized that β€˜oneOf’ would probably better reflect the semantics, gonna try when I get home.

from yaml-language-server.

JPinkney avatar JPinkney commented on May 27, 2024

AFAIK oneOf behaves the same way.

I believe whats happening is that because one of the anyOf objects only requires name when you only have name and nothing else its only auto completing from that object. However, if you type shell first for example you will get the correct result, same with args.

Out of curiosity I tried removing the other required ones in this gist and it works.

from yaml-language-server.

gorkem avatar gorkem commented on May 27, 2024

@shaded-enmity Is this working OK for you now, can we close it? I would be very much interested on the Ansible schema. Are you planning to make it available on schemastore.org?

from yaml-language-server.

shaded-enmity avatar shaded-enmity commented on May 27, 2024

@gorkem Yes, sorry, this is working.

I've generated a schema for Ansible 2.4 which can be found at https://github.com/shaded-enmity/ansible-schema-generator/blob/master/examples/ansible.json

Good idea with schemastore.org, once I'm done with changes to support mutual exclusivity for aliases I'll generate schemas for various versions of Ansible and publish them there, thanks!

from yaml-language-server.

languitar avatar languitar commented on May 27, 2024

@shaded-enmity any news on getting the schema files onto schemastore? I'd like to use the one for 2.5 ;-)

from yaml-language-server.

shaded-enmity avatar shaded-enmity commented on May 27, 2024

@languitar Got derailed so many times by different stuff, but I guess that I could (finally) finish this tomorrow, I'll update here once I have something ready.

from yaml-language-server.

languitar avatar languitar commented on May 27, 2024

great, thanks!

from yaml-language-server.

shaded-enmity avatar shaded-enmity commented on May 27, 2024

And we're live πŸŽ‰ http://json.schemastore.org/ansible-stable-2.5

from yaml-language-server.

ssbarnea avatar ssbarnea commented on May 27, 2024

Can someone give some hints on how to enable use of Ansible schema for all roles/* and playbooks/* folders? I think I managed to make it work but it would be great to have a generic example that people can just copy/paste.

Is there a way to know which scema was used on a specific file? Other plugins do expose information on the status bar.

Also, where should we report bugs regarding ansible json schema as I found one false positible regarding the use of cacheable: true inside set_facts, where we know very well the giving the boolean value is the correct way to do it.

from yaml-language-server.

shaded-enmity avatar shaded-enmity commented on May 27, 2024

@ssbarnea Please open issues/enhancements in https://github.com/shaded-enmity/ansible-schema-generator/ β€” the current schemas are meant to be used with tasks/* only, however it should be possible to make them work in a broader context of tasks directly "embedded" into roles/playbooks.
I'll take a look what I can do about set_facts in the meantime.

Thanks!

from yaml-language-server.

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.