Skip to content

Commit

Permalink
Merge pull request #26 from branic/linting_update
Browse files Browse the repository at this point in the history
Update linting configuration and fix lint errors
  • Loading branch information
djdanielsson authored Oct 1, 2022
2 parents a768bc9 + 7d45c73 commit 4b05e4b
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 59 deletions.
22 changes: 22 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# The exclude_paths does not appear to be working in pre-commit
# this issue describes similar behavior but suggested fix doesn't work
# https://github.com/ansible/ansible-lint/issues/371
# exclude_paths:
# - roles/master_role_example/
exclude_paths:
- '.github/'
- 'roles/master_role_example/'
- 'changelogs/'
parseable: true
use_default_rules: true
# https://github.com/ansible/ansible-lint/issues/808
# with verbosity set to 1, its dumping 'unknown file type messages'
# verbosity: 1
skip_list: []
kinds:
- playbooks: "**/examples/*.{yml,yaml}"
- tasks: "**/examples/tasks/*.yml"
- vars: "**/examples/vars/*.yml"
- vars: "**/examples/**/*.yml"
...
24 changes: 0 additions & 24 deletions .ansiblelint.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/tests/ee_builder/ee_builder_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
version: 0.3.2-develh
- name: containers.podman
ee_append:
- RUN useradd build; dnf -y module enable container-tools:rhel8; dnf -y update; dnf -y reinstall shadow-utils; dnf -y install podman fuse-overlayfs /etc/containers/storage.conf; rm -rf /var/cache /var/log/dnf* /var/log/yum.* # noqa line-length
- RUN useradd build; dnf -y module enable container-tools:rhel8; dnf -y update; dnf -y reinstall shadow-utils; dnf -y install podman fuse-overlayfs /etc/containers/storage.conf; rm -rf /var/cache /var/log/dnf* /var/log/yum.*
- RUN useradd podman; echo podman:10000:5000 > /etc/subuid; echo podman:10000:5000 > /etc/subgid;
- RUN chown podman:podman -R /home/podman
- ADD https://raw.githubusercontent.com/containers/libpod/master/contrib/podmanimage/stable/containers.conf /etc/containers/containers.conf
- ADD https://raw.githubusercontent.com/containers/libpod/master/contrib/podmanimage/stable/podman-containers.conf /home/podman/.config/containers/containers.conf # noqa line-length
- ADD https://raw.githubusercontent.com/containers/libpod/master/contrib/podmanimage/stable/podman-containers.conf /home/podman/.config/containers/containers.conf
- RUN chown podman:podman -R /home/podman
- RUN sed -i -e 's|^#mount_program|mount_program|g' -e '/additionalimage.*/a "/var/lib/shared",' /etc/containers/storage.conf
- RUN mkdir -p /var/lib/shared/overlay-images /var/lib/shared/overlay-layers; touch /var/lib/shared/overlay-images/images.lock; touch /var/lib/shared/overlay-layers/layers.lock # noqa line-length
- RUN mkdir -p /var/lib/shared/overlay-images /var/lib/shared/overlay-layers; touch /var/lib/shared/overlay-images/images.lock; touch /var/lib/shared/overlay-layers/layers.lock
- RUN sed -i -e '/^cgroup_manager.*/d' -e '/\#\ cgroup_manager\ =/a cgroup_manager = "cgroupfs"' /usr/share/containers/containers.conf
- ENV _BUILDAH_STARTED_IN_USERNS="" BUILDAH_ISOLATION=chroot
roles:
Expand Down
2 changes: 1 addition & 1 deletion .github/tests/ee_builder/ee_tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ inspect:
digest: sha256:e8695f61ddda352e39965391ea5cc191cbaf3af99e253708b64c5c742814f399
graph_driver:
data:
lower_dir: /home/excalibrax/.local/share/containers/storage/overlay/ac5e4c66483774de5e5646819d717e439bbce82a4b96cd781a3fea794bb528df/diff:/home/excalibrax/.local/share/containers/storage/overlay/918a87e3b2f4ce6dcf75d94a41883eb9392d82557b4303069fa882d4998f4474/diff:/home/excalibrax/.local/share/containers/storage/overlay/241936015eaca87c5a2cb7a90714509457e45dc79fcc99fe51bfab4432a3df34/diff:/home/excalibrax/.local/share/containers/storage/overlay/638f1043cf76b82fc74b877455aac7d1670e7b1ef39c0aa6ce0646e88edef0eb/diff:/home/excalibrax/.local/share/containers/storage/overlay/17b83ac2c2f0688d6c13f8a8e5af4dacc3bd25f47ca882784ba56a0c9ca42638/diff:/home/excalibrax/.local/share/containers/storage/overlay/0d1f84c67eae42a78f9b94b43a10afef7061ee1c877db2a2bb30a8811dcc26ce/diff:/home/excalibrax/.local/share/containers/storage/overlay/e8b445a45fb8c27af4054ce0744a0ac695f3a24a52d5740143b58a0beb8d8c21/diff:/home/excalibrax/.local/share/containers/storage/overlay/52fd74d1da55b0a9eb67b3751ff66941408fd22508cc8c5628fcd6a0c7646e7a/diff:/home/excalibrax/.local/share/containers/storage/overlay/7d6b5a6e65b7314a6c2d1508482c687323b2e7142097e58f71aa6444e06725f9/diff:/home/excalibrax/.local/share/containers/storage/overlay/4ca45873b9bd2e3b8c0060358edac0139d6170093d29a947f71f1df33c30e0e0/diff:/home/excalibrax/.local/share/containers/storage/overlay/269674704a522c376d692bf8ba393a68c46b11935c84f864ea1cdb5fb1aae90f/diff:/home/excalibrax/.local/share/containers/storage/overlay/640cb860790eac555c8009aaec809be538fc2d173a5ef4ac7b85a459e0b7162e/diff:/home/excalibrax/.local/share/containers/storage/overlay/2787da9de6292ea54c34a6dca516b7358e81dae01a32f8cc63ec0f4a34f6cb70/diff:/home/excalibrax/.local/share/containers/storage/overlay/5eea01743a5f60dcac0d578b4e499e7d789b89115ae3e07080ffa0bc181ffb01/diff:/home/excalibrax/.local/share/containers/storage/overlay/6b66b15a72f2f9f1820f96ad440406a8134ed94164b0f89aecabf260502ad925/diff:/home/excalibrax/.local/share/containers/storage/overlay/74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59/diff # noqa line-length
lower_dir: /home/excalibrax/.local/share/containers/storage/overlay/ac5e4c66483774de5e5646819d717e439bbce82a4b96cd781a3fea794bb528df/diff:/home/excalibrax/.local/share/containers/storage/overlay/918a87e3b2f4ce6dcf75d94a41883eb9392d82557b4303069fa882d4998f4474/diff:/home/excalibrax/.local/share/containers/storage/overlay/241936015eaca87c5a2cb7a90714509457e45dc79fcc99fe51bfab4432a3df34/diff:/home/excalibrax/.local/share/containers/storage/overlay/638f1043cf76b82fc74b877455aac7d1670e7b1ef39c0aa6ce0646e88edef0eb/diff:/home/excalibrax/.local/share/containers/storage/overlay/17b83ac2c2f0688d6c13f8a8e5af4dacc3bd25f47ca882784ba56a0c9ca42638/diff:/home/excalibrax/.local/share/containers/storage/overlay/0d1f84c67eae42a78f9b94b43a10afef7061ee1c877db2a2bb30a8811dcc26ce/diff:/home/excalibrax/.local/share/containers/storage/overlay/e8b445a45fb8c27af4054ce0744a0ac695f3a24a52d5740143b58a0beb8d8c21/diff:/home/excalibrax/.local/share/containers/storage/overlay/52fd74d1da55b0a9eb67b3751ff66941408fd22508cc8c5628fcd6a0c7646e7a/diff:/home/excalibrax/.local/share/containers/storage/overlay/7d6b5a6e65b7314a6c2d1508482c687323b2e7142097e58f71aa6444e06725f9/diff:/home/excalibrax/.local/share/containers/storage/overlay/4ca45873b9bd2e3b8c0060358edac0139d6170093d29a947f71f1df33c30e0e0/diff:/home/excalibrax/.local/share/containers/storage/overlay/269674704a522c376d692bf8ba393a68c46b11935c84f864ea1cdb5fb1aae90f/diff:/home/excalibrax/.local/share/containers/storage/overlay/640cb860790eac555c8009aaec809be538fc2d173a5ef4ac7b85a459e0b7162e/diff:/home/excalibrax/.local/share/containers/storage/overlay/2787da9de6292ea54c34a6dca516b7358e81dae01a32f8cc63ec0f4a34f6cb70/diff:/home/excalibrax/.local/share/containers/storage/overlay/5eea01743a5f60dcac0d578b4e499e7d789b89115ae3e07080ffa0bc181ffb01/diff:/home/excalibrax/.local/share/containers/storage/overlay/6b66b15a72f2f9f1820f96ad440406a8134ed94164b0f89aecabf260502ad925/diff:/home/excalibrax/.local/share/containers/storage/overlay/74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59/diff
upper_dir: /home/excalibrax/.local/share/containers/storage/overlay/55850a1b5cc6ecd2a9b857e66961a3ab96a32aff8ea05534b30b40c0f0ec56a8/diff
work_dir: /home/excalibrax/.local/share/containers/storage/overlay/55850a1b5cc6ecd2a9b857e66961a3ab96a32aff8ea05534b30b40c0f0ec56a8/work
name: overlay
Expand Down
2 changes: 1 addition & 1 deletion .github/tests/ee_builder/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inspect:
digest: sha256:257d0d40e5db0c66b417e183a8ba2cb7cbf6e7791c6643dcbfd887b9dfa3087d
graph_driver:
data:
lower_dir: /home/excalibrax/.local/share/containers/storage/overlay/638f1043cf76b82fc74b877455aac7d1670e7b1ef39c0aa6ce0646e88edef0eb/diff:/home/excalibrax/.local/share/containers/storage/overlay/17b83ac2c2f0688d6c13f8a8e5af4dacc3bd25f47ca882784ba56a0c9ca42638/diff:/home/excalibrax/.local/share/containers/storage/overlay/0d1f84c67eae42a78f9b94b43a10afef7061ee1c877db2a2bb30a8811dcc26ce/diff:/home/excalibrax/.local/share/containers/storage/overlay/e8b445a45fb8c27af4054ce0744a0ac695f3a24a52d5740143b58a0beb8d8c21/diff:/home/excalibrax/.local/share/containers/storage/overlay/52fd74d1da55b0a9eb67b3751ff66941408fd22508cc8c5628fcd6a0c7646e7a/diff:/home/excalibrax/.local/share/containers/storage/overlay/7d6b5a6e65b7314a6c2d1508482c687323b2e7142097e58f71aa6444e06725f9/diff:/home/excalibrax/.local/share/containers/storage/overlay/4ca45873b9bd2e3b8c0060358edac0139d6170093d29a947f71f1df33c30e0e0/diff:/home/excalibrax/.local/share/containers/storage/overlay/269674704a522c376d692bf8ba393a68c46b11935c84f864ea1cdb5fb1aae90f/diff:/home/excalibrax/.local/share/containers/storage/overlay/640cb860790eac555c8009aaec809be538fc2d173a5ef4ac7b85a459e0b7162e/diff:/home/excalibrax/.local/share/containers/storage/overlay/2787da9de6292ea54c34a6dca516b7358e81dae01a32f8cc63ec0f4a34f6cb70/diff:/home/excalibrax/.local/share/containers/storage/overlay/5eea01743a5f60dcac0d578b4e499e7d789b89115ae3e07080ffa0bc181ffb01/diff:/home/excalibrax/.local/share/containers/storage/overlay/6b66b15a72f2f9f1820f96ad440406a8134ed94164b0f89aecabf260502ad925/diff:/home/excalibrax/.local/share/containers/storage/overlay/74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59/diff # noqa line-length
lower_dir: /home/excalibrax/.local/share/containers/storage/overlay/638f1043cf76b82fc74b877455aac7d1670e7b1ef39c0aa6ce0646e88edef0eb/diff:/home/excalibrax/.local/share/containers/storage/overlay/17b83ac2c2f0688d6c13f8a8e5af4dacc3bd25f47ca882784ba56a0c9ca42638/diff:/home/excalibrax/.local/share/containers/storage/overlay/0d1f84c67eae42a78f9b94b43a10afef7061ee1c877db2a2bb30a8811dcc26ce/diff:/home/excalibrax/.local/share/containers/storage/overlay/e8b445a45fb8c27af4054ce0744a0ac695f3a24a52d5740143b58a0beb8d8c21/diff:/home/excalibrax/.local/share/containers/storage/overlay/52fd74d1da55b0a9eb67b3751ff66941408fd22508cc8c5628fcd6a0c7646e7a/diff:/home/excalibrax/.local/share/containers/storage/overlay/7d6b5a6e65b7314a6c2d1508482c687323b2e7142097e58f71aa6444e06725f9/diff:/home/excalibrax/.local/share/containers/storage/overlay/4ca45873b9bd2e3b8c0060358edac0139d6170093d29a947f71f1df33c30e0e0/diff:/home/excalibrax/.local/share/containers/storage/overlay/269674704a522c376d692bf8ba393a68c46b11935c84f864ea1cdb5fb1aae90f/diff:/home/excalibrax/.local/share/containers/storage/overlay/640cb860790eac555c8009aaec809be538fc2d173a5ef4ac7b85a459e0b7162e/diff:/home/excalibrax/.local/share/containers/storage/overlay/2787da9de6292ea54c34a6dca516b7358e81dae01a32f8cc63ec0f4a34f6cb70/diff:/home/excalibrax/.local/share/containers/storage/overlay/5eea01743a5f60dcac0d578b4e499e7d789b89115ae3e07080ffa0bc181ffb01/diff:/home/excalibrax/.local/share/containers/storage/overlay/6b66b15a72f2f9f1820f96ad440406a8134ed94164b0f89aecabf260502ad925/diff:/home/excalibrax/.local/share/containers/storage/overlay/74ddd0ec08fa43d09f32636ba91a0a3053b02cb4627c35051aff89f853606b59/diff
upper_dir: /home/excalibrax/.local/share/containers/storage/overlay/241936015eaca87c5a2cb7a90714509457e45dc79fcc99fe51bfab4432a3df34/diff
work_dir: /home/excalibrax/.local/share/containers/storage/overlay/241936015eaca87c5a2cb7a90714509457e45dc79fcc99fe51bfab4432a3df34/work
name: overlay
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# This workflow action will run pre-commit, which will execute ansible and yaml linting
# See .github/workflow-config/.pre-commit-config.yml for what hooks are executed
# See .pre-commit-config.yml for what hooks are executed
name: Yaml and Ansible Lint

on: [push, pull_request] # yamllint disable-line rule:truthy
Expand All @@ -14,7 +14,6 @@ jobs:
- name: Install Collections
run: |
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
pip install --upgrade ansible
- uses: pre-commit/action@v2.0.0
...
4 changes: 4 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ MD013: false
# This will ensure that code block format is consistent across all markdown files
MD0046:
style: fenced

MD033:
allowed_elements:
- "br"
...
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/ansible-community/ansible-lint.git
rev: v6.3.0
rev: v6.6.1
hooks:
# see discussions here about what arguments are used, and behavior
# https://github.com/ansible/ansible-lint/issues/649
Expand All @@ -16,8 +16,10 @@ repos:
pass_filenames: false
always_run: true
entry: "ansible-lint"
args:
- "--profile=production"
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.4.0
rev: v0.5.1
hooks:
- id: markdownlint-cli2
...
7 changes: 6 additions & 1 deletion .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
extends: default

ignore: |
changelogs
rules:
# 80 chars should be enough, but don't fail if a line is longer
line-length: disable
Expand All @@ -10,9 +13,11 @@ rules:
document-end: {present: true}
indentation:
level: error
indent-sequences: true # to be consistent with ansible-lint
# Require indentation https://redhat-cop.github.io/automation-good-practices/#_yaml_and_jinja2_syntax
indent-sequences: true
truthy:
level: error
# Allow only YAML 1.2 booleans https://redhat-cop.github.io/automation-good-practices/#_yaml_and_jinja2_syntax
allowed-values:
- 'true'
- 'false'
Expand Down
12 changes: 6 additions & 6 deletions examples/ee_venv_migrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
- name: redhat_cop.ah_configuration
tasks:
- name: Include venv_migrate role
include_role:
ansible.builtin.include_role:
name: redhat_cop.ee_utilities.virtualenv_migrate

- name: ee_list
- name: Display ee_list
ansible.builtin.debug:
var: ee_list

Expand All @@ -29,11 +29,11 @@
tasks:

- name: Create EE
include_role:
ansible.builtin.include_role:
name: redhat_cop.ee_utilities.ee_builder

- name: Export python virtual enviroment list to file
copy:
content: "{{ ee_list | to_nice_yaml( width=50, explicit_start=True, explicit_end=True) }}"
- name: Export python virtual enviroment list to file # noqa template-instead-of-copy
ansible.builtin.copy:
content: "{{ ee_list | to_nice_yaml(width=50, explicit_start=True, explicit_end=True) }}"
dest: venv_migrate_ee_python.yaml
...
2 changes: 1 addition & 1 deletion roles/ee_builder/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ galaxy_cli_opts: '-v'
ee_stream: "{% if ee_base_registry_username is defined %}downstream{% else %}upstream{% endif %}"

# Image defaults
ee_base_image: "{{ __execution_environment_definition.base_image | default( __ee_stream_images[ee_stream].base_image ) }}"
ee_base_image: "{{ __execution_environment_definition.base_image | default(__ee_stream_images[ee_stream].base_image) }}"
ee_builder_image: "{{ __ee_stream_images[ee_stream].builder_image }}"
ee_registry_username: "{{ ee_base_registry_username | default(omit, true) }}"
ee_registry_password: "{{ ee_base_registry_password | default(omit, true) }}"
Expand Down
4 changes: 2 additions & 2 deletions roles/ee_builder/tasks/00_build_ee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- "{{ ee_builder_image }}"
when: ee_update_base_images

- name: ensure bindep file is rendered
- name: Ensure bindep file is rendered
ansible.builtin.template:
src: bindep.j2
dest: "{{ builder_dir }}/{{ bindep_file }}"
Expand Down Expand Up @@ -85,6 +85,6 @@
- name: Empty build directory
ansible.builtin.file:
state: absent
path: "{{ build_dir.path | default( builder_dir ) }}"
path: "{{ build_dir.path | default(builder_dir) }}"
when: ee_builder_dir_clean
...
10 changes: 5 additions & 5 deletions roles/virtualenv_migrate/tasks/00_gather_custom_requirements.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
- name: gather | Get the list of custom virtualenvs
- name: Gather | Get the list of custom virtualenvs
ansible.builtin.command: awx-manage list_custom_venvs
register: __venv_migrate_custom_venvs
changed_when: false # only gathering information

- name: gather | Record all virtualenvs from AAP1.2 tower node
- name: Gather | Record all virtualenvs from AAP1.2 tower node
ansible.builtin.set_fact:
__venv_migrate_virtualenvs: "{{ __venv_migrate_custom_venvs.stdout | regex_findall('\\n?(/.*/)\\n\\n?') }}"
failed_when: __venv_migrate_custom_venvs.rc != 0

- name: gather | Exit the play if there are no custom virtualenvironments on AAP1.2 tower node or the awx-manage command errors.
- name: Gather | Exit the play if there are no custom virtualenvironments on AAP1.2 tower node or the awx-manage command errors.
ansible.builtin.meta: end_play
when: (__venv_migrate_virtualenvs | length == 1 and not venv_migrate_show_diff_with_default) or (__venv_migrate_custom_venvs.rc != 0)

Expand All @@ -32,11 +32,11 @@
__venv_migrate_freeze_results: "{{ __venv_migrate_freeze_results_default }}"
when: not __venv_migrate_freeze_results_default.skipped | bool

- name: gather | Combining all custom venv requirements in a variable without the versions
- name: Gather | Combining all custom venv requirements in a variable without the versions
ansible.builtin.set_fact:
__venv_migrate_combined_requirements: "{{ __venv_migrate_freeze_results.results | map('regex_replace', '(\\w+)==[\\d+\\.]+', '\\1') }}"

- name: gather | Convert string to yaml dict
- name: Gather | Convert string to yaml dict
ansible.builtin.set_fact:
__venv_migrate_combined_requirements_ser: "{{ __venv_migrate_combined_requirements_ser | d([]) + [item | from_yaml] }}"
loop: "{{ __venv_migrate_combined_requirements }}"
Expand Down
12 changes: 6 additions & 6 deletions roles/virtualenv_migrate/tasks/01_ee_diff.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
---
- name: Diff with EE requirements
block:
- name: diff | Download the default EE on localhost
- name: Diff | Download the default EE on localhost
containers.podman.podman_image:
name: "{{ venv_migrate_default_ee_url }}"
username: "{{ venv_migrate_registry_username }}"
password: "{{ venv_migrate_registry_password }}"

- name: diff | Get pip list from Default EE
- name: Diff | Get pip list from Default EE
ansible.builtin.command: "podman run --rm -it {{ venv_migrate_default_ee_url }} bash -c \"/bin/pip3 freeze\""
register: __venv_migrate_ee_pip_list_output
changed_when: false

- name: diff | Retain the EE pip list without package versions
- name: Diff | Retain the EE pip list without package versions
ansible.builtin.set_fact:
__venv_migrate_ee_pip_list: "{{ __venv_migrate_ee_pip_list_output.stdout.split('\n') | map('regex_replace', '(\\w+)==([\\d+\\.]+).*', '\\1') | list }}"

- name: diff | Check what's extra in venv and create a requirement list for the new EE and set to ee_python variable
- name: Diff | Check what's extra in venv and create a requirement list for the new EE and set to ee_python variable
ansible.builtin.set_fact:
venv_migrate_ee_python_list: "{{ venv_migrate_ee_python_list | d([]) + [{ item.item:( item.stdout_lines | difference( __venv_migrate_ee_pip_list ))}] }}" # noqa var-spacing
venv_migrate_ee_python_list: "{{ venv_migrate_ee_python_list | d([]) + [{item.item: (item.stdout_lines | difference(__venv_migrate_ee_pip_list))}] }}"
loop: "{{ __venv_migrate_combined_requirements_ser }}"
no_log: true

- name: diff | Show the packages that are extra from default EEs in custom venvs.
- name: Diff | Show the packages that are extra from default EEs in custom venvs.
ansible.builtin.debug:
msg: "{{ venv_migrate_ee_python_list }}"
delegate_to: localhost
Expand Down
Loading

0 comments on commit 4b05e4b

Please sign in to comment.