Document how to automatically run ansible-lint inside code editors, e.g. flycheck in emacs #1326
-
Issue Type
Ansible and Ansible Lint details$ ansible --version
ansible 2.8.2
config file = /home/pan14001/src/ansible-hpc-storrs/ansible.cfg
configured module search path = ['/home/pan14001/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/pan14001/.local/lib64/python3.6/site-packages/ansible
executable location = /home/pan14001/.local/bin/ansible
python version = 3.6.5 (default, May 21 2019, 11:44:44) [GCC 8.3.0] $ ansible-lint --version
ansible-lint 4.1.0
Desired BehaviourPlease update the documentation to explain how to integrate The git hooks are less useful than seeing lint messages inside of a code editor; one can several files and then have to spend a lot of time after the fact trying to correct issues instead of being advised early on. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Here's what I ended up writing in my ;;; ansible-lint
; Compile regex for ansible-lint
(require 'compile)
(add-to-list 'compilation-error-regexp-alist
'yaml)
(add-to-list 'compilation-error-regexp-alist-alist
'(yaml "^\\(.*?\\):\\([0-9]+\\)" 1 2)
)
; Replace make -k with ansible-lint, with an UTF-8 locale to avoid crashes
(defun ansible-lint-errors ()
(make-local-variable 'compile-command)
(let ((ansiblelint_command "ansible-lint ") (loc "LANG=C.UTF-8 "))
(setq compile-command (concat loc ansiblelint_command buffer-file-name)))
)
(add-hook 'yaml-mode-hook 'ansible-lint-errors) Then you can use the classical compile workflow ( I pushed a PR with a similar code to the ansible mode repository so that it's integrated with |
Beta Was this translation helpful? Give feedback.
-
You can also use the flymake-ansible-lint package: https://github.com/jamescherti/flymake-ansible-lint.el |
Beta Was this translation helpful? Give feedback.
You can also use the flymake-ansible-lint package: https://github.com/jamescherti/flymake-ansible-lint.el