1#!/usr/bin/python
2#
3# @author: Gaurav Rastogi (grastogi@avinetworks.com)
4#          Eric Anderson (eanderson@avinetworks.com)
5# module_check: supported
6#
7# Copyright: (c) 2017 Gaurav Rastogi, <grastogi@avinetworks.com>
8# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
9#
10
11ANSIBLE_METADATA = {'metadata_version': '1.1',
12                    'status': ['preview'],
13                    'supported_by': 'community'}
14
15DOCUMENTATION = '''
16---
17module: avi_ipamdnsproviderprofile
18author: Gaurav Rastogi (@grastogi23) <grastogi@avinetworks.com>
19
20short_description: Module for setup of IpamDnsProviderProfile Avi RESTful Object
21description:
22    - This module is used to configure IpamDnsProviderProfile object
23    - more examples at U(https://github.com/avinetworks/devops)
24requirements: [ avisdk ]
25version_added: "2.4"
26options:
27    state:
28        description:
29            - The state that should be applied on the entity.
30        default: present
31        choices: ["absent", "present"]
32    avi_api_update_method:
33        description:
34            - Default method for object update is HTTP PUT.
35            - Setting to patch will override that behavior to use HTTP PATCH.
36        version_added: "2.5"
37        default: put
38        choices: ["put", "patch"]
39    avi_api_patch_op:
40        description:
41            - Patch operation to use when using avi_api_update_method as patch.
42        version_added: "2.5"
43        choices: ["add", "replace", "delete"]
44    allocate_ip_in_vrf:
45        description:
46            - If this flag is set, only allocate ip from networks in the virtual service vrf.
47            - Applicable for avi vantage ipam only.
48            - Field introduced in 17.2.4.
49            - Default value when not specified in API or module is interpreted by Avi Controller as False.
50        version_added: "2.5"
51        type: bool
52    aws_profile:
53        description:
54            - Provider details if type is aws.
55    azure_profile:
56        description:
57            - Provider details if type is microsoft azure.
58            - Field introduced in 17.2.1.
59        version_added: "2.5"
60    custom_profile:
61        description:
62            - Provider details if type is custom.
63            - Field introduced in 17.1.1.
64    gcp_profile:
65        description:
66            - Provider details if type is google cloud.
67    infoblox_profile:
68        description:
69            - Provider details if type is infoblox.
70    internal_profile:
71        description:
72            - Provider details if type is avi.
73    name:
74        description:
75            - Name for the ipam/dns provider profile.
76        required: true
77    oci_profile:
78        description:
79            - Provider details for oracle cloud.
80            - Field introduced in 18.2.1,18.1.3.
81        version_added: "2.9"
82    openstack_profile:
83        description:
84            - Provider details if type is openstack.
85    proxy_configuration:
86        description:
87            - Field introduced in 17.1.1.
88    tenant_ref:
89        description:
90            - It is a reference to an object of type tenant.
91    tencent_profile:
92        description:
93            - Provider details for tencent cloud.
94            - Field introduced in 18.2.3.
95        version_added: "2.9"
96    type:
97        description:
98            - Provider type for the ipam/dns provider profile.
99            - Enum options - IPAMDNS_TYPE_INFOBLOX, IPAMDNS_TYPE_AWS, IPAMDNS_TYPE_OPENSTACK, IPAMDNS_TYPE_GCP, IPAMDNS_TYPE_INFOBLOX_DNS, IPAMDNS_TYPE_CUSTOM,
100            - IPAMDNS_TYPE_CUSTOM_DNS, IPAMDNS_TYPE_AZURE, IPAMDNS_TYPE_OCI, IPAMDNS_TYPE_TENCENT, IPAMDNS_TYPE_INTERNAL, IPAMDNS_TYPE_INTERNAL_DNS,
101            - IPAMDNS_TYPE_AWS_DNS, IPAMDNS_TYPE_AZURE_DNS.
102        required: true
103    url:
104        description:
105            - Avi controller URL of the object.
106    uuid:
107        description:
108            - Uuid of the ipam/dns provider profile.
109extends_documentation_fragment:
110    - avi
111'''
112
113EXAMPLES = """
114  - name: Create IPAM DNS provider setting
115    avi_ipamdnsproviderprofile:
116      controller: '{{ controller }}'
117      username: '{{ username }}'
118      password: '{{ password }}'
119      internal_profile:
120        dns_service_domain:
121        - domain_name: ashish.local
122          num_dns_ip: 1
123          pass_through: true
124          record_ttl: 100
125        - domain_name: guru.local
126          num_dns_ip: 1
127          pass_through: true
128          record_ttl: 200
129        ttl: 300
130      name: Ashish-DNS
131      tenant_ref: Demo
132      type: IPAMDNS_TYPE_INTERNAL
133"""
134
135RETURN = '''
136obj:
137    description: IpamDnsProviderProfile (api/ipamdnsproviderprofile) object
138    returned: success, changed
139    type: dict
140'''
141
142from ansible.module_utils.basic import AnsibleModule
143try:
144    from ansible.module_utils.network.avi.avi import (
145        avi_common_argument_spec, avi_ansible_api, HAS_AVI)
146except ImportError:
147    HAS_AVI = False
148
149
150def main():
151    argument_specs = dict(
152        state=dict(default='present',
153                   choices=['absent', 'present']),
154        avi_api_update_method=dict(default='put',
155                                   choices=['put', 'patch']),
156        avi_api_patch_op=dict(choices=['add', 'replace', 'delete']),
157        allocate_ip_in_vrf=dict(type='bool',),
158        aws_profile=dict(type='dict',),
159        azure_profile=dict(type='dict',),
160        custom_profile=dict(type='dict',),
161        gcp_profile=dict(type='dict',),
162        infoblox_profile=dict(type='dict',),
163        internal_profile=dict(type='dict',),
164        name=dict(type='str', required=True),
165        oci_profile=dict(type='dict',),
166        openstack_profile=dict(type='dict',),
167        proxy_configuration=dict(type='dict',),
168        tenant_ref=dict(type='str',),
169        tencent_profile=dict(type='dict',),
170        type=dict(type='str', required=True),
171        url=dict(type='str',),
172        uuid=dict(type='str',),
173    )
174    argument_specs.update(avi_common_argument_spec())
175    module = AnsibleModule(
176        argument_spec=argument_specs, supports_check_mode=True)
177    if not HAS_AVI:
178        return module.fail_json(msg=(
179            'Avi python API SDK (avisdk>=17.1) or requests is not installed. '
180            'For more details visit https://github.com/avinetworks/sdk.'))
181    return avi_ansible_api(module, 'ipamdnsproviderprofile',
182                           set([]))
183
184
185if __name__ == '__main__':
186    main()
187