ansible-lint-poc/venv.yml
Chris Hammer 8afe04bd3f add cleanup and change lint_work_dir
add pause so we can have time to check managed nodes filesystem
2023-11-10 13:04:28 -05:00

94 lines
2.4 KiB
YAML

- name: Test Ansible Lint Formatting via VirtualEnv
hosts: all
become: true
gather_facts: true
vars:
ansible_lint_venv_dir : /tmp/ansible-lint-venv
git_repo_to_lint : https://gitea.thezengarden.net/chris/ansible-lint-poc.git
lint_work_dir : /tmp/lint_repository
tasks:
- name: Enable CRB repository for python3-wheel (required by virtualenv)
ansible.builtin.command:
cmd: dnf config-manager --enable crb
changed_when: true
- name: Ensure virtualenv command is present
ansible.builtin.package:
name:
- python3-setuptools
- virtualenv
state: present
- name: Disable CRB repository as it is no longer neded
ansible.builtin.command:
cmd: dnf config-manager --disable crb
changed_when: true
- name: Create VirtualEnv and Install ansible-lint
ansible.builtin.pip:
name: ansible-lint==6.22.0
virtualenv: "{{ ansible_lint_venv_dir }}"
virtualenv_python: python3.9
- name: Ansible Lint Debug Information
block:
- name: Test Ansible Lint - Version
ansible.builtin.command: "{{ ansible_lint_venv_dir }}/bin/ansible-lint --nocolor --version"
register: r_lint_version
changed_when: false
- name: Test Ansible Lint - Help
ansible.builtin.command: "{{ ansible_lint_venv_dir }}/bin/ansible-lint --nocolor --help"
register: r_lint_help
changed_when: false
- name: Show ansible-lint infos
ansible.builtin.debug:
msg:
- "'ansible-lint --version': {{ r_lint_version['stdout'] }}"
- "'ansible-lint --help': {{ r_lint_help['stdout'] }}"
verbosity: 1
- name: Create destination for cloned repositories
ansible.builtin.file:
path: "{{ lint_work_dir }}"
state: directory
mode: "0755"
- name: Clone target repository into
ansible.builtin.git:
repo: "{{ git_repo_to_lint }}"
dest: "{{ lint_work_dir }}"
version: main
- name: Clone target repository into
ansible.builtin.pause:
seconds: 30
- name: Cleanup repository destination
ansible.builtin.file:
path: "{{ lint_work_dir }}"
state: absent
- name: Cleanup installed packages
ansible.builtin.package:
name:
- python3-setuptools
- virtualenv
state: absent