From 2d3659ec949072e44421c44e4eda91159bc5b18c Mon Sep 17 00:00:00 2001 From: Brant Evans Date: Fri, 30 Sep 2022 15:35:30 -0700 Subject: [PATCH] Align linting configurations with other repos --- .ansible-lint | 13 +- .pre-commit-config.yaml | 3 + .yamllint.yml | 11 +- ...controller_credential_types_cloudforms.yml | 6 +- .../controller_job_templates_demo_push.yml | 2 +- .../configs_export_model/projects_export.yml | 136 +++++++++--------- .../configs/credential_input_sources.yml | 14 +- .../tests/configs/credential_types.yml | 44 +++--- .../credentials/tests/configs/credentials.yml | 14 +- .../tests/configs/execution_environments.yml | 8 +- roles/groups/tests/configs/group.yml | 8 +- roles/hosts/tests/configs/host.yml | 8 +- .../tests/configs/notifications.yml | 24 ++-- roles/object_diff/defaults/main.yml | 2 +- roles/object_diff/tests/drop_diff.yml | 3 +- roles/object_diff/tests/object_diff.yml | 3 +- .../tests/configs/organizations.yml | 4 +- roles/roles/tests/configs/roles.yml | 12 +- roles/schedules/tests/configs/schedules.yml | 8 +- roles/users/tests/configs/users.yml | 6 +- .../tasks/add_workflows_schema.yml | 6 +- 21 files changed, 173 insertions(+), 162 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index fc410f754..97863bd45 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -14,7 +14,14 @@ use_default_rules: true # with verbosity set to 1, its dumping 'unknown file type messages' # verbosity: 1 skip_list: [] -# With the move of the .yamllint.yml to TLD ansible-lint now picks up our config so no need to exclude it. -# YAML: Ansible lint doing yaml checks that we were already doing but without config. -# - yaml +kinds: + - playbooks: "**/examples/templates/*.{yml,yaml}" + - playbooks: "**/examples/*.{yml,yaml}" + - playbooks: "**/examples/automatetheautomation/*.{yml,yaml}" + - tasks: "**/examples/tasks/*.yml" + - vars: "**/examples/automatetheautomation/orgs_vars/**/*.yml" + - vars: "**/examples/configs/*.yml" + - vars: "**/examples/configs_export_model/*.yml" + - vars: "**/examples/vars/*.yml" + - vars: "**/roles/**/tests/configs/*.yml" ... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 519906886..dd9d20d83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,9 @@ repos: entry: "ansible-lint" args: - "--profile=production" + additional_dependencies: + - "ansible-core>=2.13" + - "yamllint>=1.26,<2.0" - repo: https://github.com/DavidAnson/markdownlint-cli2 rev: v0.5.1 hooks: diff --git a/.yamllint.yml b/.yamllint.yml index 0678c5f32..ffd9642d9 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -13,13 +13,12 @@ rules: document-end: {present: true} indentation: level: error - indent-sequences: consistent + # 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' - - 'on' + - 'true' + - 'false' ... diff --git a/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_credential_types.d/app-example/controller_credential_types_cloudforms.yml b/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_credential_types.d/app-example/controller_credential_types_cloudforms.yml index 68479d147..eeda7623b 100644 --- a/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_credential_types.d/app-example/controller_credential_types_cloudforms.yml +++ b/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_credential_types.d/app-example/controller_credential_types_cloudforms.yml @@ -28,8 +28,8 @@ controller_credential_types: - host injectors: env: - CLOUDFORMS_URL: !unsafe '{{ host }}' - CLOUDFORMS_USERNAME: !unsafe '{{ username }}' - CLOUDFORMS_PASSWORD: !unsafe '{{ password }}' + CLOUDFORMS_URL: !unsafe '{{ host }}' + CLOUDFORMS_USERNAME: !unsafe '{{ username }}' + CLOUDFORMS_PASSWORD: !unsafe '{{ password }}' CLOUDFORMS_SSL_VERIFY: !unsafe '{{ ssl_verify }}' ... diff --git a/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_job_templates.d/app-example/controller_job_templates_demo_push.yml b/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_job_templates.d/app-example/controller_job_templates_demo_push.yml index ae708e462..42675006c 100644 --- a/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_job_templates.d/app-example/controller_job_templates_demo_push.yml +++ b/examples/automatetheautomation/orgs_vars/OrgExample/env/common/controller_job_templates.d/app-example/controller_job_templates_demo_push.yml @@ -27,7 +27,7 @@ controller_templates: execution_environment: "Default execution environment" instance_groups: - Container_Groups_Instance - survey_enabled: True + survey_enabled: true survey_spec: name: 'TEST' description: 'Test' diff --git a/examples/configs_export_model/projects_export.yml b/examples/configs_export_model/projects_export.yml index 8785c0187..288df6ec8 100644 --- a/examples/configs_export_model/projects_export.yml +++ b/examples/configs_export_model/projects_export.yml @@ -1,80 +1,80 @@ --- controller_projects: -- name: Tower Config Testing - description: '' - local_path: _48__controller_config_testing - scm_type: git - scm_url: https://github.com/ansible/tower-example.git - scm_branch: master - scm_refspec: '' - scm_clean: false - scm_delete_on_update: false - timeout: 0 - scm_update_on_launch: false - scm_update_cache_timeout: 0 - allow_override: false - credential: - credential_type: - kind: scm - name: Source Control - type: credential_type - name: AWX-Collection-tests-controller_workflow_job_template-scm-cred - organization: - name: Default - type: organization - type: credential - custom_virtualenv: - organization: - name: Satellite - type: organization - related: - schedules: [] - notification_templates_started: [] - notification_templates_success: [] - notification_templates_error: - - organization: - name: Satellite + - name: Tower Config Testing + description: '' + local_path: _48__controller_config_testing + scm_type: git + scm_url: https://github.com/ansible/tower-example.git + scm_branch: master + scm_refspec: '' + scm_clean: false + scm_delete_on_update: false + timeout: 0 + scm_update_on_launch: false + scm_update_cache_timeout: 0 + allow_override: false + credential: + credential_type: + kind: scm + name: Source Control + type: credential_type + name: AWX-Collection-tests-controller_workflow_job_template-scm-cred + organization: + name: Default type: organization - name: irc-satqe-chat-notification - type: notification_template - natural_key: + type: credential + custom_virtualenv: organization: name: Satellite type: organization - name: Tower Config Testing - type: project -- name: Tower Config - description: '' - local_path: _52__controller_config - scm_type: git - scm_url: https://github.com/ansible/tower-example.git - scm_branch: master - scm_refspec: '' - scm_clean: false - scm_delete_on_update: false - timeout: 0 - wait: true - scm_update_on_launch: false - scm_update_cache_timeout: 0 - allow_override: false - custom_virtualenv: - organization: - name: Satellite - type: organization - related: - schedules: [] - notification_templates_started: [] - notification_templates_success: [] - notification_templates_error: - - organization: + related: + schedules: [] + notification_templates_started: [] + notification_templates_success: [] + notification_templates_error: + - organization: + name: Satellite + type: organization + name: irc-satqe-chat-notification + type: notification_template + natural_key: + organization: name: Satellite type: organization - name: irc-satqe-chat-notification - type: notification_template - natural_key: + name: Tower Config Testing + type: project + - name: Tower Config + description: '' + local_path: _52__controller_config + scm_type: git + scm_url: https://github.com/ansible/tower-example.git + scm_branch: master + scm_refspec: '' + scm_clean: false + scm_delete_on_update: false + timeout: 0 + wait: true + scm_update_on_launch: false + scm_update_cache_timeout: 0 + allow_override: false + custom_virtualenv: organization: name: Satellite type: organization - name: Tower Config - type: project + related: + schedules: [] + notification_templates_started: [] + notification_templates_success: [] + notification_templates_error: + - organization: + name: Satellite + type: organization + name: irc-satqe-chat-notification + type: notification_template + natural_key: + organization: + name: Satellite + type: organization + name: Tower Config + type: project ... diff --git a/roles/credential_input_sources/tests/configs/credential_input_sources.yml b/roles/credential_input_sources/tests/configs/credential_input_sources.yml index b65ec9b44..2c5178297 100644 --- a/roles/credential_input_sources/tests/configs/credential_input_sources.yml +++ b/roles/credential_input_sources/tests/configs/credential_input_sources.yml @@ -1,10 +1,10 @@ --- controller_credential_input_sources: -- source_credential: cyberark - target_credential: gitlab - input_field_name: password - metadata: - object_query: Safe=MY_SAFE;Object=AWX-user - object_query_format: Exact - description: Fill the gitlab credential from CyberArk + - source_credential: cyberark + target_credential: gitlab + input_field_name: password + metadata: + object_query: Safe=MY_SAFE;Object=AWX-user + object_query_format: Exact + description: Fill the gitlab credential from CyberArk ... diff --git a/roles/credential_types/tests/configs/credential_types.yml b/roles/credential_types/tests/configs/credential_types.yml index 939470d76..0194cc82d 100644 --- a/roles/credential_types/tests/configs/credential_types.yml +++ b/roles/credential_types/tests/configs/credential_types.yml @@ -1,25 +1,25 @@ --- controller_credential_types: -- name: REST API Credential - description: REST API Credential - kind: cloud - inputs: - fields: - - type: string - id: rest_username - label: REST Username - - secret: true - type: string - id: rest_password - label: REST Password - required: - - rest_username - - rest_password - injectors: - extra_vars: - rest_password: "{ { rest_password }}" - rest_username: "{ { rest_username }}" - env: - rest_username_env: "{ { rest_username }}" - rest_password_env: "{ { rest_password }}" + - name: REST API Credential + description: REST API Credential + kind: cloud + inputs: + fields: + - type: string + id: rest_username + label: REST Username + - secret: true + type: string + id: rest_password + label: REST Password + required: + - rest_username + - rest_password + injectors: + extra_vars: + rest_password: "{ { rest_password }}" + rest_username: "{ { rest_username }}" + env: + rest_username_env: "{ { rest_username }}" + rest_password_env: "{ { rest_password }}" ... diff --git a/roles/credentials/tests/configs/credentials.yml b/roles/credentials/tests/configs/credentials.yml index 29fc833c0..29c465caf 100644 --- a/roles/credentials/tests/configs/credentials.yml +++ b/roles/credentials/tests/configs/credentials.yml @@ -1,10 +1,10 @@ --- controller_credentials: -- name: gitlab - description: Credentials for GitLab - organization: Default - credential_type: Source Control - inputs: - username: person - password: password + - name: gitlab + description: Credentials for GitLab + organization: Default + credential_type: Source Control + inputs: + username: person + password: password ... diff --git a/roles/execution_environments/tests/configs/execution_environments.yml b/roles/execution_environments/tests/configs/execution_environments.yml index f24491b14..5dedca2ce 100644 --- a/roles/execution_environments/tests/configs/execution_environments.yml +++ b/roles/execution_environments/tests/configs/execution_environments.yml @@ -1,7 +1,7 @@ --- controller_execution_environments: -- name: Tower env - organization: Default - image: quay.io/ansible/awx-ee - pull: always + - name: Tower env + organization: Default + image: quay.io/ansible/awx-ee + pull: always ... diff --git a/roles/groups/tests/configs/group.yml b/roles/groups/tests/configs/group.yml index 6527d9c03..366fa179c 100644 --- a/roles/groups/tests/configs/group.yml +++ b/roles/groups/tests/configs/group.yml @@ -1,7 +1,7 @@ --- controller_groups: -- name: localhost - inventory: My Inv - variables: - my_var: true + - name: localhost + inventory: My Inv + variables: + my_var: true ... diff --git a/roles/hosts/tests/configs/host.yml b/roles/hosts/tests/configs/host.yml index 46fab56ef..34b7aab70 100644 --- a/roles/hosts/tests/configs/host.yml +++ b/roles/hosts/tests/configs/host.yml @@ -1,7 +1,7 @@ --- controller_host: -- name: localhost - inventory: My Inv - variables: - my_var: true + - name: localhost + inventory: My Inv + variables: + my_var: true ... diff --git a/roles/notification_templates/tests/configs/notifications.yml b/roles/notification_templates/tests/configs/notifications.yml index a6db22b91..3860939b8 100644 --- a/roles/notification_templates/tests/configs/notifications.yml +++ b/roles/notification_templates/tests/configs/notifications.yml @@ -1,15 +1,15 @@ --- controller_notification_templates: -- name: Email notification - description: Send out emails for Controller jobs - organization: Default - notification_type: email - notification_configuration: - host: smtp.example.com - recipients: - - admin@example.com - sender: tower0@example.com - port: '25' - username: '' - password: '' + - name: Email notification + description: Send out emails for Controller jobs + organization: Default + notification_type: email + notification_configuration: + host: smtp.example.com + recipients: + - admin@example.com + sender: tower0@example.com + port: '25' + username: '' + password: '' ... diff --git a/roles/object_diff/defaults/main.yml b/roles/object_diff/defaults/main.yml index b93d996c0..3e261bd89 100644 --- a/roles/object_diff/defaults/main.yml +++ b/roles/object_diff/defaults/main.yml @@ -8,7 +8,7 @@ controller_hostname: "{{ vault_controller_hostname | default(lookup('env', 'CONT controller_validate_certs: "{{ vault_controller_validate_certs | default(lookup('env', 'CONTROLLER_VERIFY_SSL')) }}" # populate_controller_api_user_accounts_without_external_accounts -drop_user_external_accounts: True +drop_user_external_accounts: true # Automation Controller Object Lists controller_settings: [] diff --git a/roles/object_diff/tests/drop_diff.yml b/roles/object_diff/tests/drop_diff.yml index 7985abd61..5cbf95887 100644 --- a/roles/object_diff/tests/drop_diff.yml +++ b/roles/object_diff/tests/drop_diff.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Test playbook + hosts: localhost connection: local gather_facts: false roles: diff --git a/roles/object_diff/tests/object_diff.yml b/roles/object_diff/tests/object_diff.yml index 773351183..6532a987c 100644 --- a/roles/object_diff/tests/object_diff.yml +++ b/roles/object_diff/tests/object_diff.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Object diff playbook + hosts: localhost connection: local gather_facts: false roles: diff --git a/roles/organizations/tests/configs/organizations.yml b/roles/organizations/tests/configs/organizations.yml index 32086cd19..99a348df3 100644 --- a/roles/organizations/tests/configs/organizations.yml +++ b/roles/organizations/tests/configs/organizations.yml @@ -1,5 +1,5 @@ --- controller_organizations: -- name: Default - description: Default + - name: Default + description: Default ... diff --git a/roles/roles/tests/configs/roles.yml b/roles/roles/tests/configs/roles.yml index 1ba49355b..7582ecd84 100644 --- a/roles/roles/tests/configs/roles.yml +++ b/roles/roles/tests/configs/roles.yml @@ -1,9 +1,9 @@ --- controller_roles: -- user: admin - job_template: Demo Job Template - role: read -- inventory: Demo Inventory - user: admin - role: read + - user: admin + job_template: Demo Job Template + role: read + - inventory: Demo Inventory + user: admin + role: read ... diff --git a/roles/schedules/tests/configs/schedules.yml b/roles/schedules/tests/configs/schedules.yml index 59cdac070..f3cc60d58 100644 --- a/roles/schedules/tests/configs/schedules.yml +++ b/roles/schedules/tests/configs/schedules.yml @@ -1,7 +1,7 @@ --- controller_schedules: -- name: Demo Schedule - description: A demonstration - unified_job_template: Demo Job Template - rrule: DTSTART:20191219T130551Z RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1 + - name: Demo Schedule + description: A demonstration + unified_job_template: Demo Job Template + rrule: DTSTART:20191219T130551Z RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1 ... diff --git a/roles/users/tests/configs/users.yml b/roles/users/tests/configs/users.yml index a346790e5..58e879b86 100644 --- a/roles/users/tests/configs/users.yml +++ b/roles/users/tests/configs/users.yml @@ -1,6 +1,6 @@ --- controller_user_accounts: -- user: johnsmith - superuser: false - password: password1 + - user: johnsmith + superuser: false + password: password1 ... diff --git a/roles/workflow_job_templates/tasks/add_workflows_schema.yml b/roles/workflow_job_templates/tasks/add_workflows_schema.yml index cfade7be2..490c93c69 100644 --- a/roles/workflow_job_templates/tasks/add_workflows_schema.yml +++ b/roles/workflow_job_templates/tasks/add_workflows_schema.yml @@ -58,9 +58,9 @@ workflow_job_template_node: identifier: "{{ __workflow_loop_node_item.identifier | mandatory }}" workflow: "{{ __workflow_loop_item.name | mandatory }}" - always_nodes: "{{ __workflow_loop_node_item.always_nodes | default(__workflow_loop_node_item.related.always_nodes | default([], true) | selectattr('identifier', 'defined') | map(attribute='identifier')) | list }}" # Nodes to advance on always (blue links) # noqa 204 - success_nodes: "{{ __workflow_loop_node_item.success_nodes | default(__workflow_loop_node_item.related.success_nodes | default([], true) | selectattr('identifier', 'defined') | map(attribute='identifier')) | list }}" # Nodes to advance on success (green links) # noqa 204 - failure_nodes: "{{ __workflow_loop_node_item.failure_nodes | default(__workflow_loop_node_item.related.failure_nodes | default([], true) | selectattr('identifier', 'defined') | map(attribute='identifier')) | list }}" # Nodes to advance on failure (red links) # noqa 204 + always_nodes: "{{ __workflow_loop_node_item.always_nodes | default(__workflow_loop_node_item.related.always_nodes | default([], true) | selectattr('identifier', 'defined') | map(attribute='identifier')) | list }}" # Nodes to advance on always (blue links) + success_nodes: "{{ __workflow_loop_node_item.success_nodes | default(__workflow_loop_node_item.related.success_nodes | default([], true) | selectattr('identifier', 'defined') | map(attribute='identifier')) | list }}" # Nodes to advance on success (green links) + failure_nodes: "{{ __workflow_loop_node_item.failure_nodes | default(__workflow_loop_node_item.related.failure_nodes | default([], true) | selectattr('identifier', 'defined') | map(attribute='identifier')) | list }}" # Nodes to advance on failure (red links) state: "{{ __workflow_loop_node_item.state | default(controller_state | default('present')) }}" organization: "{{ __workflow_loop_item.organization.name | default(__workflow_loop_item.organization) }}" # Workflow job template organization controller_username: "{{ controller_username | default(omit, true) }}"