66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
- name: Test Ansible Lint Formatting
|
|
hosts: localhost
|
|
connection: local
|
|
become: false
|
|
gather_facts: false
|
|
|
|
|
|
tasks:
|
|
- name: Test Ansible Lint - Version
|
|
ansible.builtin.command: ansible-lint --version
|
|
changed_when: false
|
|
|
|
|
|
- name: Test Ansible Lint - Help
|
|
ansible.builtin.command: ansible-lint --help
|
|
changed_when: false
|
|
|
|
|
|
- name: Test Ansible Lint - Playbooks/Roles
|
|
ansible.builtin.command: ansible-lint --nocolor --format json
|
|
ignore_errors: true
|
|
changed_when: false
|
|
register: r_lint_output
|
|
|
|
|
|
- name: Debug r_lint_output
|
|
ansible.builtin.debug:
|
|
verbosity: 1
|
|
var: r_lint_output['stdout']
|
|
|
|
|
|
- name: Capture ansible-lint warnings and errors
|
|
ansible.builtin.set_fact:
|
|
r_lint_warnings: "{{ r_lint_output['stdout'] | from_json | selectattr('level', 'equalto', 'warning') }}"
|
|
r_lint_failures: "{{ r_lint_output['stdout'] | from_json | selectattr('level', 'equalto', 'error') }}"
|
|
|
|
|
|
- name: Debug r_lint_warnings
|
|
ansible.builtin.debug:
|
|
verbosity: 1
|
|
var: r_lint_warnings
|
|
|
|
|
|
# - name: Debug r_lint_warnings
|
|
# ansible.builtin.debug:
|
|
# msg:
|
|
# - "File: {{ item['location']['path'] }}"
|
|
# - "Level: {{ item['level'] }}"
|
|
# - "Severity: {{ item['severity'] }}"
|
|
# - "Description: {{ item['description'] }}"
|
|
# loop: "{{ r_lint_warnings }}"
|
|
# loop_control:
|
|
# label: "{{ item['location']['path'] }}"
|
|
|
|
|
|
# - name: Debug r_lint_failures
|
|
# ansible.builtin.debug:
|
|
# msg:
|
|
# - "File: {{ item['location']['path'] }}"
|
|
# - "Level: {{ item['level'] }}"
|
|
# - "Severity: {{ item['severity'] }}"
|
|
# - "Description: {{ item['description'] }}"
|
|
# loop: "{{ r_lint_failures }}"
|
|
# loop_control:
|
|
# label: "{{ item['location']['path'] }}"
|