updated ovh modules

This commit is contained in:
Paul 2021-02-09 01:29:48 +01:00
parent e133fc3f5f
commit 5fedd247c9
3 changed files with 15 additions and 16 deletions

View File

@ -69,7 +69,6 @@ def domain_get_record(zone="", fieldType="", subDomain="", target=""):
if zone == "":
raise ArgumentValueError("Zone is not defined")
res = None
client = _auth()
try:
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}')
if res['target'] == target:
return res
return None
except APIError:
return "Query failed in OVH API"
return None
@ -149,13 +147,14 @@ def domain_put_record(zone="",
fieldType=fieldType,
subDomain=subDomain)
if len(records) > 0:
record = client.get(f'/domain/zone/{zone}/record/{records[0]}')
req = client.put(f'/domain/zone/{zone}/record/{record["id"]}',
for rec in records:
res = client.get(f'/domain/zone/{zone}/record/{rec}')
if res['target'] == target:
req = client.put(f'/domain/zone/{zone}/record/{rec["id"]}',
subDomain=subDomain,
target=target,
ttl=ttl)
return req
else:
return "Error updating record"
except APIError:
return "Query failed in OVH API"

View File

@ -17,11 +17,11 @@ def _str_split(string):
return [e + delim for e in string.split(delim) if e]
def domain_record_present(name,
zone=None,
recordname=None,
recordtype=None,
target=None,
def domain_record_present(name="",
zone="",
recordname="",
recordtype="A",
target="",
ttl=0):
res_output = ""

View File

@ -6,7 +6,7 @@ ovh-domain-{{ domain }}-{{ "{}-{}-{}".format(record.name, record.type, record.ta
ovhapi.domain_record_present:
- name: ovh-domain-{{ domain }}-{{ "{}-{}-{}".format(record.name, record.type, record.target)|md5 }}
- zone: {{ domain }}
- recordname: {{ record.name }}
- recordname: "{{ record.name }}"
- recordtype: {{ record.type }}
- target: {{ record.target }}
- ttl: {{ record.ttl|default(0) }}