updated ovh modules
This commit is contained in:
parent
e133fc3f5f
commit
5fedd247c9
@ -69,7 +69,6 @@ def domain_get_record(zone="", fieldType="", subDomain="", target=""):
|
|||||||
|
|
||||||
if zone == "":
|
if zone == "":
|
||||||
raise ArgumentValueError("Zone is not defined")
|
raise ArgumentValueError("Zone is not defined")
|
||||||
res = None
|
|
||||||
client = _auth()
|
client = _auth()
|
||||||
try:
|
try:
|
||||||
records = client.get(f'/domain/zone/{zone}/record',
|
records = client.get(f'/domain/zone/{zone}/record',
|
||||||
@ -80,7 +79,6 @@ def domain_get_record(zone="", fieldType="", subDomain="", target=""):
|
|||||||
res = client.get(f'/domain/zone/{zone}/record/{rec}')
|
res = client.get(f'/domain/zone/{zone}/record/{rec}')
|
||||||
if res['target'] == target:
|
if res['target'] == target:
|
||||||
return res
|
return res
|
||||||
return None
|
|
||||||
except APIError:
|
except APIError:
|
||||||
return "Query failed in OVH API"
|
return "Query failed in OVH API"
|
||||||
return None
|
return None
|
||||||
@ -149,14 +147,15 @@ def domain_put_record(zone="",
|
|||||||
fieldType=fieldType,
|
fieldType=fieldType,
|
||||||
subDomain=subDomain)
|
subDomain=subDomain)
|
||||||
if len(records) > 0:
|
if len(records) > 0:
|
||||||
record = client.get(f'/domain/zone/{zone}/record/{records[0]}')
|
for rec in records:
|
||||||
req = client.put(f'/domain/zone/{zone}/record/{record["id"]}',
|
res = client.get(f'/domain/zone/{zone}/record/{rec}')
|
||||||
subDomain=subDomain,
|
if res['target'] == target:
|
||||||
target=target,
|
req = client.put(f'/domain/zone/{zone}/record/{rec["id"]}',
|
||||||
ttl=ttl)
|
subDomain=subDomain,
|
||||||
return req
|
target=target,
|
||||||
else:
|
ttl=ttl)
|
||||||
return "Error updating record"
|
return req
|
||||||
|
return "Error updating record"
|
||||||
except APIError:
|
except APIError:
|
||||||
return "Query failed in OVH API"
|
return "Query failed in OVH API"
|
||||||
|
|
||||||
|
@ -17,11 +17,11 @@ def _str_split(string):
|
|||||||
return [e + delim for e in string.split(delim) if e]
|
return [e + delim for e in string.split(delim) if e]
|
||||||
|
|
||||||
|
|
||||||
def domain_record_present(name,
|
def domain_record_present(name="",
|
||||||
zone=None,
|
zone="",
|
||||||
recordname=None,
|
recordname="",
|
||||||
recordtype=None,
|
recordtype="A",
|
||||||
target=None,
|
target="",
|
||||||
ttl=0):
|
ttl=0):
|
||||||
|
|
||||||
res_output = ""
|
res_output = ""
|
||||||
|
@ -6,7 +6,7 @@ ovh-domain-{{ domain }}-{{ "{}-{}-{}".format(record.name, record.type, record.ta
|
|||||||
ovhapi.domain_record_present:
|
ovhapi.domain_record_present:
|
||||||
- name: ovh-domain-{{ domain }}-{{ "{}-{}-{}".format(record.name, record.type, record.target)|md5 }}
|
- name: ovh-domain-{{ domain }}-{{ "{}-{}-{}".format(record.name, record.type, record.target)|md5 }}
|
||||||
- zone: {{ domain }}
|
- zone: {{ domain }}
|
||||||
- recordname: {{ record.name }}
|
- recordname: "{{ record.name }}"
|
||||||
- recordtype: {{ record.type }}
|
- recordtype: {{ record.type }}
|
||||||
- target: {{ record.target }}
|
- target: {{ record.target }}
|
||||||
- ttl: {{ record.ttl|default(0) }}
|
- ttl: {{ record.ttl|default(0) }}
|
||||||
|
Loading…
Reference in New Issue
Block a user