updated ovh state and modules
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2022-08-06 20:23:43 +02:00
parent 473f8c63d0
commit 2c28b44206
3 changed files with 41 additions and 21 deletions

View File

@ -154,11 +154,10 @@ def domain_put_record(zone="",
target=target,
ttl=ttl)
return req
return "Error updating record"
except APIError:
return "Query failed in OVH API"
return None
return "Error updating record"
def domain_delete_record(zone="", fieldType="", subDomain=""):

View File

@ -32,29 +32,29 @@ def domain_record_present(name="",
'comment': 'Config is up to date'
}
if name is None:
if not name:
return _error(ret, 'Must provide name to ovhapi.domain_record_present')
if zone is None:
if not zone:
return _error(ret, 'Must provide dns zone to ovhapi.domain_record_present')
if recordname is None:
if not recordname:
return _error(ret, 'Must provide record name to ovhapi.domain_record_present')
if recordtype is None:
if not recordtype:
return _error(ret, 'Must provide record type to ovhapi.domain_record_present')
if target is None:
if not target:
return _error(ret, 'Must provide target to ovhapi.domain_record_present')
cur_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone)
# check if record exists
cur_record = __salt__['ovhapi.domain_get_record'](zone=zone,
fieldType=recordtype,
subDomain=recordname,
target=target)
if cur_record is not None:
res = __salt__['ovhapi.domain_put_record'](zone=zone,
fieldType=recordtype,
subDomain=recordname,
target=target)
fieldType=recordtype,
subDomain=recordname,
target=target)
if cur_record:
__salt__['ovhapi.domain_put_record'](zone=zone,
fieldType=recordtype,
subDomain=recordname,
target=target)
new_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone)
ret['changes'] = {
@ -63,11 +63,11 @@ def domain_record_present(name="",
}
res_output = f"Updated record {recordname}"
else:
res = __salt__['ovhapi.domain_post_record'](zone=zone,
subDomain=recordname,
fieldType=recordtype,
target=target,
ttl=ttl)
__salt__['ovhapi.domain_post_record'](zone=zone,
subDomain=recordname,
fieldType=recordtype,
target=target,
ttl=ttl)
new_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone)
ret['changes'] = {
@ -76,7 +76,21 @@ def domain_record_present(name="",
}
res_output = f"Created record {recordname}"
cur_zone_refresh = __salt__['ovhapi.domain_refresh_zone'](zone=zone)
ret['comment'] = f'Result is {res_output}'
return ret
def domain_zone_refresh(name="", zone=""):
res_output = ""
ret = {
'name': name,
'changes': {},
'result': True,
'comment': 'Zone is refreshed'
}
res_output = __salt__['ovhapi.domain_refresh_zone'](zone=zone)
ret['comment'] = f'Result is {res_output}'

View File

@ -12,3 +12,10 @@ ovh-domain-{{ domain }}-{{ "{}-{}-{}".format(record.name, record.type, record.ta
- ttl: {{ record.ttl|default(0) }}
{%- endfor %}
{%- endfor %}
{%- for domain in ovh.domain.zones.keys() %}
ovh-domain-refresh-{{ domain }}:
ovhapi.domain_zone_refresh:
- name: ovh-domain-refresh-{{ domain }}
- zone: {{ domain }}
{%- endfor %}