Reply

Ansible NIOS schedule options

Techie
Posts: 11
1628     0

We regulary create TXT records via Ansible on a NIOS environment. These only have to be there for a week or so.

I have seen the API allows access to the scheduling options of NIOS and perhaps a scheduled delete is possible in that way, but I can't find this on Ansible. Is that correct, is there another way to do this via Ansible?

Re: Ansible NIOS schedule options

Superuser
Posts: 65
1628     0

You are correct, this has not been added to the Ansible module. You could potentially call the API directly from Ansible, using the built in uri module if you need to use API functions not available in the Infoblox modules. https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html

Re: Ansible NIOS schedule options

Techie
Posts: 11
1628     0

Thanks Jason, that turned out to be easier then expected. Still it feels like a small change to the NIOS Ansible collection.

 

For reference and perhaps others with the same challenge this is what i did.

 

- name: Find reference for created TXT record, search based on text
ansible.builtin.uri:
# start with basic auth
force_basic_auth: true
user: "{{ username }}"
password: "{{ password }}"
# GET request on TXT records with text equal to TXT string
url: https://gridmaster/wapi/v2.12.3/record:txt?text={{ txt_string }}&_return_as_object=1

- name: Schedule delete that record reference
ansible.builtin.uri:
# start with basic auth
force_basic_auth: true
user: "{{ username }}"
password: "{{ password }}"
# set HTTP method, for this delete
method: DELETE
# first variable is the reference looked up in previous request
# second variable is the current epoch time + 7 times 1 day in seconds, so scheduled delete in 7 days
url: https://gridmaster/wapi/v2.12.3/{{ record_reference.json.result[0]._ref }}?_schedinfo.scheduled_time={{ ansible_date_time.epoch | int + ( 86400 * 7 ) }}
Showing results for 
Search instead for 
Did you mean: 

Recommended for You