question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add settings to configure `ansible-playbook --syntax-check`

See original GitHub issue

Problem

I have the following setup:

  • ansible
    • roles
    • dev
      • roles
      • dev.yml
    • ansible.cfg

Whenever I execute the dev/dev.yml playbook, I’m always located inside the ansible folder.
Inside my ansible.cfg, I have extended the roles_path to tell ansible to look for roles inside the ./roles as well as the ./dev/roles.
My dev/dev.yml playbook uses roles from both folders and it works perfectly fine.

However, when I try to edit the dev/dev.yml file in VSCode, I get an error stating that the roles cannot be found:

Command failed: ansible-playbook /myrepo/ansible/dev/dev.yml --syntax-check
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
ERROR! the role 'myrole' was not found in <default paths>

Solution

From what I found by searching this repository, the README and the settings of the extension, there is no way to configure the behavior of syntax checking when it’s done using ansible-playbook. I would like to either disable the checking entirely or be able to change the configuration to tell it to take my ansible.cfg into account. Or simply extend the role_paths directly even if it’s not DRY.

Alternatives

Disabling the Ansible extension entirely.
Attempted to switch to ansible-lint but ticking the checkbox didn’t change anything.

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
cedsanacommented, Jun 7, 2022

Yes, opening the ansible folder as the vscode root works properly.

0reactions
cedsanacommented, Jun 10, 2022

@priyamsahoo Sorry to bother you again but could we reopen this issue, please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ansible-playbook - Ansible Documentation
the tool to run Ansible playbooks, which are a configuration and multinode deployment ... perform a syntax check on the playbook, but do...
Read more >
Ansible Playbook, Handlers, Variables, Syntax Check - YouTube
ansibletutorial #ansibletraining #aws #devops Lecture 8th of the Ansible series will help you to understand the concept of Playbook, ...
Read more >
What is an Ansible Playbook and How to Write One on Your ...
An Ansible playbook is a file where users write Ansible code, an organized collection of scripts defining the work of a server configuration...
Read more >
How to check the syntax of an Ansible playbook - Edureka
After creating a playbook you can check the syntax before you deploy the code in the production ... ansible-playbook play.yml --syntax-check.
Read more >
Chapter 31. Using Ansible roles to permanently configure ...
This is necessary for successful configuration of kernel parameters. When Ansible playbook is run, you will be prompted for user password.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found