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, target=target,
ttl=ttl) ttl=ttl)
return req return req
return "Error updating record"
except APIError: except APIError:
return "Query failed in OVH API" return "Query failed in OVH API"
return None return "Error updating record"
def domain_delete_record(zone="", fieldType="", subDomain=""): def domain_delete_record(zone="", fieldType="", subDomain=""):

View File

@ -32,15 +32,15 @@ def domain_record_present(name="",
'comment': 'Config is up to date' 'comment': 'Config is up to date'
} }
if name is None: if not name:
return _error(ret, 'Must provide name to ovhapi.domain_record_present') 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') 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') 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') 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') return _error(ret, 'Must provide target to ovhapi.domain_record_present')
cur_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone) cur_zone_state = __salt__['ovhapi.domain_get_zone'](zone=zone)
@ -50,8 +50,8 @@ def domain_record_present(name="",
fieldType=recordtype, fieldType=recordtype,
subDomain=recordname, subDomain=recordname,
target=target) target=target)
if cur_record is not None: if cur_record:
res = __salt__['ovhapi.domain_put_record'](zone=zone, __salt__['ovhapi.domain_put_record'](zone=zone,
fieldType=recordtype, fieldType=recordtype,
subDomain=recordname, subDomain=recordname,
target=target) target=target)
@ -63,7 +63,7 @@ def domain_record_present(name="",
} }
res_output = f"Updated record {recordname}" res_output = f"Updated record {recordname}"
else: else:
res = __salt__['ovhapi.domain_post_record'](zone=zone, __salt__['ovhapi.domain_post_record'](zone=zone,
subDomain=recordname, subDomain=recordname,
fieldType=recordtype, fieldType=recordtype,
target=target, target=target,
@ -76,7 +76,21 @@ def domain_record_present(name="",
} }
res_output = f"Created record {recordname}" 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}' 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) }} - ttl: {{ record.ttl|default(0) }}
{%- endfor %} {%- endfor %}
{%- 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 %}