From 227ff61f9d94fbe54669e7e6892b481509a1907c Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 16 Jan 2018 15:08:56 -0800 Subject: [PATCH] Add module support to yamllint sanity test. (#34964) * Add module support to yamllint sanity test. * Fix duplicate keys in module RETURN docs. * Fix syntax in return_common docs fragment. * Fix duplicate keys in module EXAMPLES docs. --- .yamllint | 20 +- .../modules/cloud/amazon/_ec2_ami_find.py | 5 - .../modules/cloud/amazon/aws_api_gateway.py | 2 - .../amazon/aws_direct_connect_connection.py | 42 ++-- lib/ansible/modules/cloud/amazon/ec2.py | 4 + .../modules/cloud/amazon/ec2_win_password.py | 3 - .../cloud/amazon/iam_mfa_device_facts.py | 14 +- .../modules/cloud/amazon/iam_policy.py | 3 - lib/ansible/modules/cloud/amazon/lambda.py | 2 - .../modules/cloud/cloudstack/cs_account.py | 58 +++--- .../modules/cloud/cloudstack/cs_network.py | 5 - .../cloud/cloudstack/cs_network_acl.py | 20 +- .../cloud/cloudstack/cs_network_acl_rule.py | 70 +++---- .../modules/cloud/cloudstack/cs_region.py | 18 +- .../cloud/cloudstack/cs_resourcelimit.py | 22 +-- .../cloud/cloudstack/cs_storage_pool.py | 2 - .../modules/cloud/cloudstack/cs_user.py | 58 +++--- lib/ansible/modules/cloud/google/gce.py | 6 +- lib/ansible/modules/cloud/google/gce_eip.py | 28 +-- .../modules/cloud/google/gcpubsub_facts.py | 20 +- lib/ansible/modules/cloud/linode/linode.py | 1 - lib/ansible/modules/cloud/misc/rhevm.py | 1 - lib/ansible/modules/cloud/ovirt/ovirt_auth.py | 2 - .../modules/cloud/ovirt/ovirt_group.py | 6 +- .../modules/cloud/ovirt/ovirt_quotas.py | 8 +- .../modules/cloud/ovirt/ovirt_users.py | 6 +- .../cloud/smartos/smartos_image_facts.py | 10 +- .../spotinst/spotinst_aws_elastigroup.py | 1 - .../modules/monitoring/datadog_monitor.py | 48 ++--- lib/ansible/modules/network/aci/aci_epg.py | 2 +- .../avi/avi_gslbservice_patch_member.py | 1 - .../modules/network/cloudengine/ce_command.py | 2 - .../network/cloudengine/ce_interface_ospf.py | 2 +- .../network/cloudengine/ce_snmp_user.py | 2 +- .../network/cnos/cnos_conditional_command.py | 1 - .../modules/network/illumos/dladm_iptun.py | 16 +- .../modules/network/illumos/dladm_linkprop.py | 12 +- .../modules/network/illumos/dladm_vlan.py | 8 +- .../modules/network/illumos/ipadm_addr.py | 16 +- .../modules/network/illumos/ipadm_addrprop.py | 8 +- .../modules/network/illumos/ipadm_ifprop.py | 16 +- .../modules/network/illumos/ipadm_prop.py | 4 +- .../modules/network/nxos/nxos_vtp_password.py | 2 - .../remote_management/ucs/ucs_wwn_pool.py | 4 +- .../modules/storage/netapp/netapp_e_amg.py | 6 - .../modules/storage/zfs/zpool_facts.py | 8 +- .../modules/utilities/logic/import_tasks.py | 2 +- lib/ansible/modules/windows/win_regmerge.py | 10 +- .../module_docs_fragments/return_common.py | 2 +- test/runner/lib/sanity/yamllint.py | 47 +++-- test/sanity/yamllint/config/default.yml | 19 ++ test/sanity/yamllint/config/modules.yml | 19 ++ test/sanity/yamllint/yamllinter.py | 183 ++++++++++++++++++ 53 files changed, 533 insertions(+), 344 deletions(-) mode change 100644 => 120000 .yamllint create mode 100644 test/sanity/yamllint/config/default.yml create mode 100644 test/sanity/yamllint/config/modules.yml create mode 100755 test/sanity/yamllint/yamllinter.py diff --git a/.yamllint b/.yamllint deleted file mode 100644 index 45d8b7adcf..0000000000 --- a/.yamllint +++ /dev/null @@ -1,19 +0,0 @@ -extends: default - -rules: - braces: {max-spaces-inside: 1, level: error} - brackets: {max-spaces-inside: 1, level: error} - colons: {max-spaces-after: -1, level: error} - commas: {max-spaces-after: -1, level: error} - comments: disable - comments-indentation: disable - document-start: disable - empty-lines: {max: 3, level: error} - hyphens: {level: error} - indentation: disable - key-duplicates: enable - line-length: disable - new-line-at-end-of-file: disable - new-lines: {type: unix} - trailing-spaces: disable - truthy: disable diff --git a/.yamllint b/.yamllint new file mode 120000 index 0000000000..88453f712a --- /dev/null +++ b/.yamllint @@ -0,0 +1 @@ +test/sanity/yamllint/config/default.yml \ No newline at end of file diff --git a/lib/ansible/modules/cloud/amazon/_ec2_ami_find.py b/lib/ansible/modules/cloud/amazon/_ec2_ami_find.py index 9c7c5d8c45..1ae5f081f1 100644 --- a/lib/ansible/modules/cloud/amazon/_ec2_ami_find.py +++ b/lib/ansible/modules/cloud/amazon/_ec2_ami_find.py @@ -205,11 +205,6 @@ architecture: returned: when AMI found type: string sample: "x86_64" -architecture: - description: architecture of image - returned: when AMI found - type: string - sample: "x86_64" block_device_mapping: description: block device mapping associated with image returned: when AMI found diff --git a/lib/ansible/modules/cloud/amazon/aws_api_gateway.py b/lib/ansible/modules/cloud/amazon/aws_api_gateway.py index 880dc610bf..099d858b54 100644 --- a/lib/ansible/modules/cloud/amazon/aws_api_gateway.py +++ b/lib/ansible/modules/cloud/amazon/aws_api_gateway.py @@ -74,7 +74,6 @@ notes: EXAMPLES = ''' # Update API resources for development -tasks: - name: update API aws_api_gateway: api_id: 'abc123321cba' @@ -82,7 +81,6 @@ tasks: swagger_file: my_api.yml # update definitions and deploy API to production -tasks: - name: deploy API aws_api_gateway: api_id: 'abc123321cba' diff --git a/lib/ansible/modules/cloud/amazon/aws_direct_connect_connection.py b/lib/ansible/modules/cloud/amazon/aws_direct_connect_connection.py index 0524385d9e..2364ec7aeb 100644 --- a/lib/ansible/modules/cloud/amazon/aws_direct_connect_connection.py +++ b/lib/ansible/modules/cloud/amazon/aws_direct_connect_connection.py @@ -62,33 +62,33 @@ options: EXAMPLES = """ # create a Direct Connect connection -aws_direct_connect_connection: - name: ansible-test-connection - state: present - location: EqDC2 - link_aggregation_group: dxlag-xxxxxxxx - bandwidth: 1Gbps -register: dc +- aws_direct_connect_connection: + name: ansible-test-connection + state: present + location: EqDC2 + link_aggregation_group: dxlag-xxxxxxxx + bandwidth: 1Gbps + register: dc # disassociate the LAG from the connection -aws_direct_connect_connection: - state: present - connection_id: dc.connection.connection_id - location: EqDC2 - bandwidth: 1Gbps +- aws_direct_connect_connection: + state: present + connection_id: dc.connection.connection_id + location: EqDC2 + bandwidth: 1Gbps # replace the connection with one with more bandwidth -aws_direct_connect_connection: - state: present - name: ansible-test-connection - location: EqDC2 - bandwidth: 10Gbps - forced_update: True +- aws_direct_connect_connection: + state: present + name: ansible-test-connection + location: EqDC2 + bandwidth: 10Gbps + forced_update: True # delete the connection -aws_direct_connect_connection: - state: absent - name: ansible-test-connection +- aws_direct_connect_connection: + state: absent + name: ansible-test-connection """ RETURN = """ diff --git a/lib/ansible/modules/cloud/amazon/ec2.py b/lib/ansible/modules/cloud/amazon/ec2.py index 8417fdbd29..7628b4989b 100644 --- a/lib/ansible/modules/cloud/amazon/ec2.py +++ b/lib/ansible/modules/cloud/amazon/ec2.py @@ -596,19 +596,23 @@ EXAMPLES = ''' # # instances with tag foo +- ec2: count_tag: foo: # instances with tag foo=bar +- ec2: count_tag: foo: bar # instances with tags foo=bar & baz +- ec2: count_tag: foo: bar baz: # instances with tags foo & bar & baz=bang +- ec2: count_tag: - foo - bar diff --git a/lib/ansible/modules/cloud/amazon/ec2_win_password.py b/lib/ansible/modules/cloud/amazon/ec2_win_password.py index b1eff37e87..40657140ca 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_win_password.py +++ b/lib/ansible/modules/cloud/amazon/ec2_win_password.py @@ -64,7 +64,6 @@ notes: EXAMPLES = ''' # Example of getting a password -tasks: - name: get the Administrator password ec2_win_password: profile: my-boto-profile @@ -73,7 +72,6 @@ tasks: key_file: "~/aws-creds/my_test_key.pem" # Example of getting a password with a password protected key -tasks: - name: get the Administrator password ec2_win_password: profile: my-boto-profile @@ -83,7 +81,6 @@ tasks: key_passphrase: "secret" # Example of waiting for a password -tasks: - name: get the Administrator password ec2_win_password: profile: my-boto-profile diff --git a/lib/ansible/modules/cloud/amazon/iam_mfa_device_facts.py b/lib/ansible/modules/cloud/amazon/iam_mfa_device_facts.py index 9a1eae00eb..6e61dc51c6 100644 --- a/lib/ansible/modules/cloud/amazon/iam_mfa_device_facts.py +++ b/lib/ansible/modules/cloud/amazon/iam_mfa_device_facts.py @@ -51,15 +51,15 @@ EXAMPLES = ''' # Note: These examples do not set authentication details, see the AWS Guide for details. # List MFA devices (more details: http://docs.aws.amazon.com/IAM/latest/APIReference/API_ListMFADevices.html) -iam_mfa_device_facts: -register: mfa_devices +- iam_mfa_device_facts: + register: mfa_devices # Assume an existing role (more details: http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) -sts_assume_role: - mfa_serial_number: "{{ mfa_devices.mfa_devices[0].serial_number }}" - role_arn: "arn:aws:iam::123456789012:role/someRole" - role_session_name: "someRoleSession" -register: assumed_role +- sts_assume_role: + mfa_serial_number: "{{ mfa_devices.mfa_devices[0].serial_number }}" + role_arn: "arn:aws:iam::123456789012:role/someRole" + role_session_name: "someRoleSession" + register: assumed_role ''' try: diff --git a/lib/ansible/modules/cloud/amazon/iam_policy.py b/lib/ansible/modules/cloud/amazon/iam_policy.py index b4c1eafe16..9a79871034 100644 --- a/lib/ansible/modules/cloud/amazon/iam_policy.py +++ b/lib/ansible/modules/cloud/amazon/iam_policy.py @@ -72,7 +72,6 @@ extends_documentation_fragment: EXAMPLES = ''' # Create a policy with the name of 'Admin' to the group 'administrators' -tasks: - name: Assign a policy called Admin to the administrators group iam_policy: iam_type: group @@ -83,7 +82,6 @@ tasks: # Advanced example, create two new groups and add a READ-ONLY policy to both # groups. -task: - name: Create Two Groups, Mario and Luigi iam: iam_type: group @@ -104,7 +102,6 @@ task: with_items: "{{ new_groups.results }}" # Create a new S3 policy with prefix per user -tasks: - name: Create S3 policy from template iam_policy: iam_type: user diff --git a/lib/ansible/modules/cloud/amazon/lambda.py b/lib/ansible/modules/cloud/amazon/lambda.py index b3829dc664..aaaca80ed7 100644 --- a/lib/ansible/modules/cloud/amazon/lambda.py +++ b/lib/ansible/modules/cloud/amazon/lambda.py @@ -125,7 +125,6 @@ extends_documentation_fragment: EXAMPLES = ''' # Create Lambda functions -tasks: - name: looped creation lambda: name: '{{ item.name }}' @@ -154,7 +153,6 @@ tasks: key2: "2" # Basic Lambda function deletion -tasks: - name: Delete Lambda functions HelloWorld and ByeBye lambda: name: '{{ item }}' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_account.py b/lib/ansible/modules/cloud/cloudstack/cs_account.py index e931c942cd..ea0406c120 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_account.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_account.py @@ -104,43 +104,43 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' # create an account in domain 'CUSTOMERS' -local_action: - module: cs_account - name: customer_xy - username: customer_xy - password: S3Cur3 - last_name: Doe - first_name: John - email: john.doe@example.com - domain: CUSTOMERS +- local_action: + module: cs_account + name: customer_xy + username: customer_xy + password: S3Cur3 + last_name: Doe + first_name: John + email: john.doe@example.com + domain: CUSTOMERS # Lock an existing account in domain 'CUSTOMERS' -local_action: - module: cs_account - name: customer_xy - domain: CUSTOMERS - state: locked +- local_action: + module: cs_account + name: customer_xy + domain: CUSTOMERS + state: locked # Disable an existing account in domain 'CUSTOMERS' -local_action: - module: cs_account - name: customer_xy - domain: CUSTOMERS - state: disabled +- local_action: + module: cs_account + name: customer_xy + domain: CUSTOMERS + state: disabled # Enable an existing account in domain 'CUSTOMERS' -local_action: - module: cs_account - name: customer_xy - domain: CUSTOMERS - state: enabled +- local_action: + module: cs_account + name: customer_xy + domain: CUSTOMERS + state: enabled # Remove an account in domain 'CUSTOMERS' -local_action: - module: cs_account - name: customer_xy - domain: CUSTOMERS - state: absent +- local_action: + module: cs_account + name: customer_xy + domain: CUSTOMERS + state: absent ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network.py b/lib/ansible/modules/cloud/cloudstack/cs_network.py index a42aadf391..63d026a8e8 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network.py @@ -251,11 +251,6 @@ gateway_ipv6: returned: success type: string sample: 2001:db8::1 -state: - description: State of the network. - returned: success - type: string - sample: Implemented zone: description: Name of zone. returned: success diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py b/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py index 997f843e3a..7a48572ac4 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network_acl.py @@ -82,18 +82,18 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' # create a network ACL -local_action: - module: cs_network_acl - name: Webserver ACL - description: a more detailed description of the ACL - vpc: customers +- local_action: + module: cs_network_acl + name: Webserver ACL + description: a more detailed description of the ACL + vpc: customers # remove a network ACL -local_action: - module: cs_network_acl - name: Webserver ACL - vpc: customers - state: absent +- local_action: + module: cs_network_acl + name: Webserver ACL + vpc: customers + state: absent ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py b/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py index 51eb1e7953..4990f74b0e 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_network_acl_rule.py @@ -145,47 +145,47 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' # create a network ACL rule, allow port 80 ingress -local_action: - module: cs_network_acl_rule - network_acl: web - rule_position: 1 - vpc: my vpc - traffic_type: ingress - action_policy: allow - port: 80 - cidr: 0.0.0.0/0 +- local_action: + module: cs_network_acl_rule + network_acl: web + rule_position: 1 + vpc: my vpc + traffic_type: ingress + action_policy: allow + port: 80 + cidr: 0.0.0.0/0 # create a network ACL rule, deny port range 8000-9000 ingress for 10.20.0.0/16 -local_action: - module: cs_network_acl_rule - network_acl: web - rule_position: 1 - vpc: my vpc - traffic_type: ingress - action_policy: deny - start_port: 8000 - end_port: 8000 - cidr: 10.20.0.0/16 +- local_action: + module: cs_network_acl_rule + network_acl: web + rule_position: 1 + vpc: my vpc + traffic_type: ingress + action_policy: deny + start_port: 8000 + end_port: 8000 + cidr: 10.20.0.0/16 # create a network ACL rule -local_action: - module: cs_network_acl_rule - network_acl: web - rule_position: 1 - vpc: my vpc - traffic_type: ingress - action_policy: deny - start_port: 8000 - end_port: 8000 - cidr: 10.20.0.0/16 +- local_action: + module: cs_network_acl_rule + network_acl: web + rule_position: 1 + vpc: my vpc + traffic_type: ingress + action_policy: deny + start_port: 8000 + end_port: 8000 + cidr: 10.20.0.0/16 # remove a network ACL rule -local_action: - module: cs_network_acl_rule - network_acl: web - rule_position: 1 - vpc: my vpc - state: absent +- local_action: + module: cs_network_acl_rule + network_acl: web + rule_position: 1 + vpc: my vpc + state: absent ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_region.py b/lib/ansible/modules/cloud/cloudstack/cs_region.py index 173ec53cfa..0c41b5d8e4 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_region.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_region.py @@ -60,17 +60,17 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' # create a region -local_action: - module: cs_region - id: 2 - name: geneva - endpoint: https://cloud.gva.example.com +- local_action: + module: cs_region + id: 2 + name: geneva + endpoint: https://cloud.gva.example.com # remove a region with ID 2 -local_action: - module: cs_region - id: 2 - state: absent +- local_action: + module: cs_region + id: 2 + state: absent ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py b/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py index b36c40d6bc..f7b8be1ee5 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_resourcelimit.py @@ -76,19 +76,19 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' # Update a resource limit for instances of a domain -local_action: - module: cs_resourcelimit - type: instance - limit: 10 - domain: customers +- local_action: + module: cs_resourcelimit + type: instance + limit: 10 + domain: customers # Update a resource limit for instances of an account -local_action: - module: cs_resourcelimit - type: instance - limit: 12 - account: moserre - domain: customers +- local_action: + module: cs_resourcelimit + type: instance + limit: 12 + account: moserre + domain: customers ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/cloudstack/cs_storage_pool.py b/lib/ansible/modules/cloud/cloudstack/cs_storage_pool.py index 4a0b31af7c..07c8a74d56 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_storage_pool.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_storage_pool.py @@ -111,7 +111,6 @@ EXAMPLES = ''' pod: pod01 storage_url: rbd://admin:SECRET@ceph-the-mons.domain/poolname provider: DefaultPrimary - name: Ceph RBD scope: cluster allocation_state: disabled @@ -124,7 +123,6 @@ EXAMPLES = ''' pod: pod01 storage_url: rbd://admin:SECRET@ceph-the-mons.domain/poolname provider: DefaultPrimary - name: Ceph RBD scope: cluster allocation_state: maintenance diff --git a/lib/ansible/modules/cloud/cloudstack/cs_user.py b/lib/ansible/modules/cloud/cloudstack/cs_user.py index 3dde2787c8..3140d43bcd 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_user.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_user.py @@ -101,43 +101,43 @@ extends_documentation_fragment: cloudstack EXAMPLES = ''' # create an user in domain 'CUSTOMERS' -local_action: - module: cs_user - account: developers - username: johndoe - password: S3Cur3 - last_name: Doe - first_name: John - email: john.doe@example.com - domain: CUSTOMERS +- local_action: + module: cs_user + account: developers + username: johndoe + password: S3Cur3 + last_name: Doe + first_name: John + email: john.doe@example.com + domain: CUSTOMERS # Lock an existing user in domain 'CUSTOMERS' -local_action: - module: cs_user - username: johndoe - domain: CUSTOMERS - state: locked +- local_action: + module: cs_user + username: johndoe + domain: CUSTOMERS + state: locked # Disable an existing user in domain 'CUSTOMERS' -local_action: - module: cs_user - username: johndoe - domain: CUSTOMERS - state: disabled +- local_action: + module: cs_user + username: johndoe + domain: CUSTOMERS + state: disabled # Enable/unlock an existing user in domain 'CUSTOMERS' -local_action: - module: cs_user - username: johndoe - domain: CUSTOMERS - state: enabled +- local_action: + module: cs_user + username: johndoe + domain: CUSTOMERS + state: enabled # Remove an user in domain 'CUSTOMERS' -local_action: - module: cs_user - name: customer_xy - domain: CUSTOMERS - state: absent +- local_action: + module: cs_user + name: customer_xy + domain: CUSTOMERS + state: absent ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gce.py b/lib/ansible/modules/cloud/google/gce.py index 36714de861..529597c269 100644 --- a/lib/ansible/modules/cloud/google/gce.py +++ b/lib/ansible/modules/cloud/google/gce.py @@ -199,7 +199,7 @@ EXAMPLES = ''' # Create multiple instances by specifying multiple names, separated by # commas in the instance_names field # (e.g. my-test-instance1,my-test-instance2) - gce: + - gce: instance_names: my-test-instance1 zone: us-central1-a machine_type: n1-standard-1 @@ -213,7 +213,7 @@ EXAMPLES = ''' # Create a single instance of an image from the "my-base-image" image family # in the us-central1-a Zone of the n1-standard-1 machine type. # This image family is in the "my-other-project" GCP project. - gce: + - gce: instance_names: my-test-instance1 zone: us-central1-a machine_type: n1-standard-1 @@ -229,7 +229,7 @@ EXAMPLES = ''' # Create a single Debian 8 instance in the us-central1-a Zone # Use existing disks, custom network/subnetwork, set service account permissions # add tags and metadata. - gce: + - gce: instance_names: my-test-instance zone: us-central1-a machine_type: n1-standard-1 diff --git a/lib/ansible/modules/cloud/google/gce_eip.py b/lib/ansible/modules/cloud/google/gce_eip.py index 20f246a4b8..a243dd5ef1 100644 --- a/lib/ansible/modules/cloud/google/gce_eip.py +++ b/lib/ansible/modules/cloud/google/gce_eip.py @@ -42,22 +42,22 @@ options: EXAMPLES = ''' # Create a Global external IP address -gce_eip: - service_account_email: "{{ service_account_email }}" - credentials_file: "{{ credentials_file }}" - project_id: "{{ project_id }}" - name: my-global-ip - region: global - state: present +- gce_eip: + service_account_email: "{{ service_account_email }}" + credentials_file: "{{ credentials_file }}" + project_id: "{{ project_id }}" + name: my-global-ip + region: global + state: present # Create a Regional external IP address -gce_eip: - service_account_email: "{{ service_account_email }}" - credentials_file: "{{ credentials_file }}" - project_id: "{{ project_id }}" - name: my-global-ip - region: us-east1 - state: present +- gce_eip: + service_account_email: "{{ service_account_email }}" + credentials_file: "{{ credentials_file }}" + project_id: "{{ project_id }}" + name: my-global-ip + region: us-east1 + state: present ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcpubsub_facts.py b/lib/ansible/modules/cloud/google/gcpubsub_facts.py index ea515a75fb..6b687c1b7a 100644 --- a/lib/ansible/modules/cloud/google/gcpubsub_facts.py +++ b/lib/ansible/modules/cloud/google/gcpubsub_facts.py @@ -45,20 +45,20 @@ options: EXAMPLES = ''' ## List all Topics in a project -gcpubsub_facts: - view: topics - state: list +- gcpubsub_facts: + view: topics + state: list ## List all Subscriptions in a project -gcpubsub_facts: - view: subscriptions - state: list +- gcpubsub_facts: + view: subscriptions + state: list ## List all Subscriptions for a Topic in a project -gcpubsub_facts: - view: subscriptions - topic: my-topic - state: list +- gcpubsub_facts: + view: subscriptions + topic: my-topic + state: list ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/linode/linode.py b/lib/ansible/modules/cloud/linode/linode.py index 3a3aa3eb0d..2347635df3 100644 --- a/lib/ansible/modules/cloud/linode/linode.py +++ b/lib/ansible/modules/cloud/linode/linode.py @@ -189,7 +189,6 @@ EXAMPLES = ''' alert_bwin_threshold: 10 alert_cpu_enabled: True alert_cpu_threshold: 210 - alert_diskio_enabled: True alert_bwout_enabled: True alert_bwout_threshold: 10 alert_diskio_enabled: True diff --git a/lib/ansible/modules/cloud/misc/rhevm.py b/lib/ansible/modules/cloud/misc/rhevm.py index 39e846397a..c29074427a 100644 --- a/lib/ansible/modules/cloud/misc/rhevm.py +++ b/lib/ansible/modules/cloud/misc/rhevm.py @@ -235,7 +235,6 @@ EXAMPLES = ''' cluster: "RH" state: "down" image: "centos7_x64" - cluster: "centos" # multi disk, multi nic create example - rhevm: diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_auth.py b/lib/ansible/modules/cloud/ovirt/ovirt_auth.py index 7a4f17bab0..c7ba086efb 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_auth.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_auth.py @@ -116,7 +116,6 @@ notes: ''' EXAMPLES = ''' -tasks: - block: # Create a vault with `ovirt_password` variable which store your # oVirt/RHV user's password, and include that yaml file with variable: @@ -150,7 +149,6 @@ tasks: # in yaml file. # This is mainly usefull when using Ansible Tower or AWX, as it will work # for Red Hat Virtualization creadentials type. -tasks: - name: Obtain SSO token ovirt_auth: state: present diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_group.py b/lib/ansible/modules/cloud/ovirt/ovirt_group.py index 2a0ee2f9d2..1afdbf2704 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_group.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_group.py @@ -59,20 +59,20 @@ EXAMPLES = ''' # look at ovirt_auth module to see how to reuse authentication: # Add group group1 from authorization provider example.com-authz -ovirt_group: +- ovirt_group: name: group1 domain: example.com-authz # Add group group1 from authorization provider example.com-authz # In case of multi-domain Active Directory setup, you should pass # also namespace, so it adds correct group: -ovirt_group: +- ovirt_group: name: group1 namespace: dc=ad2,dc=example,dc=com domain: example.com-authz # Remove group group1 with authorization provider example.com-authz -ovirt_group: +- ovirt_group: state: absent name: group1 domain: example.com-authz diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py b/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py index 92daa1229f..2687246949 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_quotas.py @@ -82,7 +82,7 @@ EXAMPLES = ''' # look at ovirt_auth module to see how to reuse authentication: # Add cluster quota to cluster cluster1 with memory limit 20GiB and CPU limit to 10: -ovirt_quotas: +- ovirt_quotas: name: quota1 data_center: dcX clusters: @@ -91,7 +91,7 @@ ovirt_quotas: cpu: 10 # Add cluster quota to all clusters with memory limit 30GiB and CPU limit to 15: -ovirt_quotas: +- ovirt_quotas: name: quota2 data_center: dcX clusters: @@ -99,7 +99,7 @@ ovirt_quotas: cpu: 15 # Add storage quota to storage data1 with size limit to 100GiB -ovirt_quotas: +- ovirt_quotas: name: quota3 data_center: dcX storage_grace: 40 @@ -109,7 +109,7 @@ ovirt_quotas: size: 100 # Remove quota quota1 (Note the quota must not be assigned to any VM/disk): -ovirt_quotas: +- ovirt_quotas: state: absent data_center: dcX name: quota1 diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_users.py b/lib/ansible/modules/cloud/ovirt/ovirt_users.py index 4ce0b71449..f0121c2f38 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_users.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_users.py @@ -55,18 +55,18 @@ EXAMPLES = ''' # look at ovirt_auth module to see how to reuse authentication: # Add user user1 from authorization provider example.com-authz -ovirt_users: +- ovirt_users: name: user1 domain: example.com-authz # Add user user1 from authorization provider example.com-authz # In case of Active Directory specify UPN: -ovirt_users: +- ovirt_users: name: user1@ad2.example.com domain: example.com-authz # Remove user user1 with authorization provider example.com-authz -ovirt_users: +- ovirt_users: state: absent name: user1 authz_name: example.com-authz diff --git a/lib/ansible/modules/cloud/smartos/smartos_image_facts.py b/lib/ansible/modules/cloud/smartos/smartos_image_facts.py index 0282c0bc27..3d2d788ed3 100644 --- a/lib/ansible/modules/cloud/smartos/smartos_image_facts.py +++ b/lib/ansible/modules/cloud/smartos/smartos_image_facts.py @@ -35,17 +35,17 @@ options: EXAMPLES = ''' # Return facts about all installed images. -smartos_image_facts: +- smartos_image_facts: # Return all private active Linux images. -smartos_image_facts: filters="os=linux state=active public=false" +- smartos_image_facts: filters="os=linux state=active public=false" # Show, how many clones does every image have. -smartos_image_facts: +- smartos_image_facts: -debug: msg="{{ smartos_images[item]['name'] }}-{{smartos_images[item]['version'] }} +- debug: msg="{{ smartos_images[item]['name'] }}-{{smartos_images[item]['version'] }} has {{ smartos_images[item]['clones'] }} VM(s)" -with_items: "{{ smartos_images.keys() }}" + with_items: "{{ smartos_images.keys() }}" ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/spotinst/spotinst_aws_elastigroup.py b/lib/ansible/modules/cloud/spotinst/spotinst_aws_elastigroup.py index ced3bde0fd..db2fa3733b 100644 --- a/lib/ansible/modules/cloud/spotinst/spotinst_aws_elastigroup.py +++ b/lib/ansible/modules/cloud/spotinst/spotinst_aws_elastigroup.py @@ -628,7 +628,6 @@ EXAMPLES = ''' - sg-8f4b8fe9 spot_instance_types: - c3.large - state: absent do_not_update: - image_id - target diff --git a/lib/ansible/modules/monitoring/datadog_monitor.py b/lib/ansible/modules/monitoring/datadog_monitor.py index 1f1b2ef6a8..474d7a5dd6 100644 --- a/lib/ansible/modules/monitoring/datadog_monitor.py +++ b/lib/ansible/modules/monitoring/datadog_monitor.py @@ -126,36 +126,36 @@ options: EXAMPLES = ''' # Create a metric monitor -datadog_monitor: - type: "metric alert" - name: "Test monitor" - state: "present" - query: "datadog.agent.up.over('host:host1').last(2).count_by_status()" - message: "Host [[host.name]] with IP [[host.ip]] is failing to report to datadog." - api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" - app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" +- datadog_monitor: + type: "metric alert" + name: "Test monitor" + state: "present" + query: "datadog.agent.up.over('host:host1').last(2).count_by_status()" + message: "Host [[host.name]] with IP [[host.ip]] is failing to report to datadog." + api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" + app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" # Deletes a monitor -datadog_monitor: - name: "Test monitor" - state: "absent" - api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" - app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" +- datadog_monitor: + name: "Test monitor" + state: "absent" + api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" + app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" # Mutes a monitor -datadog_monitor: - name: "Test monitor" - state: "mute" - silenced: '{"*":None}' - api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" - app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" +- datadog_monitor: + name: "Test monitor" + state: "mute" + silenced: '{"*":None}' + api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" + app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" # Unmutes a monitor -datadog_monitor: - name: "Test monitor" - state: "unmute" - api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" - app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" +- datadog_monitor: + name: "Test monitor" + state: "unmute" + api_key: "9775a026f1ca7d1c6c5af9d94d9595a4" + app_key: "87ce4a24b5553d2e482ea8a8500e71b8ad4554ff" ''' import traceback diff --git a/lib/ansible/modules/network/aci/aci_epg.py b/lib/ansible/modules/network/aci/aci_epg.py index 214c99c6b8..9210731536 100644 --- a/lib/ansible/modules/network/aci/aci_epg.py +++ b/lib/ansible/modules/network/aci/aci_epg.py @@ -85,7 +85,7 @@ EXAMPLES = r''' description: Web Intranet EPG bd: prod_bd - aci_epg: +- aci_epg: hostname: apic username: admin password: SomeSecretPassword diff --git a/lib/ansible/modules/network/avi/avi_gslbservice_patch_member.py b/lib/ansible/modules/network/avi/avi_gslbservice_patch_member.py index e63d4c9b2f..d3ceaddbc1 100644 --- a/lib/ansible/modules/network/avi/avi_gslbservice_patch_member.py +++ b/lib/ansible/modules/network/avi/avi_gslbservice_patch_member.py @@ -66,7 +66,6 @@ EXAMPLES = ''' addr: 10.30.10.66 type: V4 ratio: 3 - api_version: 16.4 - name: Patch GSLB Service to delete an existing member avi_gslbservice_patch_member: controller: "{{ controller }}" diff --git a/lib/ansible/modules/network/cloudengine/ce_command.py b/lib/ansible/modules/network/cloudengine/ce_command.py index fdf30577cd..15b3ab4dc4 100644 --- a/lib/ansible/modules/network/cloudengine/ce_command.py +++ b/lib/ansible/modules/network/cloudengine/ce_command.py @@ -96,8 +96,6 @@ EXAMPLES = """ password: "{{ password }}" transport: cli - tasks: - tasks: - name: "Run display version on remote devices" ce_command: diff --git a/lib/ansible/modules/network/cloudengine/ce_interface_ospf.py b/lib/ansible/modules/network/cloudengine/ce_interface_ospf.py index 00df70783e..e2ccef4c32 100644 --- a/lib/ansible/modules/network/cloudengine/ce_interface_ospf.py +++ b/lib/ansible/modules/network/cloudengine/ce_interface_ospf.py @@ -166,7 +166,7 @@ end_state: type: dict sample: {"process_id": "1", "area": "0.0.0.100", "interface": "10GE1/0/30", "cost": "100", "dead_interval": "40", "hello_interval": "10", - "process_id": "6", "silent_interface": "false", "auth_mode": "none"} + "silent_interface": "false", "auth_mode": "none"} updates: description: commands sent to the device returned: always diff --git a/lib/ansible/modules/network/cloudengine/ce_snmp_user.py b/lib/ansible/modules/network/cloudengine/ce_snmp_user.py index 0c4493faa3..59e079bf9f 100644 --- a/lib/ansible/modules/network/cloudengine/ce_snmp_user.py +++ b/lib/ansible/modules/network/cloudengine/ce_snmp_user.py @@ -158,7 +158,7 @@ end_state: returned: always type: dict sample: {"snmp local user": {"local_user_info": []}, - "snmp local user": {"local_user_info": [{"aclNumber": "2000", "engineID": "800007DB03389222111200", + "snmp usm user": {"usm_user_info": [{"aclNumber": "2000", "engineID": "800007DB03389222111200", "groupName": "wdz_group", "userName": "wdz_snmp"}]}} updates: description: command sent to the device diff --git a/lib/ansible/modules/network/cnos/cnos_conditional_command.py b/lib/ansible/modules/network/cnos/cnos_conditional_command.py index 8360ac7455..e18cf83525 100644 --- a/lib/ansible/modules/network/cnos/cnos_conditional_command.py +++ b/lib/ansible/modules/network/cnos/cnos_conditional_command.py @@ -87,7 +87,6 @@ Tasks : The following are examples of using the module cnos_conditional_command. condition: "{{ hostvars[inventory_hostname]['condition']}}" flag: leaf_switch2 command: "spanning-tree mode enable" - enablePassword: "anil" ''' RETURN = ''' diff --git a/lib/ansible/modules/network/illumos/dladm_iptun.py b/lib/ansible/modules/network/illumos/dladm_iptun.py index 9f5ac5fe94..2d59ecdaf8 100644 --- a/lib/ansible/modules/network/illumos/dladm_iptun.py +++ b/lib/ansible/modules/network/illumos/dladm_iptun.py @@ -58,17 +58,17 @@ options: ''' EXAMPLES = ''' -name: Create IPv4 tunnel interface 'iptun0' -dladm_iptun: name=iptun0 local_address=192.0.2.23 remote_address=203.0.113.10 state=present +- name: Create IPv4 tunnel interface 'iptun0' + dladm_iptun: name=iptun0 local_address=192.0.2.23 remote_address=203.0.113.10 state=present -name: Change IPv4 tunnel remote address -dladm_iptun: name=iptun0 type=ipv4 local_address=192.0.2.23 remote_address=203.0.113.11 +- name: Change IPv4 tunnel remote address + dladm_iptun: name=iptun0 type=ipv4 local_address=192.0.2.23 remote_address=203.0.113.11 -name: Create IPv6 tunnel interface 'tun0' -dladm_iptun: name=tun0 type=ipv6 local_address=192.0.2.23 remote_address=203.0.113.42 +- name: Create IPv6 tunnel interface 'tun0' + dladm_iptun: name=tun0 type=ipv6 local_address=192.0.2.23 remote_address=203.0.113.42 -name: Remove 'iptun0' tunnel interface -dladm_iptun: name=iptun0 state=absent +- name: Remove 'iptun0' tunnel interface + dladm_iptun: name=iptun0 state=absent ''' RETURN = ''' diff --git a/lib/ansible/modules/network/illumos/dladm_linkprop.py b/lib/ansible/modules/network/illumos/dladm_linkprop.py index c4c0050b61..85ab04b38d 100644 --- a/lib/ansible/modules/network/illumos/dladm_linkprop.py +++ b/lib/ansible/modules/network/illumos/dladm_linkprop.py @@ -52,14 +52,14 @@ options: ''' EXAMPLES = ''' -name: Set 'maxbw' to 100M on e1000g1 -dladm_linkprop: name=e1000g1 property=maxbw value=100M state=present +- name: Set 'maxbw' to 100M on e1000g1 + dladm_linkprop: name=e1000g1 property=maxbw value=100M state=present -name: Set 'mtu' to 9000 on e1000g1 -dladm_linkprop: name=e1000g1 property=mtu value=9000 +- name: Set 'mtu' to 9000 on e1000g1 + dladm_linkprop: name=e1000g1 property=mtu value=9000 -name: Reset 'mtu' property on e1000g1 -dladm_linkprop: name=e1000g1 property=mtu state=reset +- name: Reset 'mtu' property on e1000g1 + dladm_linkprop: name=e1000g1 property=mtu state=reset ''' RETURN = ''' diff --git a/lib/ansible/modules/network/illumos/dladm_vlan.py b/lib/ansible/modules/network/illumos/dladm_vlan.py index 7eaea1dacb..0d39d71f19 100644 --- a/lib/ansible/modules/network/illumos/dladm_vlan.py +++ b/lib/ansible/modules/network/illumos/dladm_vlan.py @@ -51,11 +51,11 @@ options: ''' EXAMPLES = ''' -name: Create 'vlan42' VLAN over 'bnx0' link -dladm_vlan: name=vlan42 link=bnx0 vlan_id=42 state=present +- name: Create 'vlan42' VLAN over 'bnx0' link + dladm_vlan: name=vlan42 link=bnx0 vlan_id=42 state=present -name: Remove 'vlan1337' VLAN interface -dladm_vlan: name=vlan1337 state=absent +- name: Remove 'vlan1337' VLAN interface + dladm_vlan: name=vlan1337 state=absent ''' RETURN = ''' diff --git a/lib/ansible/modules/network/illumos/ipadm_addr.py b/lib/ansible/modules/network/illumos/ipadm_addr.py index d5c2fd40fa..4cf0192944 100644 --- a/lib/ansible/modules/network/illumos/ipadm_addr.py +++ b/lib/ansible/modules/network/illumos/ipadm_addr.py @@ -59,17 +59,17 @@ options: ''' EXAMPLES = ''' -name: Configure IP address 10.0.0.1 on e1000g0 -ipadm_addr: addr=10.0.0.1/32 addrobj=e1000g0/v4 state=present +- name: Configure IP address 10.0.0.1 on e1000g0 + ipadm_addr: addr=10.0.0.1/32 addrobj=e1000g0/v4 state=present -name: Delete addrobj -ipadm_addr: addrobj=e1000g0/v4 state=absent +- name: Delete addrobj + ipadm_addr: addrobj=e1000g0/v4 state=absent -name: Configure link-local IPv6 address -ipadm_addr: addtype=addrconf addrobj=vnic0/v6 +- name: Configure link-local IPv6 address + ipadm_addr: addtype=addrconf addrobj=vnic0/v6 -name: Configure address via DHCP and wait 180 seconds for address obtaining -ipadm_addr: addrobj=vnic0/dhcp addrtype=dhcp wait=180 +- name: Configure address via DHCP and wait 180 seconds for address obtaining + ipadm_addr: addrobj=vnic0/dhcp addrtype=dhcp wait=180 ''' RETURN = ''' diff --git a/lib/ansible/modules/network/illumos/ipadm_addrprop.py b/lib/ansible/modules/network/illumos/ipadm_addrprop.py index 3e008a303f..d31e3b1224 100644 --- a/lib/ansible/modules/network/illumos/ipadm_addrprop.py +++ b/lib/ansible/modules/network/illumos/ipadm_addrprop.py @@ -51,11 +51,11 @@ options: ''' EXAMPLES = ''' -name: Mark address on addrobj as deprecated -ipadm_addrprop: property=deprecated value=on addrobj=e1000g0/v6 +- name: Mark address on addrobj as deprecated + ipadm_addrprop: property=deprecated value=on addrobj=e1000g0/v6 -name: Set network prefix length for addrobj -ipadm_addrprop: addrobj=bge0/v4 name=prefixlen value=26 +- name: Set network prefix length for addrobj + ipadm_addrprop: addrobj=bge0/v4 name=prefixlen value=26 ''' RETURN = ''' diff --git a/lib/ansible/modules/network/illumos/ipadm_ifprop.py b/lib/ansible/modules/network/illumos/ipadm_ifprop.py index fd71236a29..e5e75962d2 100644 --- a/lib/ansible/modules/network/illumos/ipadm_ifprop.py +++ b/lib/ansible/modules/network/illumos/ipadm_ifprop.py @@ -55,17 +55,17 @@ options: ''' EXAMPLES = ''' -name: Allow forwarding of IPv4 packets on network interface e1000g0 -ipadm_ifprop: protocol=ipv4 property=forwarding value=on interface=e1000g0 +- name: Allow forwarding of IPv4 packets on network interface e1000g0 + ipadm_ifprop: protocol=ipv4 property=forwarding value=on interface=e1000g0 -name: Temporarily reset IPv4 forwarding property on network interface e1000g0 -ipadm_ifprop: protocol=ipv4 interface=e1000g0 temporary=true property=forwarding state=reset +- name: Temporarily reset IPv4 forwarding property on network interface e1000g0 + ipadm_ifprop: protocol=ipv4 interface=e1000g0 temporary=true property=forwarding state=reset -name: Configure IPv6 metric on network interface e1000g0 -ipadm_ifprop: protocol=ipv6 nic=e1000g0 name=metric value=100 +- name: Configure IPv6 metric on network interface e1000g0 + ipadm_ifprop: protocol=ipv6 nic=e1000g0 name=metric value=100 -name: Set IPv6 MTU on network interface bge0 -ipadm_ifprop: interface=bge0 name=mtu value=1280 protocol=ipv6 +- name: Set IPv6 MTU on network interface bge0 + ipadm_ifprop: interface=bge0 name=mtu value=1280 protocol=ipv6 ''' RETURN = ''' diff --git a/lib/ansible/modules/network/illumos/ipadm_prop.py b/lib/ansible/modules/network/illumos/ipadm_prop.py index 0bb4218c53..4fd0bb1072 100644 --- a/lib/ansible/modules/network/illumos/ipadm_prop.py +++ b/lib/ansible/modules/network/illumos/ipadm_prop.py @@ -51,10 +51,10 @@ options: EXAMPLES = ''' # Set TCP receive buffer size -ipadm_prop: protocol=tcp property=recv_buf value=65536 +- ipadm_prop: protocol=tcp property=recv_buf value=65536 # Reset UDP send buffer size to the default value -ipadm_prop: protocol=udp property=send_buf state=reset +- ipadm_prop: protocol=udp property=send_buf state=reset ''' RETURN = ''' diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_password.py b/lib/ansible/modules/network/nxos/nxos_vtp_password.py index 14c04411c9..f9a919f016 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_password.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_password.py @@ -60,7 +60,6 @@ options: EXAMPLES = ''' # ENSURE VTP PASSWORD IS SET - nxos_vtp_password: - password: ntc state: present host: "{{ inventory_hostname }}" username: "{{ un }}" @@ -68,7 +67,6 @@ EXAMPLES = ''' # ENSURE VTP PASSWORD IS REMOVED - nxos_vtp_password: - password: ntc state: absent host: "{{ inventory_hostname }}" username: "{{ un }}" diff --git a/lib/ansible/modules/remote_management/ucs/ucs_wwn_pool.py b/lib/ansible/modules/remote_management/ucs/ucs_wwn_pool.py index 19b55ac3ed..549ee73c3b 100644 --- a/lib/ansible/modules/remote_management/ucs/ucs_wwn_pool.py +++ b/lib/ansible/modules/remote_management/ucs/ucs_wwn_pool.py @@ -86,7 +86,7 @@ EXAMPLES = r''' purpose: node first_addr: 20:00:00:25:B5:48:00:00 last_addr: 20:00:00:25:B5:48:00:0F - ucs_wwn_pool: +- ucs_wwn_pool: hostname: 172.16.143.150 username: admin password: password @@ -103,7 +103,7 @@ EXAMPLES = r''' password: password name: WWNN-Pool state: absent - ucs_wwn_pool: +- ucs_wwn_pool: hostname: 172.16.143.150 username: admin password: password diff --git a/lib/ansible/modules/storage/netapp/netapp_e_amg.py b/lib/ansible/modules/storage/netapp/netapp_e_amg.py index 476a2b83f9..b6aea1ad73 100644 --- a/lib/ansible/modules/storage/netapp/netapp_e_amg.py +++ b/lib/ansible/modules/storage/netapp/netapp_e_amg.py @@ -98,12 +98,6 @@ EXAMPLES = """ """ RETURN = """ -msg: - description: Successful removal - returned: success - type: string - sample: "Async mirror group removed." - msg: description: Successful creation returned: success diff --git a/lib/ansible/modules/storage/zfs/zpool_facts.py b/lib/ansible/modules/storage/zfs/zpool_facts.py index 3c4ccd5ae9..3063d24e7d 100644 --- a/lib/ansible/modules/storage/zfs/zpool_facts.py +++ b/lib/ansible/modules/storage/zfs/zpool_facts.py @@ -45,12 +45,12 @@ options: EXAMPLES = ''' # Gather facts about ZFS pool rpool -zpool_facts: pool=rpool +- zpool_facts: pool=rpool # Gather space usage about all imported ZFS pools -zpool_facts: properties='free,size' -debug: msg='ZFS pool {{ item.name }} has {{ item.free }} free space out of {{ item.size }}.' -with_items: '{{ ansible_zfs_pools }}' +- zpool_facts: properties='free,size' + debug: msg='ZFS pool {{ item.name }} has {{ item.free }} free space out of {{ item.size }}.' + with_items: '{{ ansible_zfs_pools }}' ''' RETURN = ''' diff --git a/lib/ansible/modules/utilities/logic/import_tasks.py b/lib/ansible/modules/utilities/logic/import_tasks.py index d107c5e02e..3565a5cebe 100644 --- a/lib/ansible/modules/utilities/logic/import_tasks.py +++ b/lib/ansible/modules/utilities/logic/import_tasks.py @@ -44,7 +44,7 @@ EXAMPLES = """ - debug: msg: task10 - hosts: all +- hosts: all tasks: - debug: msg: task1 diff --git a/lib/ansible/modules/windows/win_regmerge.py b/lib/ansible/modules/windows/win_regmerge.py index a4c6d9bc0a..af93ce4cb2 100644 --- a/lib/ansible/modules/windows/win_regmerge.py +++ b/lib/ansible/modules/windows/win_regmerge.py @@ -67,12 +67,12 @@ notes: EXAMPLES = r''' # Merge in a registry file without comparing to current registry # Note that paths using / to separate are preferred as they require less special handling than \ - win_regmerge: - path: C:/autodeploy/myCompany-settings.reg + - win_regmerge: + path: C:/autodeploy/myCompany-settings.reg # Compare and merge registry file - win_regmerge: - path: C:/autodeploy/myCompany-settings.reg - compare_to: HKLM:\SOFTWARE\myCompany + - win_regmerge: + path: C:/autodeploy/myCompany-settings.reg + compare_to: HKLM:\SOFTWARE\myCompany ''' RETURN = r''' diff --git a/lib/ansible/utils/module_docs_fragments/return_common.py b/lib/ansible/utils/module_docs_fragments/return_common.py index f6fc1afc55..998e1a0558 100644 --- a/lib/ansible/utils/module_docs_fragments/return_common.py +++ b/lib/ansible/utils/module_docs_fragments/return_common.py @@ -44,7 +44,7 @@ results: description: List of module results, returned: when using a loop. type: list - sample:[ {changed: True, msg: 'first item changed'}, {changed: False, msg: 'second item ok'}] + sample: [{changed: True, msg: 'first item changed'}, {changed: False, msg: 'second item ok'}] exception: description: Optional information from a handled error. returned: on some errors diff --git a/test/runner/lib/sanity/yamllint.py b/test/runner/lib/sanity/yamllint.py index a64f43eb09..4e5f8467dd 100644 --- a/test/runner/lib/sanity/yamllint.py +++ b/test/runner/lib/sanity/yamllint.py @@ -1,8 +1,8 @@ """Sanity test using yamllint.""" from __future__ import absolute_import, print_function +import json import os -import re from lib.sanity import ( SanitySingleVersion, @@ -15,7 +15,6 @@ from lib.sanity import ( from lib.util import ( SubprocessError, run_command, - find_executable, ) from lib.config import ( @@ -31,15 +30,42 @@ class YamllintTest(SanitySingleVersion): :type targets: SanityTargets :rtype: SanityResult """ - paths = sorted(i.path for i in targets.include if os.path.splitext(i.path)[1] in ('.yml', '.yaml')) + paths = [ + [i.path for i in targets.include if os.path.splitext(i.path)[1] in ('.yml', '.yaml')], + + [i.path for i in targets.include if os.path.splitext(i.path)[1] == '.py' and + os.path.basename(i.path) != '__init__.py' and + i.path.startswith('lib/ansible/modules/')], + + [i.path for i in targets.include if os.path.splitext(i.path)[1] == '.py' and + os.path.basename(i.path) != '__init__.py' and + i.path.startswith('lib/ansible/utils/module_docs_fragments/')], + ] + + paths = [sorted(p) for p in paths if p] if not paths: return SanitySkipped(self.name) + results = [] + + for test_paths in paths: + results += self.test_paths(args, test_paths) + + if results: + return SanityFailure(self.name, messages=results) + + return SanitySuccess(self.name) + + def test_paths(self, args, paths): + """ + :type args: SanityConfig + :type paths: list[str] + :rtype: list[SanityMessage] + """ cmd = [ 'python%s' % args.python_version, - find_executable('yamllint'), - '--format', 'parsable', + 'test/sanity/yamllint/yamllinter.py', ] + paths try: @@ -54,11 +80,9 @@ class YamllintTest(SanitySingleVersion): raise SubprocessError(cmd=cmd, status=status, stderr=stderr, stdout=stdout) if args.explain: - return SanitySuccess(self.name) + return [] - pattern = r'^(?P[^:]*):(?P[0-9]+):(?P[0-9]+): \[(?Pwarning|error)\] (?P.*)$' - - results = [re.search(pattern, line).groupdict() for line in stdout.splitlines()] + results = json.loads(stdout)['messages'] results = [SanityMessage( message=r['message'], @@ -68,7 +92,4 @@ class YamllintTest(SanitySingleVersion): level=r['level'], ) for r in results] - if results: - return SanityFailure(self.name, messages=results) - - return SanitySuccess(self.name) + return results diff --git a/test/sanity/yamllint/config/default.yml b/test/sanity/yamllint/config/default.yml new file mode 100644 index 0000000000..45d8b7adcf --- /dev/null +++ b/test/sanity/yamllint/config/default.yml @@ -0,0 +1,19 @@ +extends: default + +rules: + braces: {max-spaces-inside: 1, level: error} + brackets: {max-spaces-inside: 1, level: error} + colons: {max-spaces-after: -1, level: error} + commas: {max-spaces-after: -1, level: error} + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: {max: 3, level: error} + hyphens: {level: error} + indentation: disable + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: {type: unix} + trailing-spaces: disable + truthy: disable diff --git a/test/sanity/yamllint/config/modules.yml b/test/sanity/yamllint/config/modules.yml new file mode 100644 index 0000000000..da7e604999 --- /dev/null +++ b/test/sanity/yamllint/config/modules.yml @@ -0,0 +1,19 @@ +extends: default + +rules: + braces: disable + brackets: disable + colons: disable + commas: disable + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: disable + hyphens: disable + indentation: disable + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: {type: unix} + trailing-spaces: disable + truthy: disable diff --git a/test/sanity/yamllint/yamllinter.py b/test/sanity/yamllint/yamllinter.py new file mode 100755 index 0000000000..197b0dc45b --- /dev/null +++ b/test/sanity/yamllint/yamllinter.py @@ -0,0 +1,183 @@ +#!/usr/bin/env python +"""Wrapper around yamllint that supports YAML embedded in Ansible modules.""" + +from __future__ import absolute_import, print_function + +import ast +import json +import os +import sys + +from yamllint import linter +from yamllint.config import YamlLintConfig + + +def main(): + """Main program body.""" + paths = sys.argv[1:] + + checker = YamlChecker() + checker.check(paths) + checker.report() + + +class YamlChecker(object): + """Wrapper around yamllint that supports YAML embedded in Ansible modules.""" + def __init__(self): + self.messages = [] + + def report(self): + """Print yamllint report to stdout.""" + report = dict( + messages=self.messages, + ) + + print(json.dumps(report, indent=4, sort_keys=True)) + + def check(self, paths): + """ + :type paths: str + """ + yaml_conf = YamlLintConfig(file='test/sanity/yamllint/config/default.yml') + module_conf = YamlLintConfig(file='test/sanity/yamllint/config/modules.yml') + + for path in paths: + extension = os.path.splitext(path)[1] + + with open(path) as f: + contents = f.read() + + if extension in ('.yml', '.yaml'): + self.check_yaml(yaml_conf, path, contents) + elif extension == '.py': + self.check_module(module_conf, path, contents) + else: + raise Exception('unsupported extension: %s' % extension) + + def check_yaml(self, conf, path, contents): + """ + :type conf: YamlLintConfig + :type path: str + :type contents: str + """ + self.messages += [self.result_to_message(r, path) for r in linter.run(contents, conf, path)] + + def check_module(self, conf, path, contents): + """ + :type conf: YamlLintConfig + :type path: str + :type contents: str + """ + docs = self.get_module_docs(path, contents) + + for key, value in docs.items(): + yaml = value['yaml'] + lineno = value['lineno'] + + if yaml.startswith('\n'): + yaml = yaml[1:] + lineno += 1 + + messages = list(linter.run(yaml, conf, path)) + + self.messages += [self.result_to_message(r, path, lineno - 1, key) for r in messages] + + @staticmethod + def result_to_message(result, path, line_offset=0, prefix=''): + """ + :type result: any + :type path: str + :type line_offset: int + :type prefix: str + :rtype: dict[str, any] + """ + if prefix: + prefix = '%s: ' % prefix + + return dict( + code=result.rule or result.level, + message=prefix + result.desc, + path=path, + line=result.line + line_offset, + column=result.column, + level=result.level, + ) + + def get_module_docs(self, path, contents): + """ + :type path: str + :type contents: str + :rtype: dict[str, any] + """ + module_doc_types = [ + 'DOCUMENTATION', + 'EXAMPLES', + 'RETURN', + ] + + docs = {} + + def check_assignment(statement, doc_types=None): + """Check the given statement for a documentation assignment.""" + for target in statement.targets: + if doc_types and target.id not in doc_types: + continue + + docs[target.id] = dict( + yaml=statement.value.s, + lineno=statement.lineno, + end_lineno=statement.lineno + len(statement.value.s.splitlines()) + ) + + module_ast = self.parse_module(path, contents) + + if not module_ast: + return {} + + if path.startswith('lib/ansible/modules/'): + for body_statement in module_ast.body: + if isinstance(body_statement, ast.Assign): + check_assignment(body_statement, module_doc_types) + elif path.startswith('lib/ansible/utils/module_docs_fragments/'): + for body_statement in module_ast.body: + if isinstance(body_statement, ast.ClassDef): + for class_statement in body_statement.body: + if isinstance(class_statement, ast.Assign): + check_assignment(class_statement) + else: + raise Exception('unsupported path: %s' % path) + + return docs + + def parse_module(self, path, contents): + """ + :type path: str + :type contents: str + :rtype: ast.Module | None + """ + try: + return ast.parse(contents) + except SyntaxError as ex: + self.messages.append(dict( + code='python-syntax-error', + message=str(ex), + path=path, + line=ex.lineno, + column=ex.offset, + level='error', + )) + except Exception as ex: + self.messages.append(dict( + code='python-parse-error', + message=str(ex), + path=path, + line=0, + column=0, + level='error', + )) + + return None + + +if __name__ == '__main__': + main()