22# -*- coding: utf-8 -*-
33
44# Copyright: (c) 2022, Tim Cragg (@timcragg)
5+ # Copyright: (c) 2024, Akini Ross (@akinross)
56# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
67
78from __future__ import absolute_import , division , print_function
2223 - Name of the DNS profile.
2324 type: str
2425 aliases: [ name, profile_name ]
26+ management_epg:
27+ description:
28+ - Name of the management EPG.
29+ - Specify C("") to remove the management EPG configuration.
30+ type: str
31+ aliases: [ epg ]
32+ management_epg_type:
33+ description:
34+ - The type of the management EPG.
35+ type: str
36+ choices: [ inband, ooband ]
37+ aliases: [ type ]
38+ default: ooband
2539 state:
2640 description:
2741 - Use C(present) or C(absent) for adding or removing.
3953 link: https://developer.cisco.com/docs/apic-mim-ref/
4054author:
4155- Tim Cragg (@timcragg)
56+ - Akini Ross (@akinross)
4257"""
4358
4459EXAMPLES = r"""
5166 state: present
5267 delegate_to: localhost
5368
54- - name: Remove a DNS profile
69+ - name: Add a new DNS profile with a inband management EPG
5570 cisco.aci.aci_dns_profile:
5671 host: apic
5772 username: admin
5873 password: SomeSecretPassword
5974 dns_profile: my_dns_prof
60- state: absent
75+ management_epg: ansible_mgmt_epg_inband
76+ management_epg_type: inband
77+ state: present
78+ delegate_to: localhost
79+
80+ - name: Add a new DNS profile with a out-of-band management EPG
81+ cisco.aci.aci_dns_profile:
82+ host: apic
83+ username: admin
84+ password: SomeSecretPassword
85+ dns_profile: my_dns_prof
86+ management_epg: ansible_mgmt_epg_ooband
87+ state: present
88+ delegate_to: localhost
89+
90+ - name: Remove a management EPG from a DNS profile
91+ cisco.aci.aci_dns_profile:
92+ host: apic
93+ username: admin
94+ password: SomeSecretPassword
95+ dns_profile: my_dns_prof
96+ management_epg: ""
97+ state: present
6198 delegate_to: localhost
6299
63100- name: Query a DNS profile
78115 state: query
79116 delegate_to: localhost
80117 register: query_result
118+
119+ - name: Remove a DNS profile
120+ cisco.aci.aci_dns_profile:
121+ host: apic
122+ username: admin
123+ password: SomeSecretPassword
124+ dns_profile: my_dns_prof
125+ state: absent
126+ delegate_to: localhost
81127"""
82128
83129RETURN = r"""
187233
188234from ansible .module_utils .basic import AnsibleModule
189235from ansible_collections .cisco .aci .plugins .module_utils .aci import ACIModule , aci_argument_spec , aci_annotation_spec
236+ from ansible_collections .cisco .aci .plugins .module_utils .constants import MANAGEMENT_EPG_TYPE
190237
191238
192239def main ():
193240 argument_spec = aci_argument_spec ()
194241 argument_spec .update (aci_annotation_spec ())
195242 argument_spec .update (
196243 dns_profile = dict (type = "str" , aliases = ["name" , "profile_name" ]),
244+ management_epg = dict (type = "str" , aliases = ["epg" ]),
245+ management_epg_type = dict (type = "str" , default = "ooband" , choices = ["inband" , "ooband" ], aliases = ["type" ]),
197246 state = dict (type = "str" , default = "present" , choices = ["absent" , "present" , "query" ]),
198247 )
199248
@@ -207,8 +256,10 @@ def main():
207256 )
208257
209258 dns_profile = module .params .get ("dns_profile" )
259+ management_epg = module .params .get ("management_epg" )
260+ management_epg_type = MANAGEMENT_EPG_TYPE .get (module .params .get ("management_epg_type" ))
210261 state = module .params .get ("state" )
211- child_classes = ["dnsProv" , "dnsDomain" ]
262+ child_classes = ["dnsProv" , "dnsDomain" , "dnsRsProfileToEpg" ]
212263
213264 aci = ACIModule (module )
214265 aci .construct_url (
@@ -224,9 +275,35 @@ def main():
224275 aci .get_existing ()
225276
226277 if state == "present" :
278+
279+ child_configs = []
280+ if management_epg is not None :
281+ if management_epg == "" :
282+ child_configs .append (
283+ dict (
284+ dnsRsProfileToEpg = dict (
285+ attributes = dict (
286+ tDn = "" ,
287+ status = "deleted" ,
288+ )
289+ )
290+ )
291+ )
292+ else :
293+ child_configs .append (
294+ dict (
295+ dnsRsProfileToEpg = dict (
296+ attributes = dict (
297+ tDn = "uni/tn-mgmt/mgmtp-default/{0}-{1}" .format (management_epg_type , management_epg ),
298+ )
299+ )
300+ )
301+ )
302+
227303 aci .payload (
228304 aci_class = "dnsProfile" ,
229305 class_config = dict (name = dns_profile ),
306+ child_configs = child_configs ,
230307 )
231308
232309 aci .get_diff (aci_class = "dnsProfile" )
0 commit comments