API & Integration

Reply

Ansible & Infoblox return_facts and Variables

RichB
Techie
Posts: 3
5103     0

Hi All

I wrote a simple play to add a host entry using Ansible to Infoblox

 

As per below all works no problem

---
- hosts: localhost
  connection: local
  gather_facts: true
  tasks:
    - name: Create a Host Record in 11.11.11/24 for "bslnetworks.com"
      nios_host_record:
       name: router1-loopback0.bslnetworks.com
       ipv4:
         - address: 11.11.11.17
       state: present
       provider:
         host: 10.61.246.190
         username: admin
         password: adm1n

 

Now what im trying to do is set a fact or register a variable to the value of the ip address so that i can reuse that variable value.

 

I've tried these so far and with no luck

 

    - name: Set a fact ....
      set_fact:
       loopback0:
         "{{ lookup('nios', 'record:host', filter={'name':'router1-loopback0.bslnetworks.com'}, provider={'host': '10.61.246.190', 'username': 'admin', 'password': 'adm1n'}) }}"
    - debug: var=loopback0


    - name: set another fact
      set_fact:
       newfact=ansible_facts.ipv4.address
    - debug: var=newfact

I can't seem to quite get there and if anyone could offer any help it would be much appreciated

Cheers

RichB

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You