Comments (17)
@gorkem @languitar PTAL: Pending PR for SchemaStore with schemas for Ansible 2.0 through 2.5
from yaml-language-server.
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.
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.
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.
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.
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.
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.
Currently in transit, I just realized that βoneOfβ would probably better reflect the semantics, gonna try when I get home.
from yaml-language-server.
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.
@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.
@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.
@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.
@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.
great, thanks!
from yaml-language-server.
And we're live π http://json.schemastore.org/ansible-stable-2.5
from yaml-language-server.
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.
@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)
- yaml is not validating correctly the config.yml file for github
- openapi discriminators
- Proposal for Donating the yaml-language-server Project to an Open Governance Foundation HOT 4
- Show enum values on hover HOT 1
- Github workflow deploy.yml detected as a PHP Deployer config
- docs: The examples in the README have their syntax set wrong
- YAML `---` for "Multiple documents within a single stream" doesn't work [YAML Language Server] HOT 1
- Cannot Load content for: schema.json Unknown schema: file
- URL fragment references does not resolve correctly
- Use inline JSON Schema w/o modeline - make `yaml-language-server` string optional
- Hover: Show root property title and description when using anyOf untitled un-described types
- Schema association with fallbacks (wildcards) HOT 1
- Is there tilde expanstion feature on the horizon (or already supported) in schemas paths?
- yamlls + schema working fine in neovim?
- openshift schemas in nvim with yamlls
- Add support for specifying schema via `# $schema: β¦`
- RFC: Support schema from a child definition HOT 1
- How to configure yamlls at a workspace level for neovim?
- Use schema from `"$schema":` for current JSON file HOT 2
- Is path auto completion for $ref not supported?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaml-language-server.