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.
This commit is contained in:
parent
240024ea4a
commit
227ff61f9d
53 changed files with 533 additions and 344 deletions
19
.yamllint
19
.yamllint
|
@ -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
|
1
.yamllint
Symbolic link
1
.yamllint
Symbolic link
|
@ -0,0 +1 @@
|
|||
test/sanity/yamllint/config/default.yml
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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 = """
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }}'
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -235,7 +235,6 @@ EXAMPLES = '''
|
|||
cluster: "RH"
|
||||
state: "down"
|
||||
image: "centos7_x64"
|
||||
cluster: "centos"
|
||||
|
||||
# multi disk, multi nic create example
|
||||
- rhevm:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -628,7 +628,6 @@ EXAMPLES = '''
|
|||
- sg-8f4b8fe9
|
||||
spot_instance_types:
|
||||
- c3.large
|
||||
state: absent
|
||||
do_not_update:
|
||||
- image_id
|
||||
- target
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ EXAMPLES = r'''
|
|||
description: Web Intranet EPG
|
||||
bd: prod_bd
|
||||
|
||||
aci_epg:
|
||||
- aci_epg:
|
||||
hostname: apic
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
|
|
|
@ -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 }}"
|
||||
|
|
|
@ -96,8 +96,6 @@ EXAMPLES = """
|
|||
password: "{{ password }}"
|
||||
transport: cli
|
||||
|
||||
tasks:
|
||||
|
||||
tasks:
|
||||
- name: "Run display version on remote devices"
|
||||
ce_command:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -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 }}"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = '''
|
||||
|
|
|
@ -44,7 +44,7 @@ EXAMPLES = """
|
|||
- debug:
|
||||
msg: task10
|
||||
|
||||
hosts: all
|
||||
- hosts: all
|
||||
tasks:
|
||||
- debug:
|
||||
msg: task1
|
||||
|
|
|
@ -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'''
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): \[(?P<level>warning|error)\] (?P<message>.*)$'
|
||||
|
||||
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
|
||||
|
|
19
test/sanity/yamllint/config/default.yml
Normal file
19
test/sanity/yamllint/config/default.yml
Normal file
|
@ -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
|
19
test/sanity/yamllint/config/modules.yml
Normal file
19
test/sanity/yamllint/config/modules.yml
Normal file
|
@ -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
|
183
test/sanity/yamllint/yamllinter.py
Executable file
183
test/sanity/yamllint/yamllinter.py
Executable file
|
@ -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()
|
Loading…
Reference in a new issue