The VS Code Ansible extension recognizes my playbooks and does a very nice job with colorizing, hover help, etc. However it does not do the same for my roles. My directory structure:
my_project/
roles/
scenarios/
<playbook yml's>
Note that I can’t change this as I’m working on a large project where lots of people and code expect this structure. The playbooks run fine. I’m on macOS if that matters.
I’ve added an ansible.cfg
file (in a parent of my_project
) which contains:
[defaults]
roles_path = $HOME/path_to_project/my_project/roles
I know VS Code is finding that file as it complained about an error in it. Adding that file did cause ansible-lint
to run against the roles, but still no colorizing, hover help, etc.
I’ve looked at all the Ansible extension settings and I’m not seeing anything obvious. Any suggestions much appreciated!
For me to get ansible-lint
to work in a similar scenario inside vscode was to have the ansible.cfg in the root of the directory that’s opened as folder in vscode.
My layout is actually like the following, and a symlink from /workspace/ansible.cfg to /workspace/ansible/ansible.cfg worked.
workspace/
ansible/
playbooks/
roles/
ansible.cfg
ansible.cfg -> ansible/ansible.cfg
In my case I’m attaching to a docker container where /workspace/ansible
is also mounted to /ansible
and ansible.cfg
contains the following:
[defaults]
home = /ansible
inventory = /ansible/inventory.yml
# ...