Skip to content

Commit

Permalink
Update Linting (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-m-sullivan authored Jun 26, 2024
1 parent b5d1b65 commit 89e4760
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 77 deletions.
9 changes: 3 additions & 6 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
# exclude_paths:
# - roles/master_role_example/
exclude_paths:
- '.github/'
- 'roles/master_role_example/'
- 'changelogs/'
- .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:
- meta-runtime
- var-naming[no-role-prefix]
kinds:
- playbooks: "**/examples/*.{yml,yaml}"
- tasks: "**/examples/tasks/*.yml"
- vars: "**/examples/vars/*.yml"
- vars: "**/examples/**/*.yml"
...
4 changes: 2 additions & 2 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default: true
# MD003/heading-style/header-style - Heading style
# This will ensure that the heading format is consistent across all markdown files
MD003:
style: "atx"
style: atx

# MD013/line-length - Line length
# Setting to false to match the yamllint setting
Expand All @@ -17,5 +17,5 @@ MD0046:

MD033:
allowed_elements:
- "br"
- br
...
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ repos:
- id: ansible-lint
pass_filenames: false
always_run: true
entry: "ansible-lint"
entry: ansible-lint
args:
- "--profile=production"
- --profile=production
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.13.0
hooks:
Expand Down
24 changes: 14 additions & 10 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
---
extends: default

ignore: |
changelogs

rules:
# 80 chars should be enough, but don't fail if a line is longer
line-length: disable
colons:
max-spaces-before: 0
max-spaces-after: -1
document-end: {present: true}
braces:
max-spaces-inside: 1
colons: disable
comments:
min-spaces-from-content: 1
comments-indentation: disable
indentation:
level: error
level: warning
# 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'
- "true"
- "false"
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
# Enabling yamllint check based on PR #35
document-end: enable
...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Redhat Communities of Practice Execution Environment Utilities Collection

[![pre-commit tests](https://github.com/redhat-cop/ee_utilities/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/redhat-cop/ee_utilities/actions/workflows/pre-commit.yml)
[![Run Test of EE utilities](https://github.com/redhat-cop/ee_utilities/actions/workflows/ci_testing.yaml/badge.svg)](https://github.com/redhat-cop/ee_utilities/actions/workflows/ci_testing.yaml)
[![Run Test of EE utilities](https://github.com/redhat-cop/ee_utilities/actions/workflows/ci_testing.yml/badge.svg)](https://github.com/redhat-cop/ee_utilities/actions/workflows/ci_testing.yml)
[![Galaxy Release](https://github.com/redhat-cop/ee_utilities/actions/workflows/release.yml/badge.svg)](https://github.com/redhat-cop/ee_utilities/actions/workflows/release.yml)

This ansible collection includes a number of roles which can be useful for managing Ansible Execution Environments. Using this collection, you'll be able to automate following tasks:
Expand Down
10 changes: 4 additions & 6 deletions examples/ee_builder_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
- name: Playbook to create custom EE
hosts: localhost
gather_facts: false
collections:
- infra.ee_utilities
vars:
# For controller configuration definition
ee_builder_dir_clean: false
builder_dir: "."
builder_dir: .
ee_update_base_images: false
ee_reg_credential: Automation Hub Container Registry
ee_base_image: registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel9:latest
Expand All @@ -27,9 +25,9 @@
- python-requests
- python-pyyaml
python:
- pytz # for schedule_rrule lookup plugin
- python-dateutil>=2.7.0 # schedule_rrule
- awxkit # For import and export modules
- pytz # for schedule_rrule lookup plugin
- python-dateutil>=2.7.0 # schedule_rrule
- awxkit # For import and export modules
galaxy:
collections:
- name: awx.awx
Expand Down
6 changes: 2 additions & 4 deletions examples/ee_venv_migrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
- name: Playbook to create custom EE
hosts: tower
gather_facts: false
collections:
- infra.ee_utilities
vars:
venv_migrate_default_ee_url: registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel9:latest
ee_collections:
Expand All @@ -27,13 +25,13 @@
ee_ah_token: 4ab76668c4b2622ab1dfb7cbee7e6c9b8e62c0f5
ee_list: "{{ hostvars[groups['tower'][0]]['ee_list'] }}"
tasks:

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

- name: Export python virtual enviroment list to file # noqa template-instead-of-copy
- 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
mode: "0644"
...
44 changes: 22 additions & 22 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ version: 3.1.3-devel
description: A collection of utility roles for usage with Ansible Execution Enviroments
readme: README.md
authors:
- Sean Sullivan @sean-m-sullivan
- Anshul Behl @anshulbehl
- Tom Page @Tompage1994
- David Danielsson @djdanielsson
- Sean Sullivan @sean-m-sullivan
- Anshul Behl @anshulbehl
- Tom Page @Tompage1994
- David Danielsson @djdanielsson
repository: https://github.com/redhat-cop/ee_utilities/
issues: https://github.com/redhat-cop/ee_utilities//issues
build_ignore:
- galaxy.yml.j2
- release.yml
- .github
- .markdownlint.yml
- .ansible-lint
- .yamllint.yml
- .pre-commit-config.yaml
- .gitignore
- .gitattributes
- galaxy.yml.j2
- release.yml
- .github
- .markdownlint.yml
- .ansible-lint
- .yamllint.yml
- .pre-commit-config.yaml
- .gitignore
- .gitattributes
license:
- GPL-3.0-or-later
- GPL-3.0-or-later
tags:
- execution
- enviroments
- collection
- utilities
- utils
- infrastructure
- ee_utilities
- ee_utils
- execution
- enviroments
- collection
- utilities
- utils
- infrastructure
- ee_utilities
- ee_utils
...
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
requires_ansible: '>=2.14.0'
requires_ansible: ">=2.15.0"
...
4 changes: 1 addition & 3 deletions roles/ee_builder/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
ee_container_runtime: podman
ee_version: 3


ee_stream: "{% if ee_base_registry_username is defined %}downstream{% else %}upstream{% endif %}"

# Image defaults
Expand All @@ -16,11 +15,10 @@ ansible_cfg_file: ansible.cfg

# Default EE list
ee_list: []

# Major section Options
ee_build_options: "{{ __ee_dnf_fix[ee_stream] }}"
ee_build_arg_defaults:
ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: '-vv'
ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: -vv

# Controls
ee_image_push: true
Expand Down
1 change: 0 additions & 1 deletion roles/ee_builder/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ galaxy_info:
- all

galaxy_tags: []

dependencies: []
...
20 changes: 11 additions & 9 deletions roles/ee_builder/tasks/00_build_ee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

- name: Copy files/folders to pull from for additional_build_files
ansible.builtin.copy:
src: '{{ item }}'
dest: '{{ ee_builder_dir | default(build_dir.path) }}/{{ item }}'
mode: '0655'
loop: '{{ __execution_environment_definition.build_items }}'
src: "{{ item }}"
dest: "{{ ee_builder_dir | default(build_dir.path) }}/{{ item }}"
mode: "0655"
loop: "{{ __execution_environment_definition.build_items }}"
when:
- __execution_environment_definition.build_items is defined
- __execution_environment_definition.build_items|length
Expand All @@ -30,30 +30,32 @@
ansible.builtin.template:
src: ansible.cfg.j2
dest: "{{ ee_builder_dir | default(build_dir.path) }}/ansible.cfg"
mode: '0644'
mode: "0644"
when: ee_pull_collections_from_hub

- name: Create EE definition file
ansible.builtin.template:
src: execution_environment.yml.j2
dest: "{{ ee_builder_dir | default(build_dir.path) }}/execution_environment.yml"
mode: '0644'
mode: "0644"
when: not __execution_environment_definition.skip_generation | default(false) | bool

- name: Run the Ansible Builder Program
ansible.builtin.command: >
ansible-builder build -f
execution_environment.yml
-t {{ __execution_environment_definition.name | default( __execution_environment_definition.ee_name )}}{% if __execution_environment_definition.tag is defined %}:{{ __execution_environment_definition.tag }}{% endif %} --container-runtime={{ ee_container_runtime }}
-t {{ __execution_environment_definition.name | default(__execution_environment_definition.ee_name) }}{% if __execution_environment_definition.tag is defined
%}:{{ __execution_environment_definition.tag }}{% endif %} --container-runtime={{ ee_container_runtime }}
{% if ee_prune_images %} --prune-images{% endif %}
{% if ee_galaxy_keyring is defined %} --galaxy-keyring={{ ee_galaxy_keyring }}{% endif %}
{% if ee_galaxy_ignore_signature_status_code is defined %}{% for status_code in ee_galaxy_ignore_signature_status_code %} --galaxy-ignore-signature-status-code={{ status_code }}{% endfor %}{% endif %}
{% if ee_galaxy_ignore_signature_status_code is defined %}{% for status_code in ee_galaxy_ignore_signature_status_code %} --galaxy-ignore-signature-status-code={{
status_code }}{% endfor %}{% endif %}
{% if galaxy_required_valid_signature_count is defined %} --galaxy-required-valid-signature-count={{ galaxy_required_valid_signature_count }}{% endif %}
{% if ee_container_policy is defined %} --container-policy={{ ee_container_policy }}{% endif %}
--verbosity {{ ee_verbosity | default(0) }}
args:
chdir: "{{ ee_builder_dir | default(build_dir.path) }}/"
changed_when: true # these will always run and will always report "changed" otherwise
changed_when: true # these will always run and will always report "changed" otherwise

- name: Push image to registry
containers.podman.podman_image:
Expand Down
2 changes: 1 addition & 1 deletion roles/ee_builder/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ansible.builtin.template:
src: ee_controller.yaml.j2
dest: "{{ controller_ee.path }}/ee_controller.yaml"
mode: '0644'
mode: "0644"

- name: Include templated variable
ansible.builtin.include_vars:
Expand Down
2 changes: 1 addition & 1 deletion roles/ee_builder/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ __ee_stream_images:
__ee_dnf_fix:
upstream: {}
downstream:
package_manager_path: /usr/bin/microdnf # This is set because the default images and redhat images require microdnf
package_manager_path: /usr/bin/microdnf # This is set because the default images and redhat images require microdnf
...
4 changes: 2 additions & 2 deletions roles/virtualenv_migrate/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
# defaults file for virtualenv_migrate
venv_migrate_default_venv_paths:
- "/var/lib/awx/venv/ansible/"
venv_migrate_default_ee_url: "registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel9:latest"
- /var/lib/awx/venv/ansible/
venv_migrate_default_ee_url: registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel9:latest
venv_migrate_show_diff_with_default: false
venv_migrate_registry_username: "{{ registry_username | default('') }}"
venv_migrate_registry_password: "{{ registry_password | default('') }}"
Expand Down
1 change: 0 additions & 1 deletion roles/virtualenv_migrate/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ galaxy_info:
- all

galaxy_tags: []

dependencies: []
...
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- 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
changed_when: false # only gathering information

- name: Gather | Record all virtualenvs from AAP1.2 tower node
ansible.builtin.set_fact:
Expand All @@ -20,14 +20,14 @@
- not venv_migrate_show_diff_with_default
- __venv_migrate_virtualenvs | length > 1
register: __venv_migrate_freeze_results
changed_when: false # only gathering information
changed_when: false # only gathering information

- name: Gather pip freeze output from all venvs including the default venv
ansible.builtin.command: "{{ item }}/bin/pip freeze"
loop: "{{ __venv_migrate_virtualenvs }}"
when: venv_migrate_show_diff_with_default | bool
register: __venv_migrate_freeze_results_default
changed_when: false # only gathering information
changed_when: false # only gathering information

- name: Gather results from pip_freeze based on conditions
ansible.builtin.set_fact:
Expand Down
2 changes: 1 addition & 1 deletion roles/virtualenv_migrate/tasks/01_ee_diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
password: "{{ venv_migrate_registry_password }}"

- 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\""
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

Expand Down
2 changes: 1 addition & 1 deletion roles/virtualenv_migrate/tasks/02_ee_list_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- name: Create EE temp list
ansible.builtin.set_fact:
ee_list_temp:
- name: "{{ __venv_migrate_python_item.item | regex_replace('^\/|\/$', '') | regex_replace('\/|\/', '_') }}"
- name: "{{ __venv_migrate_python_item.item | regex_replace('^/|/$', '') | regex_replace('/|/', '_') }}"
base_image: "{{ venv_migrate_default_ee_url }}"
dependencies:
galaxy:
Expand Down

0 comments on commit 89e4760

Please sign in to comment.