diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_ami_copy.py b/lib/ansible/modules/extras/cloud/amazon/ec2_ami_copy.py index e5c2216652..71b3c611a8 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_ami_copy.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_ami_copy.py @@ -31,11 +31,6 @@ options: description: - the source region that AMI should be copied from required: true - region: - description: - - the destination region that AMI should be copied to - required: true - aliases: ['aws_region', 'ec2_region', 'dest_region'] source_image_id: description: - the id of the image in source region that should be copied @@ -80,7 +75,9 @@ options: default: null author: Amir Moulavi -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py index c11b31cdd7..c4857f6a3c 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py @@ -34,7 +34,9 @@ options: required: false default: null aliases: ['elb_ids', 'ec2_elbs'] -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_eni.py b/lib/ansible/modules/extras/cloud/amazon/ec2_eni.py index 05076e711f..aca78a459d 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_eni.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_eni.py @@ -202,7 +202,7 @@ interface: mac_address: description: interface's physical address type: string - sample: "06:9a:27:6a:6f:99" + sample: "00:00:5E:00:53:23" owner_id: description: aws account id type: string diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_eni_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_eni_facts.py index cf3861b87b..972dcaf4ae 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_eni_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_eni_facts.py @@ -91,13 +91,6 @@ def list_ec2_snapshots_boto3(connection, module): module.exit_json(**snaked_network_interfaces_result) -def get_error_message(xml_string): - - root = ET.fromstring(xml_string) - for message in root.findall('.//Message'): - return message.text - - def get_eni_info(interface): # Private addresses @@ -138,15 +131,13 @@ def get_eni_info(interface): def list_eni(connection, module): - eni_id = module.params.get("eni_id") - filters = module.params.get("filters") interface_dict_array = [] try: all_eni = connection.get_all_network_interfaces(filters=filters) except BotoServerError as e: - module.fail_json(msg=get_error_message(e.args[2])) + module.fail_json(msg=e.message) for interface in all_eni: interface_dict_array.append(get_eni_info(interface)) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vol_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vol_facts.py index 3d10d2d89f..14f5282eca 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vol_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vol_facts.py @@ -23,7 +23,7 @@ module: ec2_vol_facts short_description: Gather facts about ec2 volumes in AWS description: - Gather facts about ec2 volumes in AWS -version_added: "2.0" +version_added: "2.1" author: "Rob White (@wimnat)" options: filters: diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_igw.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_igw.py index 23559f11bb..91366f35ac 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_igw.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_igw.py @@ -31,19 +31,15 @@ options: - The VPC ID for the VPC in which to manage the Internet Gateway. required: true default: null - region: - description: - - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) - required: false - default: null - aliases: [ 'aws_region', 'ec2_region' ] state: description: - Create or terminate the IGW required: false default: present choices: [ 'present', 'absent' ] -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py index 479c5df795..f3f95c107e 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py @@ -24,7 +24,7 @@ module: ec2_vpc_nat_gateway short_description: Manage AWS VPC NAT Gateways. description: - Ensure the state of AWS VPC NAT Gateways based on their id, allocation and subnet ids. -version_added: "2.1" +version_added: "2.2" requirements: [boto3, botocore] options: state: diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py index 85947faed1..1529d92353 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py @@ -70,8 +70,9 @@ options: description: - "VPC ID of the VPC in which to create the route table." required: true - -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table_facts.py index 6ed21af9fd..f270f2cbb2 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table_facts.py @@ -31,14 +31,9 @@ options: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRouteTables.html) for possible filters. required: false default: null - region: - description: - - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) - required: false - default: null - aliases: [ 'aws_region', 'ec2_region' ] - -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet.py index e90dbe9eeb..dc66d44586 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet.py @@ -24,7 +24,7 @@ short_description: Manage subnets in AWS virtual private clouds description: - Manage subnets in AWS virtual private clouds version_added: "2.0" -author: Robert Estelle, @erydo +author: Robert Estelle (@erydo) options: az: description: @@ -33,7 +33,7 @@ options: default: null cidr: description: - - "The CIDR block for the subnet. E.g. 10.0.0.0/16. Only required when state=present." + - "The CIDR block for the subnet. E.g. 192.0.2.0/24. Only required when state=present." required: false default: null tags: @@ -53,8 +53,9 @@ options: - "VPC ID of the VPC in which to create the subnet." required: false default: null - -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' @@ -159,7 +160,7 @@ def get_resource_tags(vpc_conn, resource_id): vpc_conn.get_all_tags(filters={'resource-id': resource_id})) -def ensure_tags(vpc_conn, resource_id, tags, add_only, dry_run): +def ensure_tags(vpc_conn, resource_id, tags, add_only, check_mode): try: cur_tags = get_resource_tags(vpc_conn, resource_id) if cur_tags == tags: @@ -167,11 +168,11 @@ def ensure_tags(vpc_conn, resource_id, tags, add_only, dry_run): to_delete = dict((k, cur_tags[k]) for k in cur_tags if k not in tags) if to_delete and not add_only: - vpc_conn.delete_tags(resource_id, to_delete, dry_run=dry_run) + vpc_conn.delete_tags(resource_id, to_delete, dry_run=check_mode) to_add = dict((k, tags[k]) for k in tags if k not in cur_tags or cur_tags[k] != tags[k]) if to_add: - vpc_conn.create_tags(resource_id, to_add, dry_run=dry_run) + vpc_conn.create_tags(resource_id, to_add, dry_run=check_mode) latest_tags = get_resource_tags(vpc_conn, resource_id) return {'changed': True, 'tags': latest_tags} @@ -203,13 +204,6 @@ def ensure_subnet_present(vpc_conn, vpc_id, cidr, az, tags, check_mode): subnet.tags = tags changed = True - if tags is not None: - tag_result = ensure_tags(vpc_conn, subnet.id, tags, add_only=True, - dry_run=check_mode) - tags = tag_result['tags'] - changed = changed or tag_result['changed'] - else: - tags = get_resource_tags(vpc_conn, subnet.id) subnet_info = get_subnet_info(subnet) return { @@ -222,11 +216,9 @@ def ensure_subnet_absent(vpc_conn, vpc_id, cidr, check_mode): subnet = get_matching_subnet(vpc_conn, vpc_id, cidr) if subnet is None: return {'changed': False} - elif check_mode: - return {'changed': True} try: - vpc_conn.delete_subnet(subnet.id) + vpc_conn.delete_subnet(subnet.id, dry_run=check_mode) return {'changed': True} except EC2ResponseError as e: raise AnsibleVPCSubnetDeletionException( @@ -244,16 +236,14 @@ def main(): tags = dict(default=None, required=False, type='dict', aliases=['resource_tags']), vpc_id = dict(default=None, required=True) ) - module = AnsibleModule( - argument_spec=argument_spec, - supports_check_mode=True, ) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + if not HAS_BOTO: module.fail_json(msg='boto is required for this module') - ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module) - if not region: - module.fail_json(msg='Region must be specified') + region, ec2_url, aws_connect_params = get_aws_connection_info(module) if region: try: @@ -267,14 +257,14 @@ def main(): tags = module.params.get('tags') cidr = module.params.get('cidr') az = module.params.get('az') - state = module.params.get('state', 'present') + state = module.params.get('state') try: if state == 'present': - result = ensure_subnet_present(vpc_conn, vpc_id, cidr, az, tags, + result = ensure_subnet_present(connection, vpc_id, cidr, az, tags, check_mode=module.check_mode) elif state == 'absent': - result = ensure_subnet_absent(vpc_conn, vpc_id, cidr, + result = ensure_subnet_absent(connection, vpc_id, cidr, check_mode=module.check_mode) except AnsibleVPCSubnetException as e: module.fail_json(msg=str(e)) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py index dcbe81f7fa..f881833468 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_subnet_facts.py @@ -31,14 +31,9 @@ options: - A dict of filters to apply. Each dict item consists of a filter key and a filter value. See U(http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSubnets.html) for possible filters. required: false default: null - region: - description: - - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) - required: false - default: null - aliases: [ 'aws_region', 'ec2_region' ] - -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_win_password.py b/lib/ansible/modules/extras/cloud/amazon/ec2_win_password.py index fbc67c150e..4d246d4367 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_win_password.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_win_password.py @@ -40,12 +40,6 @@ options: - The passphrase for the instance key pair. The key must use DES or 3DES encryption for this module to decrypt it. You can use openssl to convert your password protected keys if they do not use DES or 3DES. ex) openssl rsa -in current_key -out new_key -des3. required: false default: null - region: - description: - - The AWS region to use. Must be specified if ec2_url is not used. If not specified then the value of the EC2_REGION environment variable, if any, is used. - required: false - default: null - aliases: [ 'aws_region', 'ec2_region' ] wait: version_added: "2.0" description: @@ -60,7 +54,9 @@ options: required: false default: 120 -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/ecs_taskdefinition.py b/lib/ansible/modules/extras/cloud/amazon/ecs_taskdefinition.py index f06d043bc5..4ee9003aab 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ecs_taskdefinition.py +++ b/lib/ansible/modules/extras/cloud/amazon/ecs_taskdefinition.py @@ -24,7 +24,8 @@ module: ecs_taskdefinition short_description: register a task definition in ecs description: - Creates or terminates task definitions -version_added: "1.9" +version_added: "2.0" +author: Mark Chance(@Java1Guy) requirements: [ json, boto, botocore, boto3 ] options: state: diff --git a/lib/ansible/modules/extras/cloud/amazon/route53_facts.py b/lib/ansible/modules/extras/cloud/amazon/route53_facts.py index 07eff84a99..6dad5e2164 100644 --- a/lib/ansible/modules/extras/cloud/amazon/route53_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/route53_facts.py @@ -54,10 +54,10 @@ options: required: false next_marker: description: - - Some requests such as list_command: hosted_zones will return a maximum + - "Some requests such as list_command: hosted_zones will return a maximum number of entries - EG 100. If the number of entries exceeds this maximum another request can be sent using the NextMarker entry from the first response - to get the next page of results + to get the next page of results" required: false delegation_set_id: description: @@ -65,8 +65,8 @@ options: required: false start_record_name: description: - - The first name in the lexicographic ordering of domain names that you want - the list_command: record_sets to start listing from + - "The first name in the lexicographic ordering of domain names that you want + the list_command: record_sets to start listing from" required: false type: description: @@ -89,9 +89,9 @@ options: required: false hosted_zone_method: description: - - This is used in conjunction with query: hosted_zone. + - "This is used in conjunction with query: hosted_zone. It allows for listing details, counts or tags of various - hosted zone details. + hosted zone details." required: false choices: [ 'details', @@ -103,9 +103,9 @@ options: default: 'list' health_check_method: description: - - This is used in conjunction with query: health_check. + - "This is used in conjunction with query: health_check. It allows for listing details, counts or tags of various - health check details. + health check details." required: false choices: [ 'list', diff --git a/lib/ansible/modules/extras/cloud/amazon/route53_health_check.py b/lib/ansible/modules/extras/cloud/amazon/route53_health_check.py index b67fec863e..0070b3e288 100644 --- a/lib/ansible/modules/extras/cloud/amazon/route53_health_check.py +++ b/lib/ansible/modules/extras/cloud/amazon/route53_health_check.py @@ -93,7 +93,9 @@ options: default: 3 choices: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] author: "zimbatm (@zimbatm)" -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/route53_zone.py b/lib/ansible/modules/extras/cloud/amazon/route53_zone.py index bc8b3b6df8..758860f685 100644 --- a/lib/ansible/modules/extras/cloud/amazon/route53_zone.py +++ b/lib/ansible/modules/extras/cloud/amazon/route53_zone.py @@ -50,7 +50,9 @@ options: - Comment associated with the zone required: false default: '' -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 author: "Christopher Troup (@minichate)" ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/s3_bucket.py b/lib/ansible/modules/extras/cloud/amazon/s3_bucket.py index 0ab91322af..970967e30b 100644 --- a/lib/ansible/modules/extras/cloud/amazon/s3_bucket.py +++ b/lib/ansible/modules/extras/cloud/amazon/s3_bucket.py @@ -42,11 +42,6 @@ options: - The JSON policy as a string. required: false default: null - region: - description: - - "AWS region to create the bucket in. If not set then the value of the AWS_REGION and EC2_REGION environment variables are checked, followed by the aws_region and ec2_region settings in the Boto config file. If none of those are set the region defaults to the S3 Location: US Standard." - required: false - default: null s3_url: description: - S3 URL endpoint for usage with Ceph, Eucalypus, fakes3, etc. Otherwise assumes AWS @@ -79,8 +74,9 @@ options: required: false default: null choices: [ 'yes', 'no' ] - -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/s3_lifecycle.py b/lib/ansible/modules/extras/cloud/amazon/s3_lifecycle.py index 20cae97fb3..f981dfadb8 100644 --- a/lib/ansible/modules/extras/cloud/amazon/s3_lifecycle.py +++ b/lib/ansible/modules/extras/cloud/amazon/s3_lifecycle.py @@ -50,11 +50,6 @@ options: - "Prefix identifying one or more objects to which the rule applies. If no prefix is specified, the rule will apply to the whole bucket." required: false default: null - region: - description: - - "AWS region to create the bucket in. If not set then the value of the AWS_REGION and EC2_REGION environment variables are checked, followed by the aws_region and ec2_region settings in the Boto config file. If none of those are set the region defaults to the S3 Location: US Standard." - required: false - default: null rule_id: description: - "Unique identifier for the rule. The value cannot be longer than 255 characters. A unique value for the rule will be generated if no value is provided." @@ -89,8 +84,9 @@ options: - "Indicates when, in days, an object transitions to a different storage class. If transition_date is not specified, this parameter is required." required: false default: null - -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/s3_logging.py b/lib/ansible/modules/extras/cloud/amazon/s3_logging.py index 1ff918a50f..038cacbef5 100644 --- a/lib/ansible/modules/extras/cloud/amazon/s3_logging.py +++ b/lib/ansible/modules/extras/cloud/amazon/s3_logging.py @@ -30,11 +30,6 @@ options: description: - "Name of the s3 bucket." required: true - region: - description: - - "AWS region to create the bucket in. If not set then the value of the AWS_REGION and EC2_REGION environment variables are checked, followed by the aws_region and ec2_region settings in the Boto config file. If none of those are set the region defaults to the S3 Location: US Standard." - required: false - default: null state: description: - "Enable or disable logging." @@ -51,8 +46,9 @@ options: - "The prefix that should be prepended to the generated log files written to the target_bucket." required: false default: "" - -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/amazon/sns_topic.py b/lib/ansible/modules/extras/cloud/amazon/sns_topic.py index 18dd98a997..e2b31484a1 100644 --- a/lib/ansible/modules/extras/cloud/amazon/sns_topic.py +++ b/lib/ansible/modules/extras/cloud/amazon/sns_topic.py @@ -63,11 +63,11 @@ options: default: [] purge_subscriptions: description: - - Whether to purge any subscriptions not listed here. NOTE: AWS does not + - "Whether to purge any subscriptions not listed here. NOTE: AWS does not allow you to purge any PendingConfirmation subscriptions, so if any exist and would be purged, they are silently skipped. This means that somebody could come back later and confirm the subscription. Sorry. - Blame Amazon. + Blame Amazon." required: False default: True extends_documentation_fragment: aws diff --git a/lib/ansible/modules/extras/cloud/amazon/sts_assume_role.py b/lib/ansible/modules/extras/cloud/amazon/sts_assume_role.py index 67d6406d3b..d856947a7d 100644 --- a/lib/ansible/modules/extras/cloud/amazon/sts_assume_role.py +++ b/lib/ansible/modules/extras/cloud/amazon/sts_assume_role.py @@ -62,7 +62,9 @@ options: default: null notes: - In order to use the assumed role in a following playbook task you must pass the access_key, access_secret and access_token -extends_documentation_fragment: aws +extends_documentation_fragment: + - aws + - ec2 ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/cloud/azure/azure_rm_deployment.py b/lib/ansible/modules/extras/cloud/azure/azure_rm_deployment.py index 192222116b..88ecf0cea0 100644 --- a/lib/ansible/modules/extras/cloud/azure/azure_rm_deployment.py +++ b/lib/ansible/modules/extras/cloud/azure/azure_rm_deployment.py @@ -239,7 +239,7 @@ EXAMPLES = ''' imageOffer: "UbuntuServer" OSDiskName: "osdiskforlinuxsimple" nicName: "myVMNic" - addressPrefix: "10.0.0.0/16" + addressPrefix: "192.0.2.0/24" subnetName: "Subnet" subnetPrefix: "10.0.0.0/24" storageAccountType: "Standard_LRS" diff --git a/lib/ansible/modules/extras/cloud/centurylink/clc_alert_policy.py b/lib/ansible/modules/extras/cloud/centurylink/clc_alert_policy.py index 33531fbeff..6e8c461854 100644 --- a/lib/ansible/modules/extras/cloud/centurylink/clc_alert_policy.py +++ b/lib/ansible/modules/extras/cloud/centurylink/clc_alert_policy.py @@ -85,7 +85,7 @@ notes: - To use this module, it is required to set the below environment variables which enables access to the Centurylink Cloud - CLC_V2_API_USERNAME, the account login id for the centurylink cloud - - CLC_V2_API_PASSWORD, the account passwod for the centurylink cloud + - CLC_V2_API_PASSWORD, the account password for the centurylink cloud - Alternatively, the module accepts the API token and account alias. The API token can be generated using the CLC account login and password via the HTTP api call @ https://api.ctl.io/v2/authentication/login - CLC_V2_API_TOKEN, the API token generated from https://api.ctl.io/v2/authentication/login @@ -302,7 +302,7 @@ class ClcAlertPolicy: """ Ensures that the alert policy is present :return: (changed, policy) - canged: A flag representing if anything is modified + changed: A flag representing if anything is modified policy: the created/updated alert policy """ changed = False @@ -327,7 +327,7 @@ class ClcAlertPolicy: """ Ensures that the alert policy is absent :return: (changed, None) - canged: A flag representing if anything is modified + changed: A flag representing if anything is modified """ changed = False p = self.module.params @@ -349,10 +349,10 @@ class ClcAlertPolicy: def _ensure_alert_policy_is_updated(self, alert_policy): """ - Ensures the aliert policy is updated if anything is changed in the alert policy configuration - :param alert_policy: the targetalert policy + Ensures the alert policy is updated if anything is changed in the alert policy configuration + :param alert_policy: the target alert policy :return: (changed, policy) - canged: A flag representing if anything is modified + changed: A flag representing if anything is modified policy: the updated the alert policy """ changed = False diff --git a/lib/ansible/modules/extras/cloud/centurylink/clc_group.py b/lib/ansible/modules/extras/cloud/centurylink/clc_group.py index 3d81afdfa0..4c522b7b0b 100644 --- a/lib/ansible/modules/extras/cloud/centurylink/clc_group.py +++ b/lib/ansible/modules/extras/cloud/centurylink/clc_group.py @@ -28,7 +28,7 @@ module: clc_group short_description: Create/delete Server Groups at Centurylink Cloud description: - Create or delete Server Groups at Centurylink Centurylink Cloud -version_added: 1.0 +version_added: "2.0" options: name: description: @@ -70,8 +70,8 @@ notes: - CLC_V2_API_PASSWORD, the account password for the centurylink cloud - Alternatively, the module accepts the API token and account alias. The API token can be generated using the CLC account login and password via the HTTP api call @ https://api.ctl.io/v2/authentication/login - - CLC_V2_API_TOKEN: the API token generated from https://api.ctl.io/v2/authentication/login - - CLC_ACCT_ALIAS: the account alias associated with the centurylink cloud + - CLC_V2_API_TOKEN, the API token generated from https://api.ctl.io/v2/authentication/login + - CLC_ACCT_ALIAS, the account alias associated with the centurylink cloud - Users can set CLC_V2_API_URL to specify an endpoint for pointing to a different CLC environment. ''' diff --git a/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py b/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py index 12e68107bf..a53aeb7953 100644 --- a/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py +++ b/lib/ansible/modules/extras/cloud/centurylink/clc_publicip.py @@ -28,7 +28,7 @@ module: clc_publicip short_description: Add and Delete public ips on servers in CenturyLink Cloud. description: - An Ansible module to add or delete public ip addresses on an existing server or servers in CenturyLink Cloud. -version_added: 1.0 +version_added: "2.0" options: protocol: description: @@ -70,8 +70,8 @@ notes: - CLC_V2_API_PASSWORD, the account password for the centurylink cloud - Alternatively, the module accepts the API token and account alias. The API token can be generated using the CLC account login and password via the HTTP api call @ https://api.ctl.io/v2/authentication/login - - CLC_V2_API_TOKEN: the API token generated from https://api.ctl.io/v2/authentication/login - - CLC_ACCT_ALIAS: the account alias associated with the centurylink cloud + - CLC_V2_API_TOKEN, the API token generated from https://api.ctl.io/v2/authentication/login + - CLC_ACCT_ALIAS, the account alias associated with the centurylink cloud - Users can set CLC_V2_API_URL to specify an endpoint for pointing to a different CLC environment. ''' diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_account.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_account.py index a16599bdcc..0074ad29ca 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_account.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_account.py @@ -374,7 +374,7 @@ def main(): result = acs_acc.get_result(account) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py index e36db10ad4..a9c71c42b0 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_affinitygroup.py @@ -26,7 +26,8 @@ DOCUMENTATION = ''' --- module: cs_affinitygroup short_description: Manages affinity groups on Apache CloudStack based clouds. -description: Create and remove affinity groups. +description: + - Create and remove affinity groups. version_added: '2.0' author: "René Moser (@resmo)" options: @@ -60,6 +61,11 @@ options: - Account the affinity group is related to. required: false default: null + project: + description: + - Name of the project the affinity group is related to. + required: false + default: null poll_async: description: - Poll async jobs until job has finished. @@ -104,6 +110,21 @@ affinity_type: returned: success type: string sample: host anti-affinity +project: + description: Name of project the affinity group is related to. + returned: success + type: string + sample: Production +domain: + description: Domain the affinity group is related to. + returned: success + type: string + sample: example domain +account: + description: Account the affinity group is related to. + returned: success + type: string + sample: example account ''' # import cloudstack common @@ -223,7 +244,7 @@ def main(): result = acs_ag.get_result(affinity_group) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_domain.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_domain.py index ac3eb115f7..35e32aa066 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_domain.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_domain.py @@ -242,8 +242,8 @@ def main(): path = dict(required=True), state = dict(choices=['present', 'absent'], default='present'), network_domain = dict(default=None), - clean_up = dict(choices=BOOLEANS, default=False), - poll_async = dict(choices=BOOLEANS, default=True), + clean_up = dict(type='bool', default=False), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -263,7 +263,7 @@ def main(): result = acs_dom.get_result(domain) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_firewall.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_firewall.py index 3654ba5ac6..160e58d472 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_firewall.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_firewall.py @@ -26,7 +26,8 @@ DOCUMENTATION = ''' --- module: cs_firewall short_description: Manages firewall rules on Apache CloudStack based clouds. -description: Creates and removes firewall rules. +description: + - Creates and removes firewall rules. version_added: '2.0' author: "René Moser (@resmo)" options: @@ -102,6 +103,12 @@ options: - Name of the project the firewall rule is related to. required: false default: null + zone: + description: + - Name of the zone in which the virtual machine is in. + - If not set, default zone is used. + required: false + default: null poll_async: description: - Poll async jobs until job has finished. @@ -378,10 +385,11 @@ def main(): start_port = dict(type='int', aliases=['port'], default=None), end_port = dict(type='int', default=None), state = dict(choices=['present', 'absent'], default='present'), + zone = dict(default=None), domain = dict(default=None), account = dict(default=None), project = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) required_together = cs_required_together() @@ -414,7 +422,7 @@ def main(): result = acs_fw.get_result(fw_rule) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_instance.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_instance.py index e63384112f..58c9872485 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_instance.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_instance.py @@ -53,7 +53,6 @@ options: state: description: - State of the instance. - - C(restored) added in version 2.1. required: false default: 'present' choices: [ 'deployed', 'started', 'stopped', 'restarted', 'restored', 'destroyed', 'expunged', 'present', 'absent' ] @@ -212,7 +211,7 @@ options: tags: description: - List of tags. Tags are a list of dictionaries having keys C(key) and C(value). - - If you want to delete all tags, set a empty list e.g. C(tags: []). + - "If you want to delete all tags, set a empty list e.g. C(tags: [])." required: false default: null aliases: [ 'tag' ] @@ -899,12 +898,15 @@ class AnsibleCloudStackInstance(AnsibleCloudStack): def restore_instance(self): instance = self.get_instance() - - if not instance: - instance = self.deploy_instance() - return instance - self.result['changed'] = True + # in check mode intance may not be instanciated + if instance: + args = {} + args['templateid'] = self.get_template_or_iso(key='id') + args['virtualmachineid'] = instance['id'] + res = self.cs.restoreVirtualMachine(**args) + if 'errortext' in res: + self.module.fail_json(msg="Failed: '%s'" % res['errortext']) poll_async = self.module.params.get('poll_async') if poll_async: @@ -963,7 +965,7 @@ def main(): user_data = dict(default=None), zone = dict(default=None), ssh_key = dict(default=None), - force = dict(choices=BOOLEANS, default=False), + force = dict(type='bool', default=False), tags = dict(type='list', aliases=[ 'tag' ], default=None), vpc = dict(default=None), poll_async = dict(type='bool', default=True), @@ -998,6 +1000,7 @@ def main(): instance = acs_instance.expunge_instance() elif state in ['restored']: + acs_instance.present_instance() instance = acs_instance.restore_instance() elif state in ['present', 'deployed']: @@ -1020,7 +1023,7 @@ def main(): result = acs_instance.get_result(instance) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_instancegroup.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_instancegroup.py index ed5396341a..12b2bc7bae 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_instancegroup.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_instancegroup.py @@ -194,7 +194,7 @@ def main(): result = acs_ig.get_result(instance_group) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py index 33956ca0e5..233720827f 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py @@ -70,7 +70,7 @@ options: default: null zone: description: - - Name of the zone in which the virtual machine is in. + - Name of the zone in which the IP address is in. - If not set, default zone is used. required: false default: null @@ -88,7 +88,7 @@ EXAMPLES = ''' module: cs_ip_address network: My Network register: ip_address - when: create_instance|changed + when: instance.public_ip is undefined # Disassociate an IP address - local_action: @@ -210,7 +210,7 @@ def main(): domain = dict(default=None), account = dict(default=None), project = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -233,7 +233,7 @@ def main(): result = acs_ip_address.get_result(ip_address) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_iso.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_iso.py index 038552f5da..ee84bd22f2 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_iso.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_iso.py @@ -304,10 +304,10 @@ def main(): account = dict(default=None), project = dict(default=None), checksum = dict(default=None), - is_ready = dict(choices=BOOLEANS, default=False), - bootable = dict(choices=BOOLEANS, default=True), - is_featured = dict(choices=BOOLEANS, default=False), - is_dynamically_scalable = dict(choices=BOOLEANS, default=False), + is_ready = dict(type='bool', default=False), + bootable = dict(type='bool', default=True), + is_featured = dict(type='bool', default=False), + is_dynamically_scalable = dict(type='bool', default=False), state = dict(choices=['present', 'absent'], default='present'), )) @@ -328,7 +328,7 @@ def main(): result = acs_iso.get_result(iso) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule.py index 9b768f3d2b..2e5f11e415 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule.py @@ -348,12 +348,12 @@ def main(): ip_address = dict(required=True, aliases=['public_ip']), cidr = dict(default=None), project = dict(default=None), - open_firewall = dict(choices=BOOLEANS, default=False), + open_firewall = dict(type='bool', default=False), tags = dict(type='list', aliases=['tag'], default=None), zone = dict(default=None), domain = dict(default=None), account = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -373,7 +373,7 @@ def main(): result = acs_lb_rule.get_result(rule) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule_member.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule_member.py index 5944aef6f7..0695ed9be5 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule_member.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_loadbalancer_rule_member.py @@ -333,7 +333,7 @@ def main(): domain = dict(default=None), project = dict(default=None), account = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -353,7 +353,7 @@ def main(): result = acs_lb_rule_member.get_result(rule) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_network.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_network.py index e258d44cb3..092fbf7326 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_network.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_network.py @@ -517,14 +517,14 @@ def main(): vlan = dict(default=None), vpc = dict(default=None), isolated_pvlan = dict(default=None), - clean_up = dict(type='bool', choices=BOOLEANS, default=False), + clean_up = dict(type='bool', default=False), network_domain = dict(default=None), state = dict(choices=['present', 'absent', 'restarted' ], default='present'), acl_type = dict(choices=['account', 'domain'], default='account'), project = dict(default=None), domain = dict(default=None), account = dict(default=None), - poll_async = dict(type='bool', choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) required_together = cs_required_together() required_together.extend([ @@ -553,7 +553,7 @@ def main(): result = acs_network.get_result(network) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_portforward.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_portforward.py index 1ae0472d91..139fa7773d 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_portforward.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_portforward.py @@ -53,21 +53,21 @@ options: required: false default: 'tcp' choices: [ 'tcp', 'udp' ] - public_port + public_port: description: - Start public port for this rule. required: true - public_end_port + public_end_port: description: - End public port for this rule. - If not specified equal C(public_port). required: false default: null - private_port + private_port: description: - Start private port for this rule. required: true - private_end_port + private_end_port: description: - End private port for this rule. - If not specified equal C(private_port). @@ -350,14 +350,14 @@ def main(): private_port = dict(type='int', required=True), private_end_port = dict(type='int', default=None), state = dict(choices=['present', 'absent'], default='present'), - open_firewall = dict(choices=BOOLEANS, default=False), + open_firewall = dict(type='bool', default=False), vm_guest_ip = dict(default=None), vm = dict(default=None), zone = dict(default=None), domain = dict(default=None), account = dict(default=None), project = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -376,7 +376,7 @@ def main(): result = acs_pf.get_result(pf_rule) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_project.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_project.py index d2271b3681..472762b432 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_project.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_project.py @@ -300,7 +300,7 @@ def main(): result = acs_project.get_result(project) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup.py index 4a3b49dead..c65d63c8f4 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup.py @@ -23,9 +23,11 @@ ANSIBLE_METADATA = {'status': ['stableinterface'], 'version': '1.0'} DOCUMENTATION = ''' +--- module: cs_securitygroup short_description: Manages security groups on Apache CloudStack based clouds. -description: Create and remove security groups. +description: + - Create and remove security groups. version_added: '2.0' author: "René Moser (@resmo)" options: @@ -210,7 +212,7 @@ def main(): result = acs_sg.get_result(sg) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup_rule.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup_rule.py index 7b3a544e79..85617b5baa 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup_rule.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_securitygroup_rule.py @@ -26,7 +26,8 @@ DOCUMENTATION = ''' --- module: cs_securitygroup_rule short_description: Manages security group rules on Apache CloudStack based clouds. -description: Add and remove security group rules. +description: + - Add and remove security group rules. version_added: '2.0' author: "René Moser (@resmo)" options: @@ -383,7 +384,7 @@ def main(): end_port = dict(type='int', default=None), state = dict(choices=['present', 'absent'], default='present'), project = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) required_together = cs_required_together() required_together.extend([ @@ -413,7 +414,7 @@ def main(): result = acs_sg_rule.get_result(sg_rule) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_sshkeypair.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_sshkeypair.py index 066fcfbc18..2724c58c71 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_sshkeypair.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_sshkeypair.py @@ -244,7 +244,7 @@ def main(): result = acs_sshkey.get_result(ssh_key) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_staticnat.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_staticnat.py index 20e4407f19..a805a1c8bb 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_staticnat.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_staticnat.py @@ -251,7 +251,7 @@ def main(): domain = dict(default=None), account = dict(default=None), project = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -271,7 +271,7 @@ def main(): result = acs_static_nat.get_result(ip_address) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py index 4a544a3089..7e6d74e9c6 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py @@ -605,19 +605,19 @@ def main(): vm = dict(default=None), snapshot = dict(default=None), os_type = dict(default=None), - is_ready = dict(type='bool', choices=BOOLEANS, default=False), - is_public = dict(type='bool', choices=BOOLEANS, default=True), - is_featured = dict(type='bool', choices=BOOLEANS, default=False), - is_dynamically_scalable = dict(type='bool', choices=BOOLEANS, default=False), - is_extractable = dict(type='bool', choices=BOOLEANS, default=False), - is_routing = dict(type='bool', choices=BOOLEANS, default=False), + is_ready = dict(type='bool', default=False), + is_public = dict(type='bool', default=True), + is_featured = dict(type='bool', default=False), + is_dynamically_scalable = dict(type='bool', default=False), + is_extractable = dict(type='bool', default=False), + is_routing = dict(type='bool', default=False), checksum = dict(default=None), template_filter = dict(default='self', choices=['featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community']), hypervisor = dict(choices=CS_HYPERVISORS, default=None), requires_hvm = dict(type='bool', default=False), password_enabled = dict(type='bool', default=False), template_tag = dict(default=None), - sshkey_enabled = dict(type='bool', choices=BOOLEANS, default=False), + sshkey_enabled = dict(type='bool', default=False), format = dict(choices=['QCOW2', 'RAW', 'VHD', 'OVA'], default=None), details = dict(default=None), bits = dict(type='int', choices=[ 32, 64 ], default=64), @@ -628,7 +628,7 @@ def main(): domain = dict(default=None), account = dict(default=None), project = dict(default=None), - poll_async = dict(type='bool', choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -661,7 +661,7 @@ def main(): result = acs_tpl.get_result(tpl) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_user.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_user.py index 5ab6190a23..f9f43322e4 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_user.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_user.py @@ -413,7 +413,7 @@ def main(): last_name = dict(default=None), password = dict(default=None, no_log=True), timezone = dict(default=None), - poll_async = dict(choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) module = AnsibleModule( @@ -444,7 +444,7 @@ def main(): result = acs_acc.get_result(user) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_vmsnapshot.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_vmsnapshot.py index 2479253b59..e3b43820a5 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_vmsnapshot.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_vmsnapshot.py @@ -26,7 +26,8 @@ DOCUMENTATION = ''' --- module: cs_vmsnapshot short_description: Manages VM snapshots on Apache CloudStack based clouds. -description: Create, remove and revert VM from snapshots. +description: + - Create, remove and revert VM from snapshots. version_added: '2.0' author: "René Moser (@resmo)" options: @@ -260,12 +261,12 @@ def main(): vm = dict(required=True), description = dict(default=None), zone = dict(default=None), - snapshot_memory = dict(choices=BOOLEANS, default=False), + snapshot_memory = dict(type='bool', default=False), state = dict(choices=['present', 'absent', 'revert'], default='present'), domain = dict(default=None), account = dict(default=None), project = dict(default=None), - poll_async = dict(type='bool', choices=BOOLEANS, default=True), + poll_async = dict(type='bool', default=True), )) required_together = cs_required_together() @@ -292,7 +293,7 @@ def main(): result = acs_vmsnapshot.get_result(snapshot) - except CloudStackException, e: + except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_volume.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_volume.py index f812a1249c..36071e0d78 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_volume.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_volume.py @@ -258,10 +258,8 @@ class AnsibleCloudStackVolume(AnsibleCloudStack): if not disk_offering: return None - args = {} - args['domainid'] = self.get_domain(key='id') - - disk_offerings = self.cs.listDiskOfferings(**args) + # Do not add domain filter for disk offering listing. + disk_offerings = self.cs.listDiskOfferings() if disk_offerings: for d in disk_offerings['diskoffering']: if disk_offering in [d['displaytext'], d['name'], d['id']]: diff --git a/lib/ansible/modules/extras/cloud/google/gcdns_record.py b/lib/ansible/modules/extras/cloud/google/gcdns_record.py index 72fa1e89b0..7c209c5cba 100644 --- a/lib/ansible/modules/extras/cloud/google/gcdns_record.py +++ b/lib/ansible/modules/extras/cloud/google/gcdns_record.py @@ -199,8 +199,8 @@ EXAMPLES = ''' record_data: - '192.0.2.23' - '10.4.5.6' - - '10.7.8.9' - - '192.168.5.10' + - '198.51.100.5' + - '203.0.113.10' # Change the value of an existing record with multiple record_data. - gcdns_record: diff --git a/lib/ansible/modules/extras/cloud/misc/ovirt.py b/lib/ansible/modules/extras/cloud/misc/ovirt.py index d4b6b241f3..af89998258 100644 --- a/lib/ansible/modules/extras/cloud/misc/ovirt.py +++ b/lib/ansible/modules/extras/cloud/misc/ovirt.py @@ -260,9 +260,9 @@ ovirt: url: https://ovirt.example.com hostname: testansible domain: ansible.local - ip: 192.168.1.100 + ip: 192.0.2.100 netmask: 255.255.255.0 - gateway: 192.168.1.1 + gateway: 192.0.2.1 rootpw: bigsecret ''' diff --git a/lib/ansible/modules/extras/cloud/misc/rhevm.py b/lib/ansible/modules/extras/cloud/misc/rhevm.py index b757aeeaff..8789e88028 100644 --- a/lib/ansible/modules/extras/cloud/misc/rhevm.py +++ b/lib/ansible/modules/extras/cloud/misc/rhevm.py @@ -175,9 +175,9 @@ vm: "size": 40 } ], - "eth0": "00:1b:4a:1f:de:f4", - "eth1": "00:1b:4a:1f:de:f5", - "eth2": "00:1b:4a:1f:de:f6", + "eth0": "00:00:5E:00:53:00", + "eth1": "00:00:5E:00:53:01", + "eth2": "00:00:5E:00:53:02", "exists": true, "failed": false, "ifaces": [ diff --git a/lib/ansible/modules/extras/cloud/misc/virt_pool.py b/lib/ansible/modules/extras/cloud/misc/virt_pool.py index a50e12710f..f9a7ba4913 100644 --- a/lib/ansible/modules/extras/cloud/misc/virt_pool.py +++ b/lib/ansible/modules/extras/cloud/misc/virt_pool.py @@ -234,12 +234,6 @@ class LibvirtConnection(object): self.module = module - cmd = "uname -r" - rc, stdout, stderr = self.module.run_command(cmd) - - if "xen" in stdout: - conn = libvirt.open(None) - else: conn = libvirt.open(uri) if not conn: @@ -253,14 +247,12 @@ class LibvirtConnection(object): results = [] # Get active entries - entries = self.conn.listStoragePools() - for name in entries: + for name in self.conn.listStoragePools(): entry = self.conn.storagePoolLookupByName(name) results.append(entry) # Get inactive entries - entries = self.conn.listDefinedStoragePools() - for name in entries: + for name in self.conn.listDefinedStoragePools(): entry = self.conn.storagePoolLookupByName(name) results.append(entry) @@ -445,24 +437,18 @@ class VirtStoragePool(object): return self.conn.find_entry(entryid) def list_pools(self, state=None): - entries = self.conn.find_entry(-1) results = [] - for x in entries: - try: + for entry in self.conn.find_entry(-1): if state: - entrystate = self.conn.get_status2(x) - if entrystate == state: - results.append(x.name()) + if state == self.conn.get_status2(entry): + results.append(entry.name()) else: - results.append(x.name()) - except: - pass + results.append(entry.name()) return results def state(self): - entries = self.list_pools() results = [] - for entry in entries: + for entry in self.list_pools(): state_blurb = self.conn.get_status(entry) results.append("%s %s" % (entry,state_blurb)) return results @@ -509,13 +495,12 @@ class VirtStoragePool(object): def refresh(self, entryid): return self.conn.refresh(entryid) - def info(self, facts_mode='info'): - return self.facts(facts_mode) + def info(self): + return self.facts(facts_mode='info') def facts(self, facts_mode='facts'): - entries = self.list_pools() results = dict() - for entry in entries: + for entry in self.list_pools(): results[entry] = dict() if self.conn.find_entry(entry): data = self.conn.get_info(entry) diff --git a/lib/ansible/modules/extras/cloud/openstack/os_port_facts.py b/lib/ansible/modules/extras/cloud/openstack/os_port_facts.py index a7b995582a..0da37d88ef 100644 --- a/lib/ansible/modules/extras/cloud/openstack/os_port_facts.py +++ b/lib/ansible/modules/extras/cloud/openstack/os_port_facts.py @@ -166,7 +166,7 @@ openstack_ports: description: The MAC address. returned: success type: string - sample: "fa:16:30:5f:10:f1" + sample: "00:00:5E:00:53:42" name: description: The port name. returned: success diff --git a/lib/ansible/modules/extras/cloud/ovh/ovh_ip_loadbalancing_backend.py b/lib/ansible/modules/extras/cloud/ovh/ovh_ip_loadbalancing_backend.py index cda220b71f..3499e73a92 100644 --- a/lib/ansible/modules/extras/cloud/ovh/ovh_ip_loadbalancing_backend.py +++ b/lib/ansible/modules/extras/cloud/ovh/ovh_ip_loadbalancing_backend.py @@ -155,9 +155,9 @@ def main(): choices=['none', 'http', 'icmp', 'oco']), state=dict(default='present', choices=['present', 'absent']), endpoint=dict(required=True), - application_key=dict(required=True), - application_secret=dict(required=True), - consumer_key=dict(required=True), + application_key=dict(required=True, no_log=True), + application_secret=dict(required=True, no_log=True), + consumer_key=dict(required=True, no_log=True), timeout=dict(default=120, type='int') ) ) diff --git a/lib/ansible/modules/extras/cloud/rackspace/rax_mon_entity.py b/lib/ansible/modules/extras/cloud/rackspace/rax_mon_entity.py index 93a568b676..fae5830965 100644 --- a/lib/ansible/modules/extras/cloud/rackspace/rax_mon_entity.py +++ b/lib/ansible/modules/extras/cloud/rackspace/rax_mon_entity.py @@ -72,8 +72,8 @@ EXAMPLES = ''' state: present label: my_entity named_ip_addresses: - web_box: 192.168.0.10 - db_box: 192.168.0.11 + web_box: 192.0.2.4 + db_box: 192.0.2.5 meta: hurf: durf register: the_entity diff --git a/lib/ansible/modules/extras/cloud/vmware/vca_fw.py b/lib/ansible/modules/extras/cloud/vmware/vca_fw.py index ef35eaeec8..78cebbb012 100644 --- a/lib/ansible/modules/extras/cloud/vmware/vca_fw.py +++ b/lib/ansible/modules/extras/cloud/vmware/vca_fw.py @@ -2,17 +2,21 @@ # Copyright (c) 2015 VMware, Inc. All Rights Reserved. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# This file is part of Ansible # -# http://www.apache.org/licenses/LICENSE-2.0 +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', @@ -28,7 +32,6 @@ version_added: "2.0" author: Peter Sprygada (@privateip) options: fw_rules: - version_added: "2.0" description: - A list of firewall rules to be added to the gateway, Please see examples on valid entries required: True @@ -50,12 +53,12 @@ EXAMPLES = ''' fw_rules: - description: "ben testing" source_ip: "Any" - dest_ip: 192.168.2.11 + dest_ip: 192.0.2.23 - description: "ben testing 2" - source_ip: 192.168.2.100 + source_ip: 192.0.2.50 source_port: "Any" dest_port: "22" - dest_ip: 192.168.2.13 + dest_ip: 192.0.2.101 is_enable: "true" enable_logging: "false" protocol: "Tcp" diff --git a/lib/ansible/modules/extras/cloud/vmware/vca_nat.py b/lib/ansible/modules/extras/cloud/vmware/vca_nat.py index 5ac3f745e5..64771da692 100644 --- a/lib/ansible/modules/extras/cloud/vmware/vca_nat.py +++ b/lib/ansible/modules/extras/cloud/vmware/vca_nat.py @@ -57,8 +57,8 @@ EXAMPLES = ''' state: 'present' nat_rules: - rule_type: SNAT - original_ip: 192.168.2.10 - translated_ip: 107.189.95.208 + original_ip: 192.0.2.42 + translated_ip: 203.0.113.23 #example for a DNAT - hosts: localhost @@ -70,9 +70,9 @@ EXAMPLES = ''' state: 'present' nat_rules: - rule_type: DNAT - original_ip: 107.189.95.208 + original_ip: 203.0.113.23 original_port: 22 - translated_ip: 192.168.2.10 + translated_ip: 192.0.2.42 translated_port: 22 ''' diff --git a/lib/ansible/modules/extras/cloud/vmware/vmware_guest.py b/lib/ansible/modules/extras/cloud/vmware/vmware_guest.py index 51751a53b4..b4843a14bd 100644 --- a/lib/ansible/modules/extras/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/extras/cloud/vmware/vmware_guest.py @@ -139,7 +139,7 @@ Example from Ansible playbook - name: create the VM vmware_guest: validate_certs: False - hostname: 192.168.1.209 + hostname: 192.0.2.44 username: administrator@vsphere.local password: vmware name: testvm_2 @@ -159,7 +159,7 @@ Example from Ansible playbook osid: centos64guest scsi: paravirtual datacenter: datacenter1 - esxi_hostname: 192.168.1.117 + esxi_hostname: 192.0.2.117 template: template_el7 wait_for_ip_address: yes register: deploy @@ -536,11 +536,8 @@ class PyVmomiHelper(object): if current_state == expected_state: result['changed'] = False result['failed'] = False - else: - task = None - try: if expected_state == 'poweredoff': task = vm.PowerOff() @@ -597,9 +594,6 @@ class PyVmomiHelper(object): mac = device.macAddress ips = list(device.ipAddress) netDict[mac] = ips - #facts['network'] = {} - #facts['network']['ipaddress_v4'] = None - #facts['network']['ipaddress_v6'] = None for k,v in netDict.iteritems(): for ipaddress in v: if ipaddress: @@ -609,7 +603,6 @@ class PyVmomiHelper(object): facts['ipv4'] = ipaddress for idx,entry in enumerate(vm.config.hardware.device): - if not hasattr(entry, 'macAddress'): continue @@ -624,7 +617,6 @@ class PyVmomiHelper(object): } facts['hw_interfaces'].append('eth'+str(idx)) - #import epdb; epdb.st() return facts diff --git a/lib/ansible/modules/extras/database/misc/mongodb_user.py b/lib/ansible/modules/extras/database/misc/mongodb_user.py index 02bf22627f..7fbcf33226 100644 --- a/lib/ansible/modules/extras/database/misc/mongodb_user.py +++ b/lib/ansible/modules/extras/database/misc/mongodb_user.py @@ -51,6 +51,12 @@ options: - The port to connect to required: false default: 27017 + login_database: + version_added: "2.0" + description: + - The database where login credentials are stored + required: false + default: null replica_set: version_added: "1.6" description: @@ -336,6 +342,7 @@ def main(): login_password=dict(default=None), login_host=dict(default='localhost'), login_port=dict(default='27017'), + login_database=dict(default=None), replica_set=dict(default=None), database=dict(required=True, aliases=['db']), name=dict(required=True, aliases=['user']), @@ -396,7 +403,7 @@ def main(): module.fail_json(msg='when supplying login arguments, both login_user and login_password must be provided') if login_user is not None and login_password is not None: - client.admin.authenticate(login_user, login_password) + client.admin.authenticate(login_user, login_password, source=login_database) elif LooseVersion(PyMongoVersion) >= LooseVersion('3.0'): if db_name != "admin": module.fail_json(msg='The localhost login exception only allows the first admin account to be created') diff --git a/lib/ansible/modules/extras/database/misc/redis.py b/lib/ansible/modules/extras/database/misc/redis.py index 6ad225e995..f99d025742 100644 --- a/lib/ansible/modules/extras/database/misc/redis.py +++ b/lib/ansible/modules/extras/database/misc/redis.py @@ -102,7 +102,7 @@ notes: this needs to be in the redis.conf in the masterauth variable requirements: [ redis ] -author: Xabier Larrakoetxea +author: "Xabier Larrakoetxea (@slok)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/database/mysql/mysql_replication.py b/lib/ansible/modules/extras/database/mysql/mysql_replication.py index d4ba8d0cee..76bcdc16c4 100644 --- a/lib/ansible/modules/extras/database/mysql/mysql_replication.py +++ b/lib/ansible/modules/extras/database/mysql/mysql_replication.py @@ -79,7 +79,7 @@ options: master_ssl: description: - same as mysql variable - possible values: 0,1 + choices: [ 0, 1 ] master_ssl_ca: description: - same as mysql variable @@ -96,7 +96,7 @@ options: description: - same as mysql variable master_auto_position: - descrtiption: + description: - does the host uses GTID based replication or not required: false default: null diff --git a/lib/ansible/modules/extras/database/postgresql/postgresql_ext.py b/lib/ansible/modules/extras/database/postgresql/postgresql_ext.py index 4f0049f566..09b2903dab 100644 --- a/lib/ansible/modules/extras/database/postgresql/postgresql_ext.py +++ b/lib/ansible/modules/extras/database/postgresql/postgresql_ext.py @@ -69,7 +69,7 @@ notes: - This module uses I(psycopg2), a Python PostgreSQL database adapter. You must ensure that psycopg2 is installed on the host before using this module. If the remote host is the PostgreSQL server (which is the default case), then PostgreSQL must also be installed on the remote host. For Ubuntu-based systems, install the C(postgresql), C(libpq-dev), and C(python-psycopg2) packages on the remote host before using this module. requirements: [ psycopg2 ] -author: Daniel Schep +author: "Daniel Schep (@dschep)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/database/postgresql/postgresql_lang.py b/lib/ansible/modules/extras/database/postgresql/postgresql_lang.py index 0028442c2b..1a868bf67a 100644 --- a/lib/ansible/modules/extras/database/postgresql/postgresql_lang.py +++ b/lib/ansible/modules/extras/database/postgresql/postgresql_lang.py @@ -113,7 +113,7 @@ notes: systems, install the postgresql, libpq-dev, and python-psycopg2 packages on the remote host before using this module. requirements: [ psycopg2 ] -author: Jens Depuydt +author: "Jens Depuydt (@jensdepuydt)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/database/vertica/vertica_configuration.py b/lib/ansible/modules/extras/database/vertica/vertica_configuration.py index 779417cab3..c99627a021 100644 --- a/lib/ansible/modules/extras/database/vertica/vertica_configuration.py +++ b/lib/ansible/modules/extras/database/vertica/vertica_configuration.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = """ --- module: vertica_configuration -version_added: '1.0' +version_added: '2.0' short_description: Updates Vertica configuration parameters. description: - Updates Vertica configuration parameters. @@ -71,7 +71,7 @@ notes: and both C(ErrorMessagesPath = /opt/vertica/lib64) and C(DriverManagerEncoding = UTF-16) to be added to the C(Driver) section of either C(/etc/vertica.ini) or C($HOME/.vertica.ini). requirements: [ 'unixODBC', 'pyodbc' ] -author: Dariusz Owczarek +author: "Dariusz Owczarek (@dareko)" """ EXAMPLES = """ diff --git a/lib/ansible/modules/extras/database/vertica/vertica_facts.py b/lib/ansible/modules/extras/database/vertica/vertica_facts.py index 1843e9495b..4796a53612 100644 --- a/lib/ansible/modules/extras/database/vertica/vertica_facts.py +++ b/lib/ansible/modules/extras/database/vertica/vertica_facts.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = """ --- module: vertica_facts -version_added: '1.0' +version_added: '2.0' short_description: Gathers Vertica database facts. description: - Gathers Vertica database facts. @@ -63,7 +63,7 @@ notes: and both C(ErrorMessagesPath = /opt/vertica/lib64) and C(DriverManagerEncoding = UTF-16) to be added to the C(Driver) section of either C(/etc/vertica.ini) or C($HOME/.vertica.ini). requirements: [ 'unixODBC', 'pyodbc' ] -author: Dariusz Owczarek +author: "Dariusz Owczarek (@dareko)" """ EXAMPLES = """ diff --git a/lib/ansible/modules/extras/database/vertica/vertica_role.py b/lib/ansible/modules/extras/database/vertica/vertica_role.py index ffd91fbd85..aff14581a3 100644 --- a/lib/ansible/modules/extras/database/vertica/vertica_role.py +++ b/lib/ansible/modules/extras/database/vertica/vertica_role.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = """ --- module: vertica_role -version_added: '1.0' +version_added: '2.0' short_description: Adds or removes Vertica database roles and assigns roles to them. description: - Adds or removes Vertica database role and, optionally, assign other roles. @@ -79,7 +79,7 @@ notes: and both C(ErrorMessagesPath = /opt/vertica/lib64) and C(DriverManagerEncoding = UTF-16) to be added to the C(Driver) section of either C(/etc/vertica.ini) or C($HOME/.vertica.ini). requirements: [ 'unixODBC', 'pyodbc' ] -author: Dariusz Owczarek +author: "Dariusz Owczarek (@dareko)" """ EXAMPLES = """ diff --git a/lib/ansible/modules/extras/database/vertica/vertica_schema.py b/lib/ansible/modules/extras/database/vertica/vertica_schema.py index d1aa32495d..0bc1918d31 100644 --- a/lib/ansible/modules/extras/database/vertica/vertica_schema.py +++ b/lib/ansible/modules/extras/database/vertica/vertica_schema.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = """ --- module: vertica_schema -version_added: '1.0' +version_added: '2.0' short_description: Adds or removes Vertica database schema and roles. description: - Adds or removes Vertica database schema and, optionally, roles @@ -95,7 +95,7 @@ notes: and both C(ErrorMessagesPath = /opt/vertica/lib64) and C(DriverManagerEncoding = UTF-16) to be added to the C(Driver) section of either C(/etc/vertica.ini) or C($HOME/.vertica.ini). requirements: [ 'unixODBC', 'pyodbc' ] -author: Dariusz Owczarek +author: "Dariusz Owczarek (@dareko)" """ EXAMPLES = """ diff --git a/lib/ansible/modules/extras/database/vertica/vertica_user.py b/lib/ansible/modules/extras/database/vertica/vertica_user.py index e743c8889e..48d20c0f6d 100644 --- a/lib/ansible/modules/extras/database/vertica/vertica_user.py +++ b/lib/ansible/modules/extras/database/vertica/vertica_user.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = """ --- module: vertica_user -version_added: '1.0' +version_added: '2.0' short_description: Adds or removes Vertica database users and assigns roles. description: - Adds or removes Vertica database user and, optionally, assigns roles. @@ -111,7 +111,7 @@ notes: and both C(ErrorMessagesPath = /opt/vertica/lib64) and C(DriverManagerEncoding = UTF-16) to be added to the C(Driver) section of either C(/etc/vertica.ini) or C($HOME/.vertica.ini). requirements: [ 'unixODBC', 'pyodbc' ] -author: Dariusz Owczarek +author: "Dariusz Owczarek (@dareko)" """ EXAMPLES = """ diff --git a/lib/ansible/modules/extras/files/blockinfile.py b/lib/ansible/modules/extras/files/blockinfile.py index 0d83a447c9..ec85c07882 100755 --- a/lib/ansible/modules/extras/files/blockinfile.py +++ b/lib/ansible/modules/extras/files/blockinfile.py @@ -120,7 +120,7 @@ EXAMPLES = r""" dest: /etc/network/interfaces block: | iface eth0 inet static - address 192.168.0.1 + address 192.0.2.23 netmask 255.255.255.0 - name: insert/update HTML surrounded by custom markers after line diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py b/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py index 03db81d386..a5e1e353da 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py @@ -1,10 +1,30 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2015, Manuel Sousa +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' +--- module: rabbitmq_exchange author: "Manuel Sousa (@manuel-sousa)" version_added: "2.0" @@ -56,14 +76,14 @@ options: required: false choices: [ "yes", "no" ] default: yes - exchangeType: + exchange_type: description: - type for the exchange required: false choices: [ "fanout", "direct", "headers", "topic" ] aliases: [ "type" ] default: direct - autoDelete: + auto_delete: description: - if the exchange should delete itself after all queues/exchanges unbound from it required: false @@ -104,7 +124,7 @@ def main(): state = dict(default='present', choices=['present', 'absent'], type='str'), name = dict(required=True, type='str'), login_user = dict(default='guest', type='str'), - login_password = dict(default='guest', type='str'), + login_password = dict(default='guest', type='str', no_log=True), login_host = dict(default='localhost', type='str'), login_port = dict(default='15672', type='str'), vhost = dict(default='/', type='str'), @@ -121,7 +141,7 @@ def main(): module.params['login_host'], module.params['login_port'], urllib.quote(module.params['vhost'],''), - module.params['name'] + urllib.quote(module.params['name'],'') ) # Check if exchange already exists @@ -145,12 +165,12 @@ def main(): change_required = exchange_exists # Check if attributes change on existing exchange - if not changeRequired and r.status_code==200 and module.params['state'] == 'present': + if not change_required and r.status_code==200 and module.params['state'] == 'present': if not ( response['durable'] == module.params['durable'] and - response['auto_delete'] == module.params['autoDelete'] and + response['auto_delete'] == module.params['auto_delete'] and response['internal'] == module.params['internal'] and - response['type'] == module.params['exchangeType'] + response['type'] == module.params['exchange_type'] ): module.fail_json( msg = "RabbitMQ RESTAPI doesn't support attribute changes for existing exchanges" @@ -159,15 +179,14 @@ def main(): # Exit if check_mode if module.check_mode: module.exit_json( - changed= changeRequired, - result = "Success", + changed= change_required, name = module.params['name'], details = response, arguments = module.params['arguments'] ) # Do changes - if changeRequired: + if change_required: if module.params['state'] == 'present': r = requests.put( url, @@ -175,9 +194,9 @@ def main(): headers = { "content-type": "application/json"}, data = json.dumps({ "durable": module.params['durable'], - "auto_delete": module.params['autoDelete'], + "auto_delete": module.params['auto_delete'], "internal": module.params['internal'], - "type": module.params['exchangeType'], + "type": module.params['exchange_type'], "arguments": module.params['arguments'] }) ) @@ -187,7 +206,6 @@ def main(): if r.status_code == 204: module.exit_json( changed = True, - result = "Success", name = module.params['name'] ) else: @@ -200,7 +218,6 @@ def main(): else: module.exit_json( changed = False, - result = "Success", name = module.params['name'] ) diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_queue.py b/lib/ansible/modules/extras/messaging/rabbitmq_queue.py index bacb02b5be..6b49fea9f0 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_queue.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_queue.py @@ -1,10 +1,30 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2015, Manuel Sousa +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' +--- module: rabbitmq_queue author: "Manuel Sousa (@manuel-sousa)" version_added: "2.0" @@ -56,13 +76,13 @@ options: required: false choices: [ "yes", "no" ] default: yes - autoDelete: + auto_delete: description: - if the queue should delete itself after all queues/queues unbound from it required: false choices: [ "yes", "no" ] default: no - messageTTL: + message_ttl: description: - How long a message can live in queue before it is discarded (milliseconds) required: False @@ -119,7 +139,7 @@ def main(): state = dict(default='present', choices=['present', 'absent'], type='str'), name = dict(required=True, type='str'), login_user = dict(default='guest', type='str'), - login_password = dict(default='guest', type='str'), + login_password = dict(default='guest', type='str', no_log=True), login_host = dict(default='localhost', type='str'), login_port = dict(default='15672', type='str'), vhost = dict(default='/', type='str'), @@ -146,10 +166,10 @@ def main(): r = requests.get( url, auth=(module.params['login_user'],module.params['login_password'])) if r.status_code==200: - queueExists = True + queue_exists = True response = r.json() elif r.status_code==404: - queueExists = False + queue_exists = False response = r.text else: module.fail_json( @@ -157,27 +177,35 @@ def main(): details = r.text ) - changeRequired = not queueExists if module.params['state']=='present' else queueExists + if module.params['state']=='present': + change_required = not queue_exists + else: + change_required = queue_exists # Check if attributes change on existing queue - if not changeRequired and r.status_code==200 and module.params['state'] == 'present': + if not change_required and r.status_code==200 and module.params['state'] == 'present': if not ( response['durable'] == module.params['durable'] and - response['auto_delete'] == module.params['autoDelete'] and + response['auto_delete'] == module.params['auto_delete'] and ( - response['arguments']['x-message-ttl'] == module.params['messageTTL'] if 'x-message-ttl' in response['arguments'] else module.params['messageTTL'] is None + ( 'x-message-ttl' in response['arguments'] and response['arguments']['x-message-ttl'] == module.params['message_ttl'] ) or + ( 'x-message-ttl' not in response['arguments'] and module.params['message_ttl'] is None ) ) and ( - response['arguments']['x-expires'] == module.params['autoExpire'] if 'x-expires' in response['arguments'] else module.params['autoExpire'] is None + ( 'x-expires' in response['arguments'] and response['arguments']['x-expires'] == module.params['auto_expires'] ) or + ( 'x-expires' not in response['arguments'] and module.params['auto_expires'] is None ) ) and ( - response['arguments']['x-max-length'] == module.params['maxLength'] if 'x-max-length' in response['arguments'] else module.params['maxLength'] is None + ( 'x-max-length' in response['arguments'] and response['arguments']['x-max-length'] == module.params['max_length'] ) or + ( 'x-max-length' not in response['arguments'] and module.params['max_length'] is None ) ) and ( - response['arguments']['x-dead-letter-exchange'] == module.params['deadLetterExchange'] if 'x-dead-letter-exchange' in response['arguments'] else module.params['deadLetterExchange'] is None + ( 'x-dead-letter-exchange' in response['arguments'] and response['arguments']['x-dead-letter-exchange'] == module.params['dead_letter_exchange'] ) or + ( 'x-dead-letter-exchange' not in response['arguments'] and module.params['dead_letter_exchange'] is None ) ) and ( - response['arguments']['x-dead-letter-routing-key'] == module.params['deadLetterRoutingKey'] if 'x-dead-letter-routing-key' in response['arguments'] else module.params['deadLetterRoutingKey'] is None + ( 'x-dead-letter-routing-key' in response['arguments'] and response['arguments']['x-dead-letter-routing-key'] == module.params['dead_letter_routing_key'] ) or + ( 'x-dead-letter-routing-key' not in response['arguments'] and module.params['dead_letter_routing_key'] is None ) ) ): module.fail_json( @@ -187,11 +215,11 @@ def main(): # Copy parameters to arguments as used by RabbitMQ for k,v in { - 'messageTTL': 'x-message-ttl', - 'autoExpire': 'x-expires', - 'maxLength': 'x-max-length', - 'deadLetterExchange': 'x-dead-letter-exchange', - 'deadLetterRoutingKey': 'x-dead-letter-routing-key' + 'message_ttl': 'x-message-ttl', + 'auto_expires': 'x-expires', + 'max_length': 'x-max-length', + 'dead_letter_exchange': 'x-dead-letter-exchange', + 'dead_letter_routing_key': 'x-dead-letter-routing-key' }.items(): if module.params[k]: module.params['arguments'][v] = module.params[k] @@ -199,15 +227,14 @@ def main(): # Exit if check_mode if module.check_mode: module.exit_json( - changed= changeRequired, - result = "Success", + changed= change_required, name = module.params['name'], details = response, arguments = module.params['arguments'] ) # Do changes - if changeRequired: + if change_required: if module.params['state'] == 'present': r = requests.put( url, @@ -215,7 +242,7 @@ def main(): headers = { "content-type": "application/json"}, data = json.dumps({ "durable": module.params['durable'], - "auto_delete": module.params['autoDelete'], + "auto_delete": module.params['auto_delete'], "arguments": module.params['arguments'] }) ) @@ -225,7 +252,6 @@ def main(): if r.status_code == 204: module.exit_json( changed = True, - result = "Success", name = module.params['name'] ) else: @@ -238,7 +264,6 @@ def main(): else: module.exit_json( changed = False, - result = "Success", name = module.params['name'] ) diff --git a/lib/ansible/modules/extras/monitoring/bigpanda.py b/lib/ansible/modules/extras/monitoring/bigpanda.py index 446c1384a6..90b3784152 100644 --- a/lib/ansible/modules/extras/monitoring/bigpanda.py +++ b/lib/ansible/modules/extras/monitoring/bigpanda.py @@ -23,7 +23,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = ''' --- module: bigpanda -author: BigPanda +author: "Hagai Kariti (@hkariti)" short_description: Notify BigPanda about deployments version_added: "1.8" description: diff --git a/lib/ansible/modules/extras/monitoring/circonus_annotation.py b/lib/ansible/modules/extras/monitoring/circonus_annotation.py index b2ec85c0db..5e9029e9fb 100644 --- a/lib/ansible/modules/extras/monitoring/circonus_annotation.py +++ b/lib/ansible/modules/extras/monitoring/circonus_annotation.py @@ -28,7 +28,7 @@ module: circonus_annotation short_description: create an annotation in circonus description: - Create an annotation event with a given category, title and description. Optionally start, end or durations can be provided -author: Nick Harring +author: "Nick Harring (@NickatEpic)" version_added: 2.0 requirements: - urllib3 diff --git a/lib/ansible/modules/extras/monitoring/nagios.py b/lib/ansible/modules/extras/monitoring/nagios.py index dc3832701f..78bd897ed1 100644 --- a/lib/ansible/modules/extras/monitoring/nagios.py +++ b/lib/ansible/modules/extras/monitoring/nagios.py @@ -58,6 +58,7 @@ options: required: false default: Ansible comment: + version_added: "2.0" description: - Comment for C(downtime) action. required: false diff --git a/lib/ansible/modules/extras/monitoring/pingdom.py b/lib/ansible/modules/extras/monitoring/pingdom.py index caed768d87..d37ae44ab1 100644 --- a/lib/ansible/modules/extras/monitoring/pingdom.py +++ b/lib/ansible/modules/extras/monitoring/pingdom.py @@ -26,7 +26,9 @@ short_description: Pause/unpause Pingdom alerts description: - This module will let you pause/unpause Pingdom alerts version_added: "1.2" -author: Justin Johns +author: + - "Dylan Silva (@thaumos)" + - "Justin Johns" requirements: - "This pingdom python library: https://github.com/mbabineau/pingdom-python" options: @@ -132,7 +134,7 @@ def main(): ) if not HAS_PINGDOM: - module.fail_json(msg="Missing requried pingdom module (check docs)") + module.fail_json(msg="Missing required pingdom module (check docs)") checkid = module.params['checkid'] state = module.params['state'] diff --git a/lib/ansible/modules/extras/monitoring/stackdriver.py b/lib/ansible/modules/extras/monitoring/stackdriver.py index 26bfb1c13f..b20b191158 100644 --- a/lib/ansible/modules/extras/monitoring/stackdriver.py +++ b/lib/ansible/modules/extras/monitoring/stackdriver.py @@ -26,7 +26,7 @@ short_description: Send code deploy and annotation events to stackdriver description: - Send code deploy and annotation events to Stackdriver version_added: "1.6" -author: Ben Whaley +author: "Ben Whaley (@bwhaley)" options: key: description: diff --git a/lib/ansible/modules/extras/monitoring/uptimerobot.py b/lib/ansible/modules/extras/monitoring/uptimerobot.py index b4f5c1d819..3a87c3838a 100644 --- a/lib/ansible/modules/extras/monitoring/uptimerobot.py +++ b/lib/ansible/modules/extras/monitoring/uptimerobot.py @@ -25,7 +25,7 @@ module: uptimerobot short_description: Pause and start Uptime Robot monitoring description: - This module will let you start and pause Uptime Robot Monitoring -author: Nate Kingsley +author: "Nate Kingsley (@nate-kingsley)" version_added: "1.9" requirements: - Valid Uptime Robot API Key diff --git a/lib/ansible/modules/extras/monitoring/zabbix_hostmacro.py b/lib/ansible/modules/extras/monitoring/zabbix_hostmacro.py index 9415fa5c38..75c552cf22 100644 --- a/lib/ansible/modules/extras/monitoring/zabbix_hostmacro.py +++ b/lib/ansible/modules/extras/monitoring/zabbix_hostmacro.py @@ -30,7 +30,9 @@ short_description: Zabbix host macro creates/updates/deletes description: - manages Zabbix host macros, it can create, update or delete them. version_added: "2.0" -author: Dean Hailin Song +author: + - "(@cave)" + - Dean Hailin Song requirements: - "python >= 2.6" - zabbix-api diff --git a/lib/ansible/modules/extras/network/cloudflare_dns.py b/lib/ansible/modules/extras/network/cloudflare_dns.py index 88fe9d6a7d..621e92ac1f 100644 --- a/lib/ansible/modules/extras/network/cloudflare_dns.py +++ b/lib/ansible/modules/extras/network/cloudflare_dns.py @@ -197,7 +197,7 @@ record: description: the record content (details depend on record type) returned: success type: string - sample: 192.168.100.20 + sample: 192.0.2.91 created_on: description: the record creation date returned: success diff --git a/lib/ansible/modules/extras/network/dnsimple.py b/lib/ansible/modules/extras/network/dnsimple.py index 034147b3e1..3f6c2188b0 100644 --- a/lib/ansible/modules/extras/network/dnsimple.py +++ b/lib/ansible/modules/extras/network/dnsimple.py @@ -97,7 +97,7 @@ options: default: null requirements: [ dnsimple ] -author: Alex Coomans +author: "Alex Coomans (@drcapulet)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/network/f5/bigip_device_ntp.py b/lib/ansible/modules/extras/network/f5/bigip_device_ntp.py index 9ad12bd3f0..23ed81b781 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_device_ntp.py +++ b/lib/ansible/modules/extras/network/f5/bigip_device_ntp.py @@ -66,7 +66,7 @@ EXAMPLES = ''' - name: Set NTP server bigip_device_ntp: ntp_servers: - - "192.168.10.12" + - "192.0.2.23" password: "secret" server: "lb.mydomain.com" user: "admin" @@ -88,7 +88,7 @@ ntp_servers: description: The NTP servers that were set on the device returned: changed type: list - sample: ["192.168.10.10", "172.27.10.10"] + sample: ["192.0.2.23", "192.0.2.42"] timezone: description: The timezone that was set on the device returned: changed diff --git a/lib/ansible/modules/extras/network/f5/bigip_gtm_virtual_server.py b/lib/ansible/modules/extras/network/f5/bigip_gtm_virtual_server.py index d2d4dd3e66..03be3a9df6 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_gtm_virtual_server.py +++ b/lib/ansible/modules/extras/network/f5/bigip_gtm_virtual_server.py @@ -73,7 +73,7 @@ EXAMPLES = ''' - name: Enable virtual server local_action: > bigip_gtm_virtual_server - server=192.168.0.1 + server=192.0.2.1 user=admin password=mysecret virtual_server_name=myname diff --git a/lib/ansible/modules/extras/network/f5/bigip_gtm_wide_ip.py b/lib/ansible/modules/extras/network/f5/bigip_gtm_wide_ip.py index a0eb48224b..c1712902f4 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_gtm_wide_ip.py +++ b/lib/ansible/modules/extras/network/f5/bigip_gtm_wide_ip.py @@ -61,7 +61,7 @@ EXAMPLES = ''' - name: Set lb method local_action: > bigip_gtm_wide_ip - server=192.168.0.1 + server=192.0.2.1 user=admin password=mysecret lb_method=round_robin diff --git a/lib/ansible/modules/extras/network/f5/bigip_selfip.py b/lib/ansible/modules/extras/network/f5/bigip_selfip.py index f62191745b..d60dafbf7c 100644 --- a/lib/ansible/modules/extras/network/f5/bigip_selfip.py +++ b/lib/ansible/modules/extras/network/f5/bigip_selfip.py @@ -197,7 +197,7 @@ address: description: The address for the Self IP returned: created type: string - sample: "192.168.10.10" + sample: "192.0.2.10" name: description: The name of the Self IP returned: diff --git a/lib/ansible/modules/extras/network/illumos/dladm_vnic.py b/lib/ansible/modules/extras/network/illumos/dladm_vnic.py index 2860b8df10..0718517d47 100644 --- a/lib/ansible/modules/extras/network/illumos/dladm_vnic.py +++ b/lib/ansible/modules/extras/network/illumos/dladm_vnic.py @@ -114,7 +114,7 @@ mac: description: MAC address to use for VNIC returned: if mac is specified type: string - sample: "00:aa:bc:fe:11:22" + sample: "00:00:5E:00:53:42" vlan: description: VLAN to use for VNIC returned: success diff --git a/lib/ansible/modules/extras/network/lldp.py b/lib/ansible/modules/extras/network/lldp.py index 9a648f1f05..f222d765fe 100644 --- a/lib/ansible/modules/extras/network/lldp.py +++ b/lib/ansible/modules/extras/network/lldp.py @@ -29,7 +29,7 @@ short_description: get details reported by lldp description: - Reads data out of lldpctl options: {} -author: Andy Hill +author: "Andy Hill (@andyhky)" notes: - Requires lldpd running and lldp enabled on switches ''' diff --git a/lib/ansible/modules/extras/network/nmcli.py b/lib/ansible/modules/extras/network/nmcli.py index 18ad3ae413..86a844c7ee 100644 --- a/lib/ansible/modules/extras/network/nmcli.py +++ b/lib/ansible/modules/extras/network/nmcli.py @@ -77,16 +77,16 @@ options: required: False default: None description: - - 'The IPv4 address to this interface using this format ie: "192.168.1.24/24"' + - 'The IPv4 address to this interface using this format ie: "192.0.2.24/24"' gw4: required: False description: - - 'The IPv4 gateway for this interface using this format ie: "192.168.100.1"' + - 'The IPv4 gateway for this interface using this format ie: "192.0.2.1"' dns4: required: False default: None description: - - 'A list of upto 3 dns servers, ipv4 format e.g. To add two IPv4 DNS server addresses: ["8.8.8.8 8.8.4.4"]' + - 'A list of upto 3 dns servers, ipv4 format e.g. To add two IPv4 DNS server addresses: ["192.0.2.53", "198.51.100.53"]' ip6: required: False default: None @@ -232,9 +232,9 @@ The following examples are working examples that I have run in the field. I foll ```yml --- #devops_os_define_network -storage_gw: "192.168.0.254" -external_gw: "10.10.0.254" -tenant_gw: "172.100.0.254" +storage_gw: "192.0.2.254" +external_gw: "198.51.100.254" +tenant_gw: "203.0.113.254" #Team vars nmcli_team: @@ -312,9 +312,9 @@ nmcli_ethernet: ### host_vars ```yml --- -storage_ip: "192.168.160.21/23" -external_ip: "10.10.152.21/21" -tenant_ip: "192.168.200.21/23" +storage_ip: "192.0.2.91/23" +external_ip: "198.51.100.23/21" +tenant_ip: "203.0.113.77/23" ``` @@ -920,8 +920,8 @@ class Nmcli(object): cmd=[self.module.get_bin_path('nmcli', True)] # format for creating ethernet interface # To add an Ethernet connection with static IP configuration, issue a command as follows - # - nmcli: name=add conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.168.100.100/24 gw4=192.168.100.1 state=present - # nmcli con add con-name my-eth1 ifname eth1 type ethernet ip4 192.168.100.100/24 gw4 192.168.100.1 + # - nmcli: name=add conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.0.2.100/24 gw4=192.0.2.1 state=present + # nmcli con add con-name my-eth1 ifname eth1 type ethernet ip4 192.0.2.100/24 gw4 192.0.2.1 cmd.append('con') cmd.append('add') cmd.append('type') @@ -957,8 +957,8 @@ class Nmcli(object): cmd=[self.module.get_bin_path('nmcli', True)] # format for modifying ethernet interface # To add an Ethernet connection with static IP configuration, issue a command as follows - # - nmcli: name=add conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.168.100.100/24 gw4=192.168.100.1 state=present - # nmcli con add con-name my-eth1 ifname eth1 type ethernet ip4 192.168.100.100/24 gw4 192.168.100.1 + # - nmcli: name=add conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.0.2.100/24 gw4=192.0.2.1 state=present + # nmcli con add con-name my-eth1 ifname eth1 type ethernet ip4 192.0.2.100/24 gw4 192.0.2.1 cmd.append('con') cmd.append('mod') cmd.append(self.conn_name) diff --git a/lib/ansible/modules/extras/network/openvswitch_port.py b/lib/ansible/modules/extras/network/openvswitch_port.py index 7b00de2945..759a2489c1 100644 --- a/lib/ansible/modules/extras/network/openvswitch_port.py +++ b/lib/ansible/modules/extras/network/openvswitch_port.py @@ -96,7 +96,7 @@ EXAMPLES = ''' state: present set: Interface vlan10 -# Assign interface id server1-vifeth6 and mac address 52:54:00:30:6d:11 +# Assign interface id server1-vifeth6 and mac address 00:00:5E:00:53:23 # to port vifeth6 and setup port to be managed by a controller. - openvswitch_port: bridge: br-int diff --git a/lib/ansible/modules/extras/notification/hall.py b/lib/ansible/modules/extras/notification/hall.py index 75350fb462..691fc95316 100755 --- a/lib/ansible/modules/extras/notification/hall.py +++ b/lib/ansible/modules/extras/notification/hall.py @@ -27,13 +27,13 @@ DOCUMENTATION = """ module: hall short_description: Send notification to Hall description: - - The M(hall) module connects to the U(https://hall.com) messaging API and allows you to deliver notication messages to rooms. -version_added: 1.6 -author: Billy Kimble + - "The M(hall) module connects to the U(https://hall.com) messaging API and allows you to deliver notication messages to rooms." +version_added: "2.0" +author: Billy Kimble (@bkimble) options: room_token: description: - - Room token provided to you by setting up the Ansible room integation on U(https://hall.com) + - "Room token provided to you by setting up the Ansible room integation on U(https://hall.com)" required: true msg: description: @@ -45,7 +45,7 @@ options: required: true picture: description: - - The full URL to the image you wish to use for the Icon of the message. Defaults to U(http://cdn2.hubspot.net/hub/330046/file-769078210-png/Official_Logos/ansible_logo_black_square_small.png?t=1421076128627) + - "The full URL to the image you wish to use for the Icon of the message. Defaults to U(http://cdn2.hubspot.net/hub/330046/file-769078210-png/Official_Logos/ansible_logo_black_square_small.png?t=1421076128627)" required: false """ diff --git a/lib/ansible/modules/extras/notification/hipchat.py b/lib/ansible/modules/extras/notification/hipchat.py index 66cdf36023..f321a6b914 100644 --- a/lib/ansible/modules/extras/notification/hipchat.py +++ b/lib/ansible/modules/extras/notification/hipchat.py @@ -76,7 +76,7 @@ options: description: - API url if using a self-hosted hipchat server. For hipchat api version 2 use C(/v2) path in URI required: false - default: 'https://api.hipchat.com/v1/rooms/message' + default: 'https://api.hipchat.com/v1' version_added: 1.6.0 @@ -101,7 +101,6 @@ EXAMPLES = ''' # HipChat module specific support methods. # -MSG_URI = "https://api.hipchat.com/v1/rooms/message" import urllib try: import json @@ -195,7 +194,7 @@ def main(): msg_format=dict(default="text", choices=["text", "html"]), notify=dict(default=True, type='bool'), validate_certs=dict(default='yes', type='bool'), - api=dict(default=MSG_URI), + api=dict(default=DEFAULT_URI), ), supports_check_mode=True ) diff --git a/lib/ansible/modules/extras/notification/irc.py b/lib/ansible/modules/extras/notification/irc.py index 7eaa8986e9..d2fa22a4f5 100644 --- a/lib/ansible/modules/extras/notification/irc.py +++ b/lib/ansible/modules/extras/notification/irc.py @@ -67,11 +67,11 @@ options: "light_blue", "pink", "gray", "light_gray"] channel: description: - - Channel name + - Channel name. One of nick_to or channel needs to be set. When both are set, the message will be sent to both of them. required: true nick_to: description: - - A list of nicknames to send the message to. When both channel and nick_to are defined, the message will be send to both of them. + - A list of nicknames to send the message to. One of nick_to or channel needs to be set. When both are defined, the message will be sent to both of them. required: false default: null version_added: "2.0" diff --git a/lib/ansible/modules/extras/notification/mqtt.py b/lib/ansible/modules/extras/notification/mqtt.py index c8adfc0d0e..b13124b4f0 100644 --- a/lib/ansible/modules/extras/notification/mqtt.py +++ b/lib/ansible/modules/extras/notification/mqtt.py @@ -115,7 +115,7 @@ requirements: [ mosquitto ] notes: - This module requires a connection to an MQTT broker such as Mosquitto U(http://mosquitto.org) and the I(Paho) C(mqtt) Python client (U(https://pypi.python.org/pypi/paho-mqtt)). -author: Jan-Piet Mens +author: "Jan-Piet Mens (@jpmens)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/notification/osx_say.py b/lib/ansible/modules/extras/notification/osx_say.py index 6b0e114c3b..ff6d3ae014 100644 --- a/lib/ansible/modules/extras/notification/osx_say.py +++ b/lib/ansible/modules/extras/notification/osx_say.py @@ -41,7 +41,9 @@ options: What voice to use required: false requirements: [ say ] -author: Michael DeHaan +author: + - "Ansible Core Team" + - "Michael DeHaan (@mpdehaan)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/notification/pushbullet.py b/lib/ansible/modules/extras/notification/pushbullet.py index 6f20708a9a..ed09be8f51 100644 --- a/lib/ansible/modules/extras/notification/pushbullet.py +++ b/lib/ansible/modules/extras/notification/pushbullet.py @@ -22,7 +22,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = ''' --- -author: Willy Barro +author: "Willy Barro (@willybarro)" requirements: [ pushbullet.py ] module: pushbullet short_description: Sends notifications to Pushbullet diff --git a/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py b/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py index ca4d75dfbf..9e5245bc6f 100644 --- a/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py +++ b/lib/ansible/modules/extras/packaging/elasticsearch_plugin.py @@ -32,7 +32,7 @@ module: elasticsearch_plugin short_description: Manage Elasticsearch plugins description: - Manages Elasticsearch plugins. -version_added: "" +version_added: "2.0" author: Mathew Davies (@ThePixelDeveloper) options: name: @@ -52,7 +52,7 @@ options: default: None timeout: description: - - Timeout setting: 30s, 1m, 1h... + - "Timeout setting: 30s, 1m, 1h..." required: False default: 1m plugin_bin: diff --git a/lib/ansible/modules/extras/packaging/os/dnf.py b/lib/ansible/modules/extras/packaging/os/dnf.py index d21670ae11..c06ccdca05 100644 --- a/lib/ansible/modules/extras/packaging/os/dnf.py +++ b/lib/ansible/modules/extras/packaging/os/dnf.py @@ -27,7 +27,7 @@ ANSIBLE_METADATA = {'status': ['stableinterface'], DOCUMENTATION = ''' --- module: dnf -version_added: historical +version_added: 1.9 short_description: Manages packages with the I(dnf) package manager description: - Installs, upgrade, removes, and lists packages and groups with the I(dnf) package manager. @@ -36,7 +36,6 @@ options: description: - "Package name, or package specifier with version, like C(name-1.0). When using state=latest, this can be '*' which means run: dnf -y update. You can also pass a url or a local path to a rpm file." required: true - version_added: "1.8" default: null aliases: [] @@ -44,7 +43,6 @@ options: description: - Various (non-idempotent) commands for usage with C(/usr/bin/ansible) and I(not) playbooks. See examples. required: false - version_added: "1.8" default: null state: @@ -52,7 +50,6 @@ options: - Whether to install (C(present), C(latest)), or remove (C(absent)) a package. required: false choices: [ "present", "latest", "absent" ] - version_added: "1.8" default: "present" enablerepo: @@ -61,7 +58,6 @@ options: These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". required: false - version_added: "1.8" default: null aliases: [] @@ -71,7 +67,6 @@ options: These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". required: false - version_added: "1.8" default: null aliases: [] @@ -79,7 +74,6 @@ options: description: - The remote dnf configuration file to use for the transaction. required: false - version_added: "1.8" default: null aliases: [] @@ -88,7 +82,6 @@ options: - Whether to disable the GPG checking of signatures of packages being installed. Has an effect only if state is I(present) or I(latest). required: false - version_added: "1.8" default: "no" choices: ["yes", "no"] aliases: [] diff --git a/lib/ansible/modules/extras/packaging/os/homebrew.py b/lib/ansible/modules/extras/packaging/os/homebrew.py index 4a1ab598e0..c44ccabbe6 100755 --- a/lib/ansible/modules/extras/packaging/os/homebrew.py +++ b/lib/ansible/modules/extras/packaging/os/homebrew.py @@ -46,7 +46,7 @@ options: aliases: ['pkg', 'package', 'formula'] path: description: - - ':' separated list of paths to search for 'brew' executable. Since A package (I(formula) in homebrew parlance) location is prefixed relative to the actual path of I(brew) command, providing an alternative I(brew) path enables managing different set of packages in an alternative location in the system. + - "':' separated list of paths to search for 'brew' executable. Since A package (I(formula) in homebrew parlance) location is prefixed relative to the actual path of I(brew) command, providing an alternative I(brew) path enables managing different set of packages in an alternative location in the system." required: false default: '/usr/local/bin' state: diff --git a/lib/ansible/modules/extras/packaging/os/macports.py b/lib/ansible/modules/extras/packaging/os/macports.py index 071ca58953..ac49f1568e 100644 --- a/lib/ansible/modules/extras/packaging/os/macports.py +++ b/lib/ansible/modules/extras/packaging/os/macports.py @@ -25,7 +25,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = ''' --- module: macports -author: Jimmy Tang +author: "Jimmy Tang (@jcftang)" short_description: Package manager for MacPorts description: - Manages MacPorts packages diff --git a/lib/ansible/modules/extras/packaging/os/pkg5.py b/lib/ansible/modules/extras/packaging/os/pkg5.py index 55483ed8da..4c02d63821 100644 --- a/lib/ansible/modules/extras/packaging/os/pkg5.py +++ b/lib/ansible/modules/extras/packaging/os/pkg5.py @@ -25,6 +25,7 @@ DOCUMENTATION = ''' module: pkg5 author: "Peter Oliver (@mavit)" short_description: Manages packages with the Solaris 11 Image Packaging System +version_added: 1.9 description: - IPS packages are the native packages in Solaris 11 and higher. notes: diff --git a/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py b/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py index d42f9dc648..279b40f009 100644 --- a/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py +++ b/lib/ansible/modules/extras/packaging/os/pkg5_publisher.py @@ -25,6 +25,7 @@ DOCUMENTATION = ''' module: pkg5_publisher author: "Peter Oliver (@mavit)" short_description: Manages Solaris 11 Image Packaging System publishers +version_added: 1.9 description: - IPS packages are the native packages in Solaris 11 and higher. - This modules will configure which publishers a client will download IPS diff --git a/lib/ansible/modules/extras/packaging/os/pkgng.py b/lib/ansible/modules/extras/packaging/os/pkgng.py index 9bf0e86866..5727b19003 100644 --- a/lib/ansible/modules/extras/packaging/os/pkgng.py +++ b/lib/ansible/modules/extras/packaging/os/pkgng.py @@ -278,9 +278,8 @@ def annotate_packages(module, pkgng_path, packages, annotation, dir_arg): for package in packages: for _annotation in annotations: - annotate_c += ( 1 if operation[_annotation['operation']]( - module, pkgng_path, package, - _annotation['tag'], _annotation['value'], rootdir_arg) else 0 ) + if operation[_annotation['operation']](module, pkgng_path, package, _annotation['tag'], _annotation['value']): + annotate_c += 1 if annotate_c > 0: return (True, "added %s annotations." % annotate_c) diff --git a/lib/ansible/modules/extras/packaging/os/slackpkg.py b/lib/ansible/modules/extras/packaging/os/slackpkg.py index af5739d57c..3c4ee4f62e 100644 --- a/lib/ansible/modules/extras/packaging/os/slackpkg.py +++ b/lib/ansible/modules/extras/packaging/os/slackpkg.py @@ -55,7 +55,7 @@ options: choices: [ true, false ] author: Kim Nørgaard (@KimNorgaard) -requirements: [ "Slackware" >= 12.2 ] +requirements: [ "Slackware >= 12.2" ] ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/packaging/os/svr4pkg.py b/lib/ansible/modules/extras/packaging/os/svr4pkg.py index bb37efc1d7..81409e3b2d 100644 --- a/lib/ansible/modules/extras/packaging/os/svr4pkg.py +++ b/lib/ansible/modules/extras/packaging/os/svr4pkg.py @@ -34,7 +34,7 @@ description: - Note that this is a very basic packaging system. It will not enforce dependencies on install or remove. version_added: "0.9" -author: Boyd Adamson +author: "Boyd Adamson (@brontitall)" options: name: description: diff --git a/lib/ansible/modules/extras/packaging/os/yum_repository.py b/lib/ansible/modules/extras/packaging/os/yum_repository.py index 9aec9300e0..1d00d26f68 100644 --- a/lib/ansible/modules/extras/packaging/os/yum_repository.py +++ b/lib/ansible/modules/extras/packaging/os/yum_repository.py @@ -33,7 +33,7 @@ DOCUMENTATION = ''' --- module: yum_repository author: Jiri Tyr (@jtyr) -version_added: '2.0' +version_added: '2.1' short_description: Add and remove YUM repositories description: - Add or remove YUM repositories in RPM-based Linux distributions. diff --git a/lib/ansible/modules/extras/system/cronvar.py b/lib/ansible/modules/extras/system/cronvar.py index bb6983cf6b..a65610811b 100644 --- a/lib/ansible/modules/extras/system/cronvar.py +++ b/lib/ansible/modules/extras/system/cronvar.py @@ -87,7 +87,7 @@ options: default: false requirements: - cron -author: Doug Luce +author: "Doug Luce (@dougluce)" """ EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/system/facter.py b/lib/ansible/modules/extras/system/facter.py index a89aabead2..5ae13ab737 100644 --- a/lib/ansible/modules/extras/system/facter.py +++ b/lib/ansible/modules/extras/system/facter.py @@ -36,7 +36,9 @@ version_added: "0.2" options: {} notes: [] requirements: [ "facter", "ruby-json" ] -author: Michael DeHaan +author: + - "Ansible Core Team" + - "Michael DeHaan" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/system/firewalld.py b/lib/ansible/modules/extras/system/firewalld.py index 4f8a4fd7e6..8324069b1b 100644 --- a/lib/ansible/modules/extras/system/firewalld.py +++ b/lib/ansible/modules/extras/system/firewalld.py @@ -447,8 +447,9 @@ def main(): port=dict(required=False,default=None), rich_rule=dict(required=False,default=None), zone=dict(required=False,default=None), - permanent=dict(type='bool',required=True), immediate=dict(type='bool',default=False), + source=dict(required=False,default=None), + permanent=dict(type='bool',required=False,default=None), state=dict(choices=['enabled', 'disabled'], required=True), timeout=dict(type='int',required=False,default=0), interface=dict(required=False,default=None), @@ -528,6 +529,7 @@ def main(): msgs = [] service = module.params['service'] rich_rule = module.params['rich_rule'] + source = module.params['source'] if module.params['port'] != None: port, protocol = module.params['port'].split('/') diff --git a/lib/ansible/modules/extras/system/getent.py b/lib/ansible/modules/extras/system/getent.py index 276fb7a08c..960a1221f7 100644 --- a/lib/ansible/modules/extras/system/getent.py +++ b/lib/ansible/modules/extras/system/getent.py @@ -58,7 +58,7 @@ options: notes: - "Not all databases support enumeration, check system documentation for details" requirements: [ ] -author: Brian Coca +author: "Brian Coca (@bcoca)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/system/locale_gen.py b/lib/ansible/modules/extras/system/locale_gen.py index 04394a26dc..b56a5e498e 100644 --- a/lib/ansible/modules/extras/system/locale_gen.py +++ b/lib/ansible/modules/extras/system/locale_gen.py @@ -27,6 +27,7 @@ short_description: Creates or removes locales. description: - Manages locales by editing /etc/locale.gen and invoking locale-gen. version_added: "1.6" +author: "Augustus Kling (@AugustusKling)" options: name: description: diff --git a/lib/ansible/modules/extras/system/ohai.py b/lib/ansible/modules/extras/system/ohai.py index 4a5e772c25..47926a34d1 100644 --- a/lib/ansible/modules/extras/system/ohai.py +++ b/lib/ansible/modules/extras/system/ohai.py @@ -36,7 +36,9 @@ version_added: "0.6" options: {} notes: [] requirements: [ "ohai" ] -author: Michael DeHaan +author: + - "Ansible Core Team" + - "Michael DeHaan (@mpdehaan)" ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/system/osx_defaults.py b/lib/ansible/modules/extras/system/osx_defaults.py index 5f79cdce8d..757cc811d9 100644 --- a/lib/ansible/modules/extras/system/osx_defaults.py +++ b/lib/ansible/modules/extras/system/osx_defaults.py @@ -23,14 +23,14 @@ ANSIBLE_METADATA = {'status': ['stableinterface'], DOCUMENTATION = ''' --- module: osx_defaults -author: Franck Nijhof +author: Franck Nijhof (@frenck) short_description: osx_defaults allows users to read, write, and delete Mac OS X user defaults from Ansible description: - osx_defaults allows users to read, write, and delete Mac OS X user defaults from Ansible scripts. Mac OS X applications and other programs use the defaults system to record user preferences and other information that must be maintained when the applications aren't running (such as default font for new documents, or the position of an Info panel). -version_added: 1.8 +version_added: "2.0" options: domain: description: @@ -58,7 +58,7 @@ options: description: - Add new elements to the array for a key which has an array as its value. required: false - default: string + default: false choices: [ "true", "false" ] value: description: diff --git a/lib/ansible/modules/extras/system/pam_limits.py b/lib/ansible/modules/extras/system/pam_limits.py index a4434fcf15..7f6598e980 100644 --- a/lib/ansible/modules/extras/system/pam_limits.py +++ b/lib/ansible/modules/extras/system/pam_limits.py @@ -122,7 +122,7 @@ def main(): pam_types = [ 'soft', 'hard', '-' ] - limits_conf = '/home/slyce/limits.conf' + limits_conf = '/etc/security/limits.conf' module = AnsibleModule( # not checking because of daisy chain to file module @@ -134,7 +134,8 @@ def main(): use_max = dict(default=False, type='bool'), use_min = dict(default=False, type='bool'), backup = dict(default=False, type='bool'), - dest = dict(default=limits_conf, type='str') + dest = dict(default=limits_conf, type='str'), + comment = dict(required=False, default='', type='str') ) ) @@ -146,6 +147,7 @@ def main(): use_min = module.params['use_min'] backup = module.params['backup'] limits_conf = module.params['dest'] + new_comment = module.params['comment'] changed = False @@ -176,6 +178,7 @@ def main(): new_value = value for line in f: + if line.startswith('#'): nf.write(line) continue @@ -185,6 +188,21 @@ def main(): nf.write(line) continue + # Remove comment in line + newline = newline.split('#',1)[0] + try: + old_comment = line.split('#',1)[1] + except: + old_comment = '' + + newline = newline.rstrip() + + if not new_comment: + new_comment = old_comment + + if new_comment: + new_comment = "\t#"+new_comment + line_fields = newline.split(' ') if len(line_fields) != 4: diff --git a/lib/ansible/modules/extras/system/selinux_permissive.py b/lib/ansible/modules/extras/system/selinux_permissive.py index 02c197839b..fed5db2bcf 100644 --- a/lib/ansible/modules/extras/system/selinux_permissive.py +++ b/lib/ansible/modules/extras/system/selinux_permissive.py @@ -29,7 +29,7 @@ module: selinux_permissive short_description: Change permissive domain in SELinux policy description: - Add and remove domain from the list of permissive domain. -version_added: "1.9" +version_added: "2.0" options: domain: description: diff --git a/lib/ansible/modules/extras/system/seport.py b/lib/ansible/modules/extras/system/seport.py index fb6c01db63..bbd049c030 100644 --- a/lib/ansible/modules/extras/system/seport.py +++ b/lib/ansible/modules/extras/system/seport.py @@ -27,7 +27,7 @@ module: seport short_description: Manages SELinux network port type definitions description: - Manages SELinux network port type definitions. -version_added: "1.7.1" +version_added: "2.0" options: ports: description: diff --git a/lib/ansible/modules/extras/system/solaris_zone.py b/lib/ansible/modules/extras/system/solaris_zone.py index 667f370130..85e0f41a1c 100644 --- a/lib/ansible/modules/extras/system/solaris_zone.py +++ b/lib/ansible/modules/extras/system/solaris_zone.py @@ -50,7 +50,7 @@ options: - C(absent), destroy the zone. - C(configured), configure the ready so that it's to be attached. - C(attached), attach a zone, but do not boot it. - - C(detach), stop and detach a zone + - C(detached), shutdown and detach a zone choices: ['present', 'installed', 'started', 'running', 'stopped', 'absent', 'configured', 'attached', 'detached'] default: present name: @@ -75,7 +75,6 @@ options: required: false default: null config: - required: false description: - 'The zonecfg configuration commands for this zone. See zonecfg(1M) for the valid options and syntax. Typically this is a list of options separated by semi-colons or new lines, e.g. @@ -83,19 +82,17 @@ options: required: false default: empty string create_options: - required: false description: - 'Extra options to the zonecfg(1M) create command.' required: false default: empty string install_options: - required: false description: - 'Extra options to the zoneadm(1M) install command. To automate Solaris 11 zone creation, use this to specify the profile XML file, e.g. install_options="-c sc_profile.xml"' required: false + default: empty string attach_options: - required: false description: - 'Extra options to the zoneadm attach command. For example, this can be used to specify whether a minimum or full update of packages is required and if any packages need to diff --git a/lib/ansible/modules/extras/univention/udm_dns_record.py b/lib/ansible/modules/extras/univention/udm_dns_record.py index 02e00d8033..92cea50494 100644 --- a/lib/ansible/modules/extras/univention/udm_dns_record.py +++ b/lib/ansible/modules/extras/univention/udm_dns_record.py @@ -78,7 +78,7 @@ options: required: false default: [] description: - - "Additional data for this record, e.g. ['a': '192.168.1.1']. + - "Additional data for this record, e.g. ['a': '192.0.2.1']. Required if C(state=present)." ''' diff --git a/lib/ansible/modules/extras/web_infrastructure/letsencrypt.py b/lib/ansible/modules/extras/web_infrastructure/letsencrypt.py index 8d290b3984..a8541a6d77 100644 --- a/lib/ansible/modules/extras/web_infrastructure/letsencrypt.py +++ b/lib/ansible/modules/extras/web_infrastructure/letsencrypt.py @@ -211,7 +211,7 @@ def get_cert_days(module,cert_file): except AttributeError: module.fail_json(msg="No 'Not after' date found in {0}".format(cert_file)) except ValueError: - module.fail_json(msg="Faild to parse 'Not after' date of {0}".format(cert_file)) + module.fail_json(msg="Failed to parse 'Not after' date of {0}".format(cert_file)) now = datetime.datetime.utcnow() return (not_after - now).days @@ -268,8 +268,8 @@ def write_file(module, dest, content): class ACMEDirectory(object): ''' The ACME server directory. Gives access to the available resources - and the Replay-Nonce for a given uri. This only works for - uris that permit GET requests (so normally not the ones that + and the Replay-Nonce for a given URI. This only works for + URIs that permit GET requests (so normally not the ones that require authentication). https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.2 ''' diff --git a/lib/ansible/modules/extras/windows/win_acl.ps1 b/lib/ansible/modules/extras/windows/win_acl.ps1 index 2fea8d3027..4890a524fd 100644 --- a/lib/ansible/modules/extras/windows/win_acl.ps1 +++ b/lib/ansible/modules/extras/windows/win_acl.ps1 @@ -27,7 +27,7 @@ #Functions Function UserSearch { - Param ([string]$AccountName) + Param ([string]$accountName) #Check if there's a realm specified $searchDomain = $false @@ -46,27 +46,25 @@ Function UserSearch } else { - $IsDomainAccount = $true - $IsUpn = $false + $searchDomain = $true + $accountName = $accountName.split("\")[1] } - } - Elseif ($AccountName -contains "@") + Elseif ($accountName.contains("@")) { - $IsDomainAccount = $true - $IsUpn = $true + $searchDomain = $true + $searchDomainUPN = $true } Else { #Default to local user account - $accountname = $env:COMPUTERNAME + "\" + $AccountName - $IsLocalAccount = $true + $accountName = $env:COMPUTERNAME + "\" + $accountName } if (($searchDomain -eq $false) -and ($SearchAppPools -eq $false)) { # do not use Win32_UserAccount, because e.g. SYSTEM (BUILTIN\SYSTEM or COMPUUTERNAME\SYSTEM) will not be listed. on Win32_Account groups will be listed too - $localaccount = get-wmiobject -class "Win32_Account" -namespace "root\CIMV2" -filter "(LocalAccount = True)" | where {$_.Caption -eq $AccountName} + $localaccount = get-wmiobject -class "Win32_Account" -namespace "root\CIMV2" -filter "(LocalAccount = True)" | where {$_.Caption -eq $accountName} if ($localaccount) { return $localaccount.SID @@ -86,13 +84,18 @@ Function UserSearch return $apppoolobj.applicationPoolSid } } - ElseIf (($IsDomainAccount -eq $true) -and ($IsUpn -eq $false)) { #Search by samaccountname $Searcher = [adsisearcher]"" - $Searcher.Filter = "sAMAccountName=$($accountname.split("\")[1])" - $result = $Searcher.FindOne() + If ($searchDomainUPN -eq $false) { + $Searcher.Filter = "sAMAccountName=$($accountName)" + } + Else { + $Searcher.Filter = "userPrincipalName=$($accountName)" + } + + $result = $Searcher.FindOne() if ($result) { $user = $result.GetDirectoryEntry() @@ -104,7 +107,6 @@ Function UserSearch return (New-Object System.Security.Principal.SecurityIdentifier($binarySID,0)).Value } } - } $params = Parse-Args $args; diff --git a/lib/ansible/modules/extras/windows/win_chocolatey.py b/lib/ansible/modules/extras/windows/win_chocolatey.py index 26fefb1549..89e6d73af0 100644 --- a/lib/ansible/modules/extras/windows/win_chocolatey.py +++ b/lib/ansible/modules/extras/windows/win_chocolatey.py @@ -28,7 +28,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = ''' --- module: win_chocolatey -version_added: "1.8" +version_added: "1.9" short_description: Installs packages using chocolatey description: - Installs packages using Chocolatey (http://chocolatey.org/). If Chocolatey is missing from the system, the module will install it. List of packages can be found at http://chocolatey.org/packages diff --git a/lib/ansible/modules/extras/windows/win_iis_virtualdirectory.py b/lib/ansible/modules/extras/windows/win_iis_virtualdirectory.py index 0b5a40f0d0..9388cb9d6b 100644 --- a/lib/ansible/modules/extras/windows/win_iis_virtualdirectory.py +++ b/lib/ansible/modules/extras/windows/win_iis_virtualdirectory.py @@ -34,8 +34,6 @@ options: description: - The name of the virtual directory to create or remove required: true - default: null - aliases: [] state: description: - Whether to add or remove the specified virtual directory @@ -53,13 +51,11 @@ options: - The application under which the virtual directory is created or exists. required: false default: null - aliases: [] physical_path: description: - The physical path to the folder in which the new virtual directory is created. The specified folder must already exist. required: false default: null - aliases: [] author: Henrik Wallström ''' diff --git a/lib/ansible/modules/extras/windows/win_nssm.ps1 b/lib/ansible/modules/extras/windows/win_nssm.ps1 index 91e63069dd..da3d01a716 100644 --- a/lib/ansible/modules/extras/windows/win_nssm.ps1 +++ b/lib/ansible/modules/extras/windows/win_nssm.ps1 @@ -412,7 +412,7 @@ Function Nssm-Update-Credentials } else { $fullUser = $user - If (-not($user -contains "@") -and ($user.Split("\").count -eq 1)) { + If (-Not($user.contains("@")) -And ($user.Split("\").count -eq 1)) { $fullUser = ".\" + $user } diff --git a/lib/ansible/modules/extras/windows/win_nssm.py b/lib/ansible/modules/extras/windows/win_nssm.py index 0dad49ae14..57d9dfa3cb 100644 --- a/lib/ansible/modules/extras/windows/win_nssm.py +++ b/lib/ansible/modules/extras/windows/win_nssm.py @@ -93,7 +93,8 @@ options: start_mode: description: - If C(auto) is selected, the service will start at bootup. C(manual) means that the service will start only when another service needs it. C(disabled) means that the service will stay off, regardless if it is needed or not. - required: false + required: true + default: auto choices: - auto - manual diff --git a/lib/ansible/modules/extras/windows/win_owner.ps1 b/lib/ansible/modules/extras/windows/win_owner.ps1 index d781dd011d..076ab84605 100644 --- a/lib/ansible/modules/extras/windows/win_owner.ps1 +++ b/lib/ansible/modules/extras/windows/win_owner.ps1 @@ -88,7 +88,8 @@ Set-Attr $result "changed" $false; $path = Get-Attr $params "path" -failifempty $true $user = Get-Attr $params "user" -failifempty $true -$recurse = Get-Attr $params "recurse" "no" -validateSet "no","yes" -resultobj $result | ConvertTo-Bool +$recurse = Get-Attr $params "recurse" "no" -validateSet "no","yes" -resultobj $result +$recurse = $recurse | ConvertTo-Bool If (-Not (Test-Path -Path $path)) { Fail-Json $result "$path file or directory does not exist on the host" diff --git a/lib/ansible/modules/extras/windows/win_scheduled_task.py b/lib/ansible/modules/extras/windows/win_scheduled_task.py index ea1e202be7..96a9b48f95 100644 --- a/lib/ansible/modules/extras/windows/win_scheduled_task.py +++ b/lib/ansible/modules/extras/windows/win_scheduled_task.py @@ -36,10 +36,13 @@ options: description: - Name of the scheduled task required: true + description: + description: + - The description for the scheduled task + required: false enabled: description: - Enable/disable the task - required: false choices: - yes - no @@ -47,26 +50,34 @@ options: state: description: - State that the task should become - required: false + required: true choices: - present - absent + user: + description: + - User to run scheduled task as + required: false execute: description: - Command the scheduled task should execute required: false + argument: + description: + - Arguments to provide scheduled task action + required: false frequency: description: - The frequency of the command, not idempotent + required: false choices: - daily - weekly - required: false time: description: - Time to execute scheduled task, not idempotent required: false - daysOfWeek: + days_of_week: description: - Days of the week to run a weekly task, not idempotent required: false @@ -74,7 +85,6 @@ options: description: - Task folder in which this task will be stored default: '\' - required: false ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/extras/windows/win_share.ps1 b/lib/ansible/modules/extras/windows/win_share.ps1 index f409281711..6f873bed7e 100644 --- a/lib/ansible/modules/extras/windows/win_share.ps1 +++ b/lib/ansible/modules/extras/windows/win_share.ps1 @@ -22,52 +22,49 @@ #Functions Function UserSearch { - Param ([string]$AccountName) + Param ([string]$accountName) #Check if there's a realm specified - if ($AccountName.Split("\").count -gt 1) - { - if ($AccountName.Split("\")[0] -eq $env:COMPUTERNAME) + + $searchDomain = $false + $searchDomainUPN = $false + if ($accountName.Split("\").count -gt 1) { - $IsLocalAccount = $true - } - Else + if ($accountName.Split("\")[0] -ne $env:COMPUTERNAME) { - $IsDomainAccount = $true - $IsUpn = $false + $searchDomain = $true + $accountName = $accountName.split("\")[1] } - } - Elseif ($AccountName.contains("@")) + Elseif ($accountName.contains("@")) { - $IsDomainAccount = $true - $IsUpn = $true + $searchDomain = $true + $searchDomainUPN = $true } Else { #Default to local user account - $accountname = $env:COMPUTERNAME + "\" + $AccountName - $IsLocalAccount = $true + $accountName = $env:COMPUTERNAME + "\" + $accountName } - if ($IsLocalAccount -eq $true) + if ($searchDomain -eq $false) { # do not use Win32_UserAccount, because e.g. SYSTEM (BUILTIN\SYSTEM or COMPUUTERNAME\SYSTEM) will not be listed. on Win32_Account groups will be listed too - $localaccount = get-wmiobject -class "Win32_Account" -namespace "root\CIMV2" -filter "(LocalAccount = True)" | where {$_.Caption -eq $AccountName} + $localaccount = get-wmiobject -class "Win32_Account" -namespace "root\CIMV2" -filter "(LocalAccount = True)" | where {$_.Caption -eq $accountName} if ($localaccount) { return $localaccount.SID } } - ElseIf ($IsDomainAccount -eq $true) + Else { #Search by samaccountname $Searcher = [adsisearcher]"" - If ($IsUpn -eq $false) { - $Searcher.Filter = "sAMAccountName=$($accountname.split("\")[1])" + If ($searchDomainUPN -eq $false) { + $Searcher.Filter = "sAMAccountName=$($accountName)" } Else { - $Searcher.Filter = "userPrincipalName=$($accountname)" + $Searcher.Filter = "userPrincipalName=$($accountName)" } $result = $Searcher.FindOne() diff --git a/lib/ansible/modules/extras/windows/win_share.py b/lib/ansible/modules/extras/windows/win_share.py index a3be5c9af2..bca7646cf3 100644 --- a/lib/ansible/modules/extras/windows/win_share.py +++ b/lib/ansible/modules/extras/windows/win_share.py @@ -28,7 +28,7 @@ ANSIBLE_METADATA = {'status': ['preview'], DOCUMENTATION = ''' --- module: win_share -version_added: "2.0" +version_added: "2.1" short_description: Manage Windows shares description: - Add, modify or remove Windows share and set share permissions. @@ -84,7 +84,7 @@ options: - Specify user list that should get no access, regardless of implied access on share, separated by comma. required: no default: none -Hans-Joachim Kliemeck (@h0nIg) +author: Hans-Joachim Kliemeck (@h0nIg) ''' EXAMPLES = ''' @@ -114,4 +114,8 @@ EXAMPLES = ''' win_share: name: internal state: absent +''' + +RETURN = ''' + ''' \ No newline at end of file diff --git a/lib/ansible/modules/extras/windows/win_unzip.py b/lib/ansible/modules/extras/windows/win_unzip.py index cef6a1b4a2..c1e533b0d0 100644 --- a/lib/ansible/modules/extras/windows/win_unzip.py +++ b/lib/ansible/modules/extras/windows/win_unzip.py @@ -37,14 +37,10 @@ options: description: - File to be unzipped (provide absolute path) required: true - default: null - aliases: [] dest: description: - Destination of zip file (provide absolute path of directory). If it does not exist, the directory will be created. required: true - default: null - aliases: [] rm: description: - Remove the zip file, after unzipping @@ -55,7 +51,6 @@ options: - yes - no default: false - aliases: [] recurse: description: - Recursively expand zipped files within the src file. @@ -66,13 +61,11 @@ options: - false - yes - no - aliases: [] creates: description: - If this file or directory exists the specified src will not be extracted. required: no default: null - aliases: [] author: Phil Schwartz ''' diff --git a/lib/ansible/modules/extras/windows/win_uri.py b/lib/ansible/modules/extras/windows/win_uri.py index b2c9c747c5..f9e923dfaf 100644 --- a/lib/ansible/modules/extras/windows/win_uri.py +++ b/lib/ansible/modules/extras/windows/win_uri.py @@ -125,10 +125,11 @@ use_basic_parsing: type: bool sample: True body: - description: The content of the body used (added in version 2.2) + description: The content of the body used returned: when body is specified type: string sample: '{"id":1}' + version_added: "2.3" status_code: description: The HTTP Status Code of the response. returned: success