[ansible-lint](https://ansible-lint.readthedocs.io/) is the official linter for Ansible content such playbooks, collections, roles.
Questions tagged [ansible-lint]
23 questions
31
votes
2 answers
How to nicely split on multiple lines long conditionals with OR on ansible?
I already know that if you have long conditionals with and between them you can use lists to split them on multiple lines.
Still, I am not aware of any solution for the case where you have OR between them.
Practical example from real life:
when:…

sorin
- 161,544
- 178
- 535
- 806
13
votes
1 answer
ANSIBLE0013 Use shell only when shell functionality is required
In a Ansible role, I do this:
- name: update trusted ca
shell: "{{ in_ca_dict[ansible_os_family]['update']['shell'] }}"
with:
package_name: ca-certificates
RedHat:
path:
6: /usr/local/share/ca-certificates
7:…

Juliatzin
- 18,455
- 40
- 166
- 325
8
votes
2 answers
Line too long: Ansible lint
This is my Ansible task
- name: no need to import it.
ansible.builtin.uri:
url: >
https://{{ vertex_region }}-aiplatform.googleapis.com/v1/projects/{{ project }}/locations/{{ vertex_region }}/datasets/{{ dataset_id }}/dataItems
…

quicksilver
- 289
- 5
- 11
7
votes
1 answer
Ansible lint reports "Package installs should not use latest"
I've finally started using Ansible Lint to ensure I'm up to date and not missing things and I've found it reporting a curious error/notice. When I use dnf to install a package, I've been using state: latest as it's for a system bootstrapping…

oucil
- 4,211
- 2
- 37
- 53
2
votes
1 answer
Handling of global roles directory with ansible-lint
I have split my custom ansible roles and the ones downloaded from ansible-galaxy into seperate directories (./roles and ~/.ansible/roles).
In .ansible.cfg I have added the following configuration:
[...]
roles_path =…

Timbo
- 75
- 8
2
votes
0 answers
ansible - mount -o remount /
A want just remount / on my host.
If I use a command module:
- name: Change noacl in /etc/fstab
become: True
replace:
dest: /etc/fstab
backup: yes
regexp: 'noacl'
replace: 'acl'
register: fstab
- name: remounte /
become:…

Zak Shirak
- 89
- 4
- 12
1
vote
2 answers
ansible-lint failing with: AttributeError: 'str' object has no attribute 'resolve'
While running a github linter workflow on a new CentOS VM that I set up, I got the following error:
Run ansible-lint --parseable ./ansible
Traceback (most recent call last):
File "/usr/local/bin/ansible-lint", line 8, in
…

Annemie
- 157
- 1
- 3
- 13
1
vote
0 answers
How to import both playbooks and tasks in an Ansible playbook
I have several playbooks that I sometimes execute individually but I also want to group them in one "master" playbook so that they can all be executed sequentially. I do this using ansible.builtin.import_playbook. In this same playbook I also want…

Ricardo Marques
- 21
- 5
1
vote
1 answer
Encountering an error decoupling tasks and vars from playbooks via roles
To start, I have a basic ansible directory structure for roles.
In the [ansible] directory:
- inventory
- playbook.yml
- [roles]
- [gui_utils]
- [defaults]
- main.yml
- [files]
- main.yml
-…

jordan.mcleod
- 13
- 5
1
vote
1 answer
Ansible Lint trailing space
I have performed ansible lint check on the below yml code, even though there is no trailing spaces, I'm receiving trailing whitespace warning for the indentation that has been given. Can you advice on how that can be overcome
---
- hosts: localhost
…

Vin
- 61
- 2
- 8
1
vote
1 answer
Identify Ansible playbooks
I would like to add an automatic syntax check (as CI process) for all the Ansible playbooks in my project, using ansible-lint.
There are playbooks in several directories in the project, so I thought of using something like locate *.yml. However,…

ChikChak
- 936
- 19
- 44
0
votes
0 answers
Ansible-Lint warning for custom module argument exception
I have a custom module to manage Keycloak realms. That module takes a long list of arguments including a sub-dictionary for smtp_server:
def keycloak_argument_spec():
return dict(
auth_keycloak_url=dict(type='str', aliases=['url'],…

TRW
- 876
- 7
- 23
0
votes
0 answers
ansible-lint complaining about usage of reigstered variable in a Jinja template
I have the following ansible role:
- name: Copy trusted certificates
ansible.builtin.copy:
src: "{{ item }}"
dest: '{{ ssl_certs_path }}/'
register: installed_certs
with_items: '{{ ssl_trusted_certs }}'
become: true
- name:…

mat
- 1,645
- 15
- 36
0
votes
1 answer
Ansible Lint isn't able to catch certain errors for the playbook tasks
name[missing] rule is not checked for the standalone playbook. however, its checked for the role though. here is an example ansible-playbook I tested and once I run ansible-lint, it says 'Passed with production profile: 0 failure(s), 0 warning(s) on…

Aseef Ahmed
- 1
- 3
0
votes
1 answer
Ansible-lint in a CI pipeline with many sub directories
The current set up of my project is
/projects
/plugins
/roles/sampleRole1/...
/roles/sampleRole2/..
galaxy.yml
I want to lint each any every role that exists within "/roles" but I am having trouble figuring out a solution and running into…

Michael Jones
- 11
- 2