Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Ansible "!vault" tag should be known #194

Open
oncipriani opened this issue Oct 5, 2018 · 19 comments
Open

The Ansible "!vault" tag should be known #194

oncipriani opened this issue Oct 5, 2018 · 19 comments

Comments

@oncipriani
Copy link

oncipriani commented Oct 5, 2018

Issue Type: Bug

When using ansible-vault encrypt_string to create a single encrypted variable and pasting it into any YAML file, Visual Studio Code complains with the following message:

unknown tag <!vault>

Extension version: 0.5.1
VS Code version: Code 1.27.2 (f46c4c469d6e6d8c46f268d1553c5dc4b475840f, 2018-09-12T16:17:45.060Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i5-3340 CPU @ 3.10GHz (4 x 3093)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 7.91GB (2.85GB free)
Process Argv C:\Program Files\Microsoft VS Code\Code.exe
Screen Reader no
VM 0%
@yungezz
Copy link
Contributor

yungezz commented Oct 8, 2018

thanks for reporting the issue. Yaml validation is based on yaml language server, it has no knowledge of ansible specific syntax including vault. will try to look at if there's way to suppress specific error, which i suspect might not.

@Taoquitok
Copy link

The vscode yaml project has a solution to this using custom tags, but this ansible extension overrides their solution. Are you able to implement their suggestion into this project?
redhat-developer/vscode-yaml#93

@oncipriani
Copy link
Author

Simply adding "yaml.customTags": [ "!vault" ] to "settings.json" results in an "Unknown configuration setting" complaint by Visual Studio.

After installing the "redhat.vscode-yaml" extension, the "Unknown configuration setting" error is gone, but the "unknown tag <!vault>" persists.

@Taoquitok
Copy link

@oncipriani, yep. If you disable the vscode-ansible extension the "unknown tag" error will go, so some part of the vscode-ansible extension is overriding the functionality from the vscode-yaml extension.
For the time being I've disabled the vscode-ansible extension as the yaml one covers the main functionality I need in respect to ansible as a work around

@oncipriani
Copy link
Author

@Taoquitok, I removed the vscode-ansible extension. The error was more annoying than the benefits the extension provided.

Thank you.

@yungezz
Copy link
Contributor

yungezz commented Oct 26, 2018

@oncipriani before we support custom tags, you could disable the validation by setting "ansible.validation": false to disable the validation. Will update after it's supported.

@ghost
Copy link

ghost commented Nov 12, 2018

@oncipriani before we support custom tags, you could disable the validation by setting "ansible.validation": false to disable the validation. Will update after it's supported.

Wouldn't this disable all validation? This extension is a real life saver for me, since it helps me write faster, a lot faster, than normal. Disabling the validation would break everything for me. Sorry to nag, but we got any status of when we can either support this tag, or if we will be able to use the "yaml.customTags": [ "!vault" ] to configure this?

Thanks!

@kpocius
Copy link

kpocius commented Nov 12, 2018

@f-eric, I believe the idea for now is to use vscode-yaml for YAML validation (with custom tags) and vscode-ansible for Ansible stuff. The description of ansible.validation parameter is "Enable/Disable validation on yaml content", so it only seems to affect YAML (also confirmed by running a quick test just now).

@ghost
Copy link

ghost commented Nov 12, 2018

@kpocius Thanks for the quick reply! I suppose you're right. I'll switch plugin when working with these specific files. And thanks again, for leading me the right way. 🙂

@ghost
Copy link

ghost commented Nov 12, 2018

Actually, I just configured the yaml.customTags and it's all working..! I'm using VScode 1.2.7 on RHEL 7.5.
@oncipriani You still have the issue of this not working?

@oncipriani
Copy link
Author

@f-eric Configuring yaml.customTags still results in an "Unknown configuration setting" complaint by Visual Studio.

Setting ansible.validation to false is a pretty decent workaround, so that's what I'm using.

My Visual Studio version information (running on Windows 10):

Version: 1.28.2 (system setup)
Commit: 7f3ce96ff4729c91352ae6def877e59c561f4850
Date: 2018-10-17T00:23:51.859Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

@snoopotic
Copy link

Hi. This an annoying one. What do you need to fix it? Can I help?

@yungezz
Copy link
Contributor

yungezz commented May 21, 2019

hi @snoopotic you could disable the validation by setting "ansible.validation": false to disable the validation.

@snoopotic
Copy link

@yungezz but isn't one main purpose of the ansible plugin to HAVE validation? So disabling is a workaround.

@ghost
Copy link

ghost commented Jul 24, 2019

@yungezz this is fixed in the language server, see:
redhat-developer/yaml-language-server#59

@nvitaterna
Copy link

I am having the same issue - even with "!valut" in my yaml.customTags setting.

@mlvnds
Copy link

mlvnds commented Feb 11, 2020

For new readers, the workaround I'm using to get rid of false errors when using the <!vault> tag:

  • Install redhat.vscode-yaml extension
  • Disable Ansible YAML validation by updating your settings.json (View > Command Palette > Preferences: Open Settings (JSON))
    "ansible.validation": false,
  • Add new trusted tag to redhat.vscode-yaml extension
    "yaml.customTags" : [ "!vault" ],

@xcorp
Copy link

xcorp commented May 26, 2020

Just want to chime in and say this affects me as well.
Disabling validation kinda defeats the purpose of having the plugin.

@TriplEight
Copy link

add to @Melvin-mlp 's suggestion:
There's no need to disable Ansible YAML validation, all you need is to

  • Remove Miscosoft ansible extension (@ext:vscoss.vscode-ansible)
  • Install redhat.vscode-yaml extension
  • Add new trusted tag to redhat.vscode-yaml extension so it looks like this:
{
    "some.ext": "some.setting",
    "yaml.customTags": ["!vault",]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants