I'm using salt-cloud to deploy VMs and I'm trying to get them registred in my DNS with the Saltstack Reactor system.
I have a reactor.conf with this trigger:
reactor:
- 'salt/cloud/*/created': # Add a VM
- /srv/reactor/initialize_vm.sls
initilize_vm.sls :
invoke_orchestrate_add_to_dns:
runner.state.orchestrate:
- mods: orch.add_to_dns
- pillar:
event_name: {{ name }}
event_profile: {{ profile }}
orch/add_to_dns.sls:
{% set name = pillar['event_name'] %}
{% set profile = pillar['event_profile'] %}
vm-add-dns-{{ name }}:
sqlite3.row_present:
- db: /var/lib/powerdns/pdns.sqlite3
- table: records
- where_sql: "name='{{ name }}' and type='A'"
- data:
domain_id: 1
name: {{ name }}
type: A
content: {{ ??? }}
ttl: 300
prio: 0
disabled: 0
I just need to know the IP address of the new minion. But as the orchestration run on the master, I can't just do a content: {{ grains['fqdn_ip4'] }}.
Any ideas to get minions informations ?