bundles/powerdns: split "add ip to autoprimaries" and "fix hostname for autoprimary"
This commit is contained in:
parent
261c284f2f
commit
1260410eae
1 changed files with 17 additions and 4 deletions
|
@ -175,14 +175,27 @@ if node.metadata.get('powerdns/features/pgsql', node.has_bundle('postgresql')):
|
|||
for hostname, ips in node.metadata.get('powerdns/my_primary_servers', {}).items():
|
||||
for ip in ips:
|
||||
ip_name = ip.replace(':', '-')
|
||||
actions[f'powerdns_ensure_{hostname}_{ip_name}_in_autoprimaries'] = {
|
||||
'command': 'psql -c "INSERT INTO supermasters (ip, nameserver, account) VALUES '
|
||||
f'(\'{ip}\', \'{hostname}\', \'admin\') ON CONFLICT ON CONSTRAINT '
|
||||
f'supermasters_pkey DO UPDATE SET nameserver = \'{hostname}\'" powerdns',
|
||||
|
||||
actions[f'powerdns_ensure_{ip_name}_in_autoprimaries'] = {
|
||||
'command': f'psql -c "INSERT INTO supermasters (ip, nameserver, account) VALUES (\'{ip}\', \'{hostname}\', \'admin\')" powerdns',
|
||||
'unless': f'test -n \"$(psql -tAqc "SELECT nameserver FROM supermasters WHERE ip = \'{ip}\'" powerdns)\"',
|
||||
'triggers': {
|
||||
'action:powerdns_fix_primaries',
|
||||
},
|
||||
'after': {
|
||||
'action:powerdns_load_pgsql_schema',
|
||||
},
|
||||
}
|
||||
|
||||
actions[f'powerdns_ensure_{hostname}_matches_{ip_name}_in_autoprimaries'] = {
|
||||
'command': f'psql -c "UPDATE supermasters SET nameserver = \'{hostname}\' WHERE ip = \'{ip}\'" powerdns',
|
||||
'unless': f'bash -c "[ \"$(psql -tAqc "SELECT nameserver FROM supermasters WHERE ip = \'{ip}\'" powerdns)\" == \"{hostname}\" ]"',
|
||||
'triggers': {
|
||||
'action:powerdns_fix_primaries',
|
||||
},
|
||||
'after': {
|
||||
f'action:powerdns_ensure_{ip_name}_in_autoprimaries',
|
||||
},
|
||||
}
|
||||
|
||||
actions['powerdns_fix_primaries'] = {
|
||||
|
|
Loading…
Reference in a new issue