ansible-collection
ansible-collection copied to clipboard
Feature request: Multiple values
Hello,
I would like to be able to define a record with multiple values, e.g. an "A" record with multiple IP addresses.
I know this means multiple records in the nameserver and I could use a loop in Ansible to create those records. However, doing it that way means I can't use the "solo" option because it would leave only a single record.
Therefore it would be helpful if the INWX module allowed to define a list of values. For example:
- name: Create multiple A records
inwx.collection.dns:
domain: example.com
record: test
solo: true
type: A
value:
- 1.1.1.1
- 2.2.2.2
I would expect this to create two A records for test.example.com with values 1.1.1.1 and 2.2.2.2, and remove all other A records for test.example.com.
Hi, you can remove all records with a specific name this way:
- name: Create an A record
inwx.collection.dns:
domain: example.com
type: A
record: test
# value: '1.2.3.4' No value here, this way all records with the name 'test' are selected and deleted because of state=absent
state: absent
username: test_user
password: test_password
After that you can add new records in a loop.
If you want to do both deleting and inserting in one task you can do it like this:
- name: Clear old records and replace with new ones
inwx.collection.dns:
domain: example.com
type: A
record: test
value: '{{ item }}'
# If first item in loop -> set solo to true to delete all other records with same name
# Set solo to false for all following records in loop to not override them again
solo: "{{ 'true' if inwx_a_record_values[0] == item else 'false' }}"
username: test_user
password: test_password
loop: '{{ inwx_a_record_values }}'
inwx_a_record_values
looks like this:
---
inwx_a_record_values:
- 1.1.1.1
- 2.2.2.2
- 3.3.3.3
Thanks for this workaround! But there is still a problem: It recreates at least some of the records every time. I'm looking for a solution that does not perform unnecessary updates while keeping things as simple as possible.
+1 Im here for just the same feature request. I utilize this collection for my acme challenges.
more details: https://github.com/felixfontein/ansible-acme/pull/19
in my case the values look like this:
value: "['XXX', 'YYY']"
record: _acme-challenge
It would also be nice if the module would make it possible to combine the solo
option with this.
so the module would ensure that ONLY THIS TWO records are present.
Hey, as there seems to be some interest in this feature I'm going to implement this. It will probably be released with new record types (#12) in 1.3.0. But I can't guarantee any specific release date.