Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Multiple values #9

Open
laemm-line opened this issue Jun 13, 2021 · 4 comments
Open

Feature request: Multiple values #9

laemm-line opened this issue Jun 13, 2021 · 4 comments

Comments

@laemm-line
Copy link

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.

@NickUfer
Copy link
Contributor

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

@laemm-line
Copy link
Author

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.

@Kariton
Copy link

Kariton commented Oct 25, 2021

+1
Im here for just the same feature request.
I utilize this collection for my acme challenges.

more details: felixfontein/ansible-acme#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.

@NickUfer
Copy link
Contributor

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.

Kariton added a commit to Kariton/ansible-acme that referenced this issue Oct 28, 2021
Kariton added a commit to Kariton/ansible-acme that referenced this issue Oct 28, 2021
* [FIX] multiple record values dns-inwx-create.yml
this is necessary as long as inwx/ansible-collection#9 is not resolved.

* Update general_role_parameters.rst

* Update acme_certificate_role.rst
felixfontein added a commit to felixfontein/ansible-acme that referenced this issue Oct 31, 2021
* [ADD] DNS hoster INWX (#1)

* [ADD] DNS provider 'INWX' to argument_specs.yml

* [ADD] INWX sanity checks

* [ADD] INWX create

* [ADD] INWX cleanup

* [FIX] typo in argument_specs.yml

* [FIX] typo 'wait_for_txt' dns-inwx-create.yml

Remove `always_ask_default_resolver: false` from module `community.dns.wait_for_txt` while 'Wait for DNS entries to propagate'

* [FIX] INWX and docs (#2)

* [FIX] multiple record values dns-inwx-create.yml
this is necessary as long as inwx/ansible-collection#9 is not resolved.

* Update general_role_parameters.rst

* Update acme_certificate_role.rst

* Update dns-inwx-cleanup.yml (#3)

* I should update the general requirements

* Create 19-add-inwx-dns-provider.yaml (#4)

* [FIX] Sanity (Ⓐstable-2.10) / Extra Sanity

`ERROR: docs/docsite/rst/general_role_parameters.rst:95:0: Bullet list ends without a blank line; unexpected unindent.` /
`./docs/docsite/rst/general_role_parameters.rst:95:0: (WARNING/2) Bullet list ends without a blank line; unexpected unindent.`

I hope that is the needed fix.

* Update docs/docsite/rst/general_role_parameters.rst

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update docs/docsite/rst/general_role_parameters.rst

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update docs/docsite/rst/requirements.rst

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update roles/acme_certificate/meta/argument_specs.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update roles/acme_certificate/tasks/dns-inwx-create.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update docs/docsite/rst/general_role_parameters.rst

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update docs/docsite/rst/general_role_parameters.rst

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update roles/acme_certificate/tasks/dns-inwx-create.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/19-add-inwx-dns-provider.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants