Configure VS Code Ansible extension to use our local venv tools instead of system defaults:
[kaau@tcacaueslapp003 ~]$ ls -ld ${HOME}/NACBSRE_sre_cac_86039
drwx------. 13 kaau kaau 4096 Aug 7 01:43 /home/kaau/NACBSRE_sre_cac_86039
[kaau@tcacaueslapp003 ~]$ ls -ld ${HOME}/NACBSRE_sre_cac_86039/.vscode
drwx------. 2 kaau kaau 84 Aug 8 18:46 /home/kaau/NACBSRE_sre_cac_86039/.vscode
[kaau@tcacaueslapp003 ~]$ ls -l ${HOME}/NACBSRE_sre_cac_86039/.vscode
-rw-------. 1 kaau kaau 445 Aug 7 01:43 extensions.json
-rw-------. 1 kaau kaau 1004 Aug 7 01:43 git-commit-instructions.md
-rw-------. 1 kaau kaau 333 Aug 8 18:46 settings.json
[kaau@tcacaueslapp003 ~]$ cat ${HOME}/NACBSRE_sre_cac_86039/.vscode/extensions.json
[[blue:{]]
[[blue: // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.]]
[[blue: // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp]]
[[blue:]]
[[blue: // List of extensions which should be recommended for users of this workspace.]]
[[blue: "recommendations": []]
[[blue: "ms-vscode-remote.remote-ssh",]]
[[blue: "eamodio.gitlens",]]
[[blue: "redhat.ansible",]]
[[blue: "redhat.vscode-yaml",]]
[[blue: "GitHub.vscode-pull-request-github",]]
[[blue: "GitHub.copilot-chat"]]
[[blue: ]]]
[[blue:}]]
[kaau@tcacaueslapp003 ~]$ cat ${HOME}/NACBSRE_sre_cac_86039/.vscode/settings.json
[[blue:{]]
[[blue: "ansible.executionEnvironment.enabled": false,]]
[[blue: "ansible.python.interpreterPath": "/home/kaau/venv/bin/python",]]
[[blue: "ansible.validation.lint.enabled": true,]]
[[blue: "ansible.validation.lint.path": "/home/kaau/venv/bin/ansible-lint",]]
[[blue: "python.defaultInterpreterPath": "/home/kaau/venv/bin/python",]]
[[blue: "yaml.validate": true]]
[[blue:}]]
| setting | effect |
|---|---|
| ansible.executionEnvironment.enabled: false | disables container-based execution (EE). Ansible runs directly on the host, not inside a Docker/Podman image |
| ansible.python.interpreterPath | tells the Ansible extension which Python to use, aka our venv’s and not the system Python |
| ansible.validation.lint.enabled: true | turns on real-time ansible-lint feedback in the editor: red squiggles and Problems panel as we type |
| ansible.validation.lint.path | points the extension to ~/venv/bin/ansible-lint, so it uses the same version and .ansible-lint config as your terminal runs |
| python.defaultInterpreterPath | sets the default Python interpreter for the Pylance/Python extension in order to be consistent with the venv |
| yaml.validate: true | enables YAML schema validation for .yml files via the Red Hat YAML extension |
Run ansible-lint on nacbsre/cac_collection:
[kaau@tcacaueslapp003 ~]$ cd ${HOME}/NACBSRE_sre_cac_86039
[kaau@tcacaueslapp003 NACBSRE_sre_cac_86039]$ source ${HOME}/venv/bin/activate
(venv) [kaau@tcacaueslapp003 NACBSRE_sre_cac_86039]$ ansible-lint nacbsre/cac_collection
WARNING Unable to load module mail at nacbsre/cac_collection/roles/sre_config_report/tasks/managed_files_report.yml:52 for options validation
WARNING Unable to resolve FQCN for module mail
WARNING Unable to load module nacbsre.cac_collection.cac_lock at nacbsre/cac_collection/roles/sre_was_build/tasks/main.yml:16 for options validation
::
::
::
::
WARNING Unable to load module nacbsre.cac_collection.veritas_infoscale at nacbsre/cac_collection/roles/sre_veritas_infoscale/tasks/configure_sfcfsha.yml:10 for options validation
WARNING Listing 248 violation(s) that are fatal
[[red:galaxy[no-changelog]: No changelog found. Please add a changelog file. Refer to the galaxy.md file for more info.]]
[[blue:nacbsre/cac_collection/galaxy.yml:1]]
[[red:galaxy[tags]: galaxy.yaml must have one of the required tags: ['application', 'cloud', 'database', 'infrastructure', 'linux', 'monitoring', 'networking',]]
[[red:'security', 'storage', 'tools', 'windows']]]
[[blue:nacbsre/cac_collection/galaxy.yml:1]]
[[red:yaml[document-start]: Missing document start "---"
[[blue:nacbsre/cac_collection/galaxy.yml]]:5
[[red:yaml[indentation]: Wrong indentation: expected 2 but found 0
[[blue:nacbsre/cac_collection/galaxy.yml]]:19
[[red:yaml[line-length]: Line too long (223 > 180 characters)
[[blue:nacbsre/cac_collection/galaxy.yml]]:23
[[red:yaml[indentation]: Wrong indentation: expected 2 but found 0
[[blue:nacbsre/cac_collection/galaxy.yml]]:28
[[red:yaml[comments]: Missing starting space in comment
[[blue:nacbsre/cac_collection/galaxy.yml]]:43
::
::
::
::
[[red:yaml[comments]: Too few spaces before comment: expected 2]]
[[blue:nacbsre/cac_collection/roles/sre_was_build/molecule/operations/molecule.yml]]:2
[[red:yaml[comments-indentation]: Comment not indented like content]]
[[blue:nacbsre/cac_collection/roles/sre_was_build/molecule/operations/molecule.yml]]:16
WARNING The following filters were mocked during the run: ansible.utils.ipaddr,ansible.utils.remove_keys,json_query
Read documentation for instructions on how to ignore specific rule violations.
Rule Violation Summary
count tag profile rule associated tags
[[red: 6 key-order[task] basic formatting ]]
[[yellow: 12 jinja[spacing] basic formatting (warning) ]]
[[red: 1 no-free-form basic syntax, risk ]]
[[red: 1 partial-become[task] basic unpredictability ]]
[[red: 1 schema[meta-runtime] basic core ]]
[[red: 3 name[missing] basic idiom ]]
[[red: 33 var-naming[no-role-prefix] basic idiom ]]
[[red: 2 yaml[braces] basic formatting, yaml ]]
[[red: 11 yaml[comments-indentation] basic formatting, yaml ]]
[[red: 29 yaml[comments] basic formatting, yaml ]]
[[red: 1 yaml[document-start] basic formatting, yaml ]]
[[red: 3 yaml[empty-lines] basic formatting, yaml ]]
[[red: 10 yaml[indentation] basic formatting, yaml ]]
[[red: 15 yaml[line-length] basic formatting, yaml ]]
[[red: 6 yaml[new-line-at-end-of-file] basic formatting, yaml ]]
[[red: 2 yaml[trailing-spaces] basic formatting, yaml ]]
[[red: 1 yaml[truthy] basic formatting, yaml ]]
[[red: 81 name[casing] moderate idiom ]]
[[red: 2 risky-file-permissions safety unpredictability ]]
[[red: 1 galaxy[no-changelog] shared metadata ]]
[[red: 1 galaxy[tags] shared metadata ]]
[[red: 3 fqcn[action-core] production formatting ]]
[[red: 23 fqcn[keyword] production formatting ]]
[[red:Failed]]: [[blue:236]] [[red:failure(s)]], [[blue:12]] [[red:warning(s)]] on [[blue:412]] files. Last profile that met the validation criteria was [[green:'min']].
(venv) [kaau@tcacaueslapp003 NACBSRE_sre_cac_86039]$ deactivate
Run ansible-lint on a particular role in nacbsre/cac_collection:
[kaau@tcacaueslapp003 ~]$ cd ${HOME}/NACBSRE_sre_cac_86039/nacbsre/cac_collection
[kaau@tcacaueslapp003 cac_collection]$ ls -l roles
drwx------. 6 kaau kaau 82 Aug 7 01:43 sre_cac_report
drwx------. 5 kaau kaau 69 Aug 7 01:43 sre_config_report
drwx------. 4 kaau kaau 49 Aug 7 01:43 sre_data_validation
drwx------. 9 kaau kaau 180 Aug 7 01:43 sre_driftdetector
drwx------. 7 kaau kaau 94 Aug 7 01:43 sre_ihs_build
drwx------. 8 kaau kaau 161 Aug 7 01:43 sre_linux_config_deploy
drwx------. 5 kaau kaau 68 Aug 7 01:43 sre_managed_files_deploy
drwx------. 8 kaau kaau 107 Aug 7 01:43 sre_mq_build
drwx------. 7 kaau kaau 119 Aug 7 01:43 sre_oracle_build
drwx------. 7 kaau kaau 94 Aug 7 01:43 sre_os_hardening
drwx------. 4 kaau kaau 52 Aug 7 01:43 sre_pkg_deploy
drwx------. 4 kaau kaau 52 Aug 7 01:43 sre_pkg_download
drwx------. 5 kaau kaau 64 Aug 7 01:43 sre_send_email
drwx------. 3 kaau kaau 36 Aug 7 01:43 sre_service_operation
drwx------. 7 kaau kaau 94 Aug 7 01:43 sre_tomcat_build
drwx------. 3 kaau kaau 36 Aug 7 01:43 sre_veritas_infoscale
drwx------. 9 kaau kaau 183 Aug 7 01:43 sre_was_build
[kaau@tcacaueslapp003 cac_collection]$ source ${HOME}/venv/bin/activate
(venv) [kaau@tcacaueslapp003 cac_collection]$ ansible-lint --nocolor roles/sre_oracle_build
or
(venv) [kaau@tcacaueslapp003 cac_collection]$ ansible-lint roles/sre_oracle_build
WARNING Unable to load module ansible.utils.validate at roles/sre_data_validation/tasks/config_data_validate.yml:2 for options validation
WARNING Unable to resolve FQCN for module ansible.utils.validate
WARNING Unable to load module community.general.archive at roles/sre_driftdetector/tasks/update_managed_file_list.yml:14 for options validation
WARNING Unable to resolve FQCN for module community.general.archive
WARNING Listing 2 violation(s) that are fatal
[[red:var-naming[no-role-prefix]: Variables names from within roles should use sre_pkg_deploy_ as a prefix. (vars: package)]]
[[blue:roles/sre_mq_build/tasks/qmgr_deploy_item.yml]]:35 Task/Handler: Deploy MQ queue managers
[[red:var-naming[no-role-prefix]: Variables names from within roles should use sre_service_operation_ as a prefix. (vars: operation)]]
[[blue:roles/sre_pkg_deploy/tasks/post_config_service_operation.yml]]:6 Task/Handler: Bring service to desired state
Read documentation for instructions on how to ignore specific rule violations.
Rule Violation Summary
count tag profile rule associated tags
[[red:2 var-naming[no-role-prefix] basic idiom]]
[[red:Failed]]: [[blue:2]] [[red:failure(s)]], [[blue:0]] [[red:warning(s)]] on [[blue:89]] files. Last profile that met the validation criteria was [[green:'min']].
(venv) [kaau@tcacaueslapp003 cac_collection]$ deactivate