diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 00000000..cad3b8e1 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,11 @@ +profile: production + +exclude_paths: + # This file is autogenerated so we cannot change the format + - changelogs/changelog.yaml + # Incorrect error around supported ansible versions in this file + - meta/runtime.yml + - tests/integration/ + # We skip a rule that has to be skipped + - tests/sanity/ignore-*.txt + - tests/unit/ diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 90a02151..cbaafaa7 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -54,6 +54,8 @@ stages: test: sanity - name: Units test: units + - name: Lint + test: lint - stage: Ansible_2_16 displayName: Ansible 2.16 dependsOn: [] diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index 3b89bc6a..cc0320a9 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -2,7 +2,7 @@ name: Collection Docs concurrency: group: docs-pr-${{ github.head_ref }} cancel-in-progress: true -on: +"on": pull_request_target: types: [opened, synchronize, reopened, closed] @@ -44,7 +44,7 @@ jobs: - name: PR comment uses: ansible-community/github-docs-build/actions/ansible-docs-build-comment@main with: - body-includes: '## Docs Build' + body-includes: "## Docs Build" reactions: heart action: ${{ needs.build-docs.outputs.changed != 'true' && 'remove' || '' }} on-closed-action: remove diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 2cc74fb4..c1ea9810 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -2,14 +2,14 @@ name: Collection Docs concurrency: group: docs-push-${{ github.sha }} cancel-in-progress: true -on: +"on": push: branches: - main tags: - - '*' + - "*" schedule: - - cron: '0 13 * * *' + - cron: "0 13 * * *" jobs: build-docs: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index aef40d7f..ae371941 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,7 +1,7 @@ name: Stale pull request handler -on: +"on": schedule: - - cron: 0 0 * * * + - cron: 0 0 * * * permissions: pull-requests: write @@ -11,13 +11,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/stale@v4.0.0 - id: stale - with: - days-before-stale: -1 - days-before-pr-stale: 28 - days-before-pr-close: 14 - stale-pr-label: stale - stale-pr-message: >- - This pull request is stale because it has been open for 4 weeks with no activity. - Remove stale label or comment or this will be closed in 2 weeks. + - uses: actions/stale@v4.0.0 + id: stale + with: + days-before-stale: -1 + days-before-pr-stale: 28 + days-before-pr-close: 14 + stale-pr-label: stale + stale-pr-message: >- + This pull request is stale because it has been open for 4 weeks with no activity. + Remove stale label or comment or this will be closed in 2 weeks. diff --git a/changelogs/config.yaml b/changelogs/config.yaml index d0889037..a14a5c4d 100644 --- a/changelogs/config.yaml +++ b/changelogs/config.yaml @@ -9,21 +9,21 @@ notesdir: fragments prelude_section_name: release_summary prelude_section_title: Release Summary sections: -- - major_changes - - Major Changes -- - minor_changes - - Minor Changes -- - breaking_changes - - Breaking Changes / Porting Guide -- - deprecated_features - - Deprecated Features -- - removed_features - - Removed Features (previously deprecated) -- - security_fixes - - Security Fixes -- - bugfixes - - Bugfixes -- - known_issues - - Known Issues + - - major_changes + - Major Changes + - - minor_changes + - Minor Changes + - - breaking_changes + - Breaking Changes / Porting Guide + - - deprecated_features + - Deprecated Features + - - removed_features + - Removed Features (previously deprecated) + - - security_fixes + - Security Fixes + - - bugfixes + - Bugfixes + - - known_issues + - Known Issues title: Ansible Windows trivial_section_name: trivial diff --git a/changelogs/fragments/win_get_url-tls13.yml b/changelogs/fragments/win_get_url-tls13.yml index 1dba9d83..d2cb4b1f 100644 --- a/changelogs/fragments/win_get_url-tls13.yml +++ b/changelogs/fragments/win_get_url-tls13.yml @@ -1,2 +1,2 @@ bugfixes: -- win_get_url - Fix Tls1.3 getting removed from the list of security protocols \ No newline at end of file + - win_get_url - Fix Tls1.3 getting removed from the list of security protocols diff --git a/changelogs/fragments/win_powershell-fix-using.yml b/changelogs/fragments/win_powershell-fix-using.yml index 52e1212d..036f52b2 100644 --- a/changelogs/fragments/win_powershell-fix-using.yml +++ b/changelogs/fragments/win_powershell-fix-using.yml @@ -1,2 +1,2 @@ bugfixes: -- win_powershell - Remove unecessary using in code causing stray error records in output - https://github.com/ansible-collections/ansible.windows/issues/571 + - win_powershell - Remove unecessary using in code causing stray error records in output - https://github.com/ansible-collections/ansible.windows/issues/571 diff --git a/galaxy.yml b/galaxy.yml index 5ce3ebdf..805743cb 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -3,19 +3,19 @@ name: windows version: 2.2.0 readme: README.md authors: -- Jordan Borean @jborean93 -- Matt Davis @nitzmahone + - Jordan Borean @jborean93 + - Matt Davis @nitzmahone description: | Ansible collection for core Windows plugins. license_file: COPYING tags: -- windows + - windows dependencies: {} repository: https://github.com/ansible-collections/ansible.windows documentation: https://docs.ansible.com/ansible/devel/collections/ansible/windows homepage: https://github.com/ansible-collections/ansible.windows issues: https://github.com/ansible-collections/ansible.windows/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc build_ignore: -- .vscode -- tests/integration/inventory* -- changelogs/.plugin-cache.yaml + - .vscode + - tests/integration/inventory* + - changelogs/.plugin-cache.yaml diff --git a/meta/runtime.yml b/meta/runtime.yml index 090bfcfb..ff9bf3e7 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,4 +1,4 @@ -requires_ansible: '>=2.14' +requires_ansible: ">=2.14" plugin_routing: modules: win_domain_controller: diff --git a/plugins/filter/quote.yml b/plugins/filter/quote.yml index 304322b1..3484f42e 100644 --- a/plugins/filter/quote.yml +++ b/plugins/filter/quote.yml @@ -4,34 +4,34 @@ DOCUMENTATION: name: quote author: - - Jordan Borean (@jborean93) + - Jordan Borean (@jborean93) short_description: Quotes argument(s) for various Windows shells seealso: - - module: ansible.windows.win_command - - module: ansible.windows.win_shell + - module: ansible.windows.win_command + - module: ansible.windows.win_shell description: - - Quotes argument(s) for the various Windows command line shells. - - Defaults to escaping arguments based on the Win32 C argv parsing rules that M(ansible.windows.win_command) uses. - - Using I(shell='cmd') or I(shell='powershell') can be set to escape arguments for those respective shells. - - Each value is escaped in a way to ensure the process gets the literal argument passed in and meta chars escaped. + - Quotes argument(s) for the various Windows command line shells. + - Defaults to escaping arguments based on the Win32 C argv parsing rules that M(ansible.windows.win_command) uses. + - Using I(shell='cmd') or I(shell='powershell') can be set to escape arguments for those respective shells. + - Each value is escaped in a way to ensure the process gets the literal argument passed in and meta chars escaped. positional: _input options: _input: description: - - The string, list, or dict of values to quote. - - A string or list of strings will be quoted. - - When using a dict as the input, the final form will be in C(KEY="value") to match the MSI parameter format. + - The string, list, or dict of values to quote. + - A string or list of strings will be quoted. + - When using a dict as the input, the final form will be in C(KEY="value") to match the MSI parameter format. type: raw required: true shell: description: - - The shell to quote the arguments for. - - By default no shell is used and the arguments are quoted with the Win32 C quoting rules. + - The shell to quote the arguments for. + - By default no shell is used and the arguments are quoted with the Win32 C quoting rules. type: string choices: - - None - - cmd - - powershell + - None + - cmd + - powershell default: None EXAMPLES: | @@ -47,5 +47,5 @@ EXAMPLES: | RETURN: _value: description: - - The quoted input value(s) as a single space delimited string. - type: string \ No newline at end of file + - The quoted input value(s) as a single space delimited string. + type: string diff --git a/plugins/modules/async_status.yml b/plugins/modules/async_status.yml index d268e6e9..34b90bfe 100644 --- a/plugins/modules/async_status.yml +++ b/plugins/modules/async_status.yml @@ -4,25 +4,25 @@ DOCUMENTATION: module: async_status short_description: Obtain status of asynchronous task - seealso: - - module: ansible.builtin.async_status + seealso: + - module: ansible.builtin.async_status description: - - This module gets the status of an asynchronous task. + - This module gets the status of an asynchronous task. options: jid: description: - - Job or task identifier + - Job or task identifier type: str required: true mode: description: - - If C(status), obtain the status. - - If C(cleanup), clean up the async job cache (by default in C(~/.ansible_async/)) for the specified job I(jid). + - If C(status), obtain the status. + - If C(cleanup), clean up the async job cache (by default in C(~/.ansible_async/)) for the specified job I(jid). type: str - choices: [ cleanup, status ] + choices: [cleanup, status] default: status author: - - Ansible Core Team + - Ansible Core Team EXAMPLES: | - name: Asynchronous yum task @@ -44,7 +44,7 @@ RETURN: description: The asynchronous job id returned: success type: str - sample: '360874038559.4169' + sample: "360874038559.4169" finished: description: Whether the asynchronous job has finished (C(1)) or not (C(0)) returned: always diff --git a/plugins/modules/setup.yml b/plugins/modules/setup.yml index 5efbea07..54b59c8c 100644 --- a/plugins/modules/setup.yml +++ b/plugins/modules/setup.yml @@ -5,52 +5,52 @@ DOCUMENTATION: module: setup short_description: Gathers facts about remote hosts seealso: - - module: ansible.builtin.setup + - module: ansible.builtin.setup options: gather_subset: description: - - If supplied, restrict the additional facts collected to the given subset. - - Can specify a list of values to specify a larger subset. - - Values can also be used with an initial C(!) to specify that that specific subset should not be collected. - - To avoid collecting even the min subset, specify C(!all,!min). - - To collect only specific facts, use C(!all,!min), and specify the particular fact subsets. + - If supplied, restrict the additional facts collected to the given subset. + - Can specify a list of values to specify a larger subset. + - Values can also be used with an initial C(!) to specify that that specific subset should not be collected. + - To avoid collecting even the min subset, specify C(!all,!min). + - To collect only specific facts, use C(!all,!min), and specify the particular fact subsets. type: list elements: str default: all gather_timeout: description: - - Set the default timeout in seconds for individual fact gathering. + - Set the default timeout in seconds for individual fact gathering. type: int default: 10 fact_path: description: - - Path used for local ansible facts (C(*.ps1) or C(*.json)) - files in this dir - will be run (if a ps1) or read (if a json) and their results be added to the return facts. - - The returned fact will be named after the local file (without the extension suffix), e.g. C(ansible_my_fact). + - Path used for local ansible facts (C(*.ps1) or C(*.json)) - files in this dir + will be run (if a ps1) or read (if a json) and their results be added to the return facts. + - The returned fact will be named after the local file (without the extension suffix), e.g. C(ansible_my_fact). type: path _measure_subset: description: - - For internal use + - For internal use type: bool - default: False + default: false description: - - This module is automatically called by playbooks to gather useful - variables about remote hosts that can be used in playbooks. It can also be - executed directly by C(/usr/bin/ansible) to check what variables are - available to a host. Ansible provides many I(facts) about the system, - automatically. + - This module is automatically called by playbooks to gather useful + variables about remote hosts that can be used in playbooks. It can also be + executed directly by C(/usr/bin/ansible) to check what variables are + available to a host. Ansible provides many I(facts) about the system, + automatically. notes: - - More ansible facts will be added with successive releases. If I(facter) is - installed, variables from these programs will also be snapshotted - into the JSON file for usage in templating. These variables are prefixed - with C(facter_) so it's easy to tell their source. All variables are - bubbled up to the caller. - - Some facts may be unavailable if running under a limited account. - - For more information about delegated facts, - please check U(https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html#delegating-facts). + - More ansible facts will be added with successive releases. If I(facter) is + installed, variables from these programs will also be snapshotted + into the JSON file for usage in templating. These variables are prefixed + with C(facter_) so it's easy to tell their source. All variables are + bubbled up to the caller. + - Some facts may be unavailable if running under a limited account. + - For more information about delegated facts, + please check U(https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html#delegating-facts). author: - - Ansible Core Team + - Ansible Core Team EXAMPLES: | - name: run the setup facts - ansible.builtin.setup: \ No newline at end of file + ansible.builtin.setup: diff --git a/plugins/modules/slurp.yml b/plugins/modules/slurp.yml index aa418240..a6aaa355 100644 --- a/plugins/modules/slurp.yml +++ b/plugins/modules/slurp.yml @@ -5,23 +5,23 @@ DOCUMENTATION: module: slurp short_description: Slurps a file from remote nodes description: - - This module works like M(ansible.builtin.fetch). It is used for fetching a base64- - encoded blob containing the data in a remote file. + - This module works like M(ansible.builtin.fetch). It is used for fetching a base64- + encoded blob containing the data in a remote file. options: src: description: - - The file on the remote system to fetch. This I(must) be a file, not a directory. + - The file on the remote system to fetch. This I(must) be a file, not a directory. type: path required: true - aliases: [ path ] + aliases: [path] notes: - - This module returns an 'in memory' base64 encoded version of the file, take - into account that this will require at least twice the RAM as the original file size. + - This module returns an 'in memory' base64 encoded version of the file, take + into account that this will require at least twice the RAM as the original file size. seealso: - - module: ansible.builtin.fetch - - module: ansible.builtin.slurp + - module: ansible.builtin.fetch + - module: ansible.builtin.slurp author: - - Ansible Core Team + - Ansible Core Team EXAMPLES: | - name: Retrieve remote ini file on a Windows host @@ -35,17 +35,17 @@ EXAMPLES: | RETURN: content: - description: Encoded file content - returned: success - type: str - sample: "MjE3OQo=" + description: Encoded file content + returned: success + type: str + sample: "MjE3OQo=" encoding: - description: Type of encoding used for file - returned: success - type: str - sample: "base64" + description: Type of encoding used for file + returned: success + type: str + sample: "base64" source: - description: Actual path of file slurped - returned: success - type: str - sample: C:\Program Files\Program\program.ini \ No newline at end of file + description: Actual path of file slurped + returned: success + type: str + sample: C:\Program Files\Program\program.ini diff --git a/tests/utils/shippable/lint.sh b/tests/utils/shippable/lint.sh new file mode 100755 index 00000000..12b5b4cd --- /dev/null +++ b/tests/utils/shippable/lint.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -o pipefail -eux + +# This is aligned with the galaxy-importer used by AH +# https://github.com/ansible/galaxy-importer/blob/d4b5e6d12088ba452f129f4824bd049be5543358/setup.cfg#L22C4-L22C33 +python -m pip install \ + 'ansible-lint>=6.2.2,<=6.14.3' + +ansible-lint