๐ฑ @shaded-enmity ๐ฑ
Build it, break it, rinse and repeat!
Generate JSON schema for language servers from Ansible module documentation
License: GNU General Public License v3.0
๐ฑ @shaded-enmity ๐ฑ
Build it, break it, rinse and repeat!
ansible recommends using FQCNs and tasks from ansible-base are on ansible.builtin
namespace. Is it possible to add support for them?
Per the copy module's docs, the mode
parameter may be either a string or an octal number.
Judging from the results I get with https://github.com/redhat-developer/yaml-language-server, I think this project generates a schema allowing only strings.
I say "I think" because I came here from https://github.com/SchemaStore/schemastore, which I believe is using this project to generate its Ansible schema.
That project currently has a bug report for this issue that has received no comments or response:
and I thought this was probably the right place to bring it up for further discussion.
Hi @shaded-enmity according to this: ansible/ansible#42033 (review) I had to change the documentation to use dict
instead of object
.
Current code does not map the dict
type:
TYPE_MAP = {
'int': {'$ref': '#/definitions/ansible_number'},
'bool': {'$ref': '#/definitions/ansible_truth'},
'str': 'string',
'float': 'number',
'object': 'object'
}
Is that the place to fix it? If so I can create a PR for it.
You can use travis to install and generate a schema for latest version of ansible and to create a PR against its own project for updating the schema.
Having an already build schema cached would be extremely useful, as we can start consuming it from other projects like https://github.com/redhat-developer/vscode-yaml/issues
Does this schema allow you to use templated variables in your YAML? For example, when I validate this yaml file using http://json.schemastore.org/ansible-stable-2.5:
---
- name: test
yum:
name: foo
state: "{{ bar }}"
on the last line, it says Value is not accepted. Valid values: "absent", "installed", "latest", "present", "removed".
I am trying to use this schema with yaml-language-server. After setting everything up, I create a new yml file and start editing it. I want this file to be a playbook:
- hosts: all
tasks:
- apt:
The first issue is that I get no completions for the tasks. Then, hosts
complains that it needs a shell
property. From what I understand the schema file supports only yml files with tasks and not playbooks. Is this the case? If so, can playbook support be added? Is there an existing workaround?
I'm not familiar with ansible but it seems include_tasks and import_tasks should be strings or objects instead of just objects.
Related link: redhat-developer/vscode-yaml#105
The generated schemas seem to list path
as a required property under the template
module.
This is wrong.
In fact, the template
module doesn't even have a path
property.
Instead, the required properties are src
and dest
.
This seems to cause redhat-developer/vscode-yaml#181 (because this generator has been used to create SchemaStore/schemastore#666)
Currently only the common "generic" types like number
, truth
etc are handled using definitions.
To enable using the schemas in a context of tasks embedded into roles
and playbooks
we should make the main schema a definition as well that we can further reference from sub schemas.
https://docs.ansible.com/ansible/latest/modules/apt_module.html#parameters
name: A list of package names,
This is perfectly valid ansible
- name: install packages
apt:
name:
- foo
- bar
But this results in errors, since the schema is reporting that 'name' should be a string.
Tried running the example from examples/
dir and whats getting run in test.sh
. Both fail out with:
2021-11-03 23:05:28,152 [2044615] CRITICAL ansible-schema: Traceback (most recent call last):
File "/home/mike/git/gh/ansible-schema-generator/./ansible-schema-generator", line 734, in <module>
main()
File "/home/mike/git/gh/ansible-schema-generator/./ansible-schema-generator", line 651, in main
for filename, module in parsed_files.iteritems():
AttributeError: 'collections.OrderedDict' object has no attribute 'iteritems'
Installed requirements.txt
. Anything I'm missing?
Hello,
I've spotted a missing comma in definition of boolean at https://github.com/shaded-enmity/ansible-schema-generator/blob/master/ansible-schema-generator#L70.
For properties like https://docs.ansible.com/ansible/latest/modules/k8s_module.html#parameter-wait_condition the schema generated for the wait_condition
property is being defined as string:
"wait_condition": {
"type": "string",
"description": "Specifies a custom condition on the status to wait for. Ignored if C(wait) is not set or is set to False."
}
when I believe it should be an object with properties.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.