#Restoring dns config obtained through na_ontap_rest_info

1 messages · Page 1 of 1 (latest)

blissful salmon
#

Hello everybody,
I pulled my cluster's dns configuration into a text file using the rest_info module. I would like to be able to make changes to this saved configuration and push it back to the cluster. Whats the best way to do this?

rest_info gives me a list of objects of the following form:

- attempts: ...
  domains:
  - ...
  - ...
  dynamic_dns:
    enabled: ...
    time_to_live: ...
    use_secure: ...
  scope: svm
  servers:
  - ...
  - ...
  svm:
    name: ...
    uuid: ...
  timeout: 2
  uuid: ...

I tried experimenting with na_ontap_restit module, providing the objects that rest_info gave me as a body to POST or PATCH request, but that fails saying that the fields cannot be set in this operation.

modest hemlock
#

So that a little complicated, but the short answer is you can't.

FIrst
For ansible we only support the most popular parameters, and not all fields. We add parameters based on customer requests. So for instance for DNS we support we currently don't support dynamic_dns

Second
There quite a few parameters that are returned that can not be changed. For instance in your example you can not change any UUID. Changing one parameters can change others, for instance SVM.Name and SVM.UUID are tied to each other.

blissful salmon
#

Thank you for your answer.

For now, I opted for establishing base dns configs with the dns module and then patching attempts, timeout and dynamic dns based on matching the uuid, like so:

- name: Get uuids and svm names from host # noqa args[module]
  netapp.ontap.na_ontap_rest_info:
    gather_subset:
      - name-services/dns
    fields:
      - svm.name
    https: true
    hal_linking: false
  register: output

- name: Extract current dns configs
  ansible.builtin.set_fact:
    current_dns_configs: "{{ output['ontap_info']['name-services/dns']['records'] }}"

- name: Set attempts, timeout and dynamic dns settings for svms # noqa args[module]
  netapp.ontap.na_ontap_restit:
    api: "name-services/dns/{{ (current_dns_configs | selectattr('svm', 'defined') | selectattr('svm.name', '==', item.svm.name) | list | first).uuid }}"
    method: PATCH
    wait_for_completion: true
    body: "{{ item | ansible.utils.remove_keys(target=['scope', 'uuid', 'svm']) | to_json }}"
  when: item.scope != 'cluster'
  loop: "{{ dns_configs }}"

- name: Set attempts, timeout and dynamic dns settings for cluster # noqa args[module]
  netapp.ontap.na_ontap_restit:
    api: "name-services/dns/{{ (current_dns_configs | rejectattr('svm', 'defined') | list | first).uuid }}"
    method: PATCH
    wait_for_completion: true
    body: "{{ item | ansible.utils.remove_keys(target=['scope', 'uuid', 'svm']) | to_json }}"
  when: item.scope == 'cluster'
  loop: "{{ dns_configs }}"

dns_configs is my list of dns settings pulled via rest_info.