HewlettPackard / ilo-ansible-collection

Ansible Collection and Sample Playbooks for HPE iLO
Apache License 2.0
40 stars 20 forks source link

setdns & setntpservers, behaviour with multiple fields. #12

Closed dannybeuker closed 1 year ago

dannybeuker commented 1 year ago

Hello,

The Primary, Secondary and Tertiary fields on DNS (IPv4) and SNTP are showing some (to me) unexpected behaviour. Not sure if this is intended or not. At the very least it's not clearly documented and does not seem idempotent to me. Actually found a working scenario while writing this out, which is added below.

Maybe someone can elaborate on this.

Versions.

ansible [core 2.11.7]
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Collection        Version
----------------- -------
community.general 6.0.0
hpe.ilo           1.0.20
iLO Firmware Version 2.71 Jul 04 2022

Tasks.

- name: "Set DNS"
  community.general.ilo_redfish_config:
    category: Manager
    command: SetDNSserver
    baseuri: "{{ ilo_ip }}"
    attribute_name: DNSServers
    attribute_value: "1.1.1.1 2.2.2.2"
    auth_token: "{{ ilo.session.token }}"
- name: "Set NTP"
  community.general.ilo_redfish_config:
    category: Manager
    command: SetNTPServers
    baseuri: "{{ ilo_ip }}"
    attribute_name: StaticNTPServers
    attribute_value: "1.1.1.1 2.2.2.2"
    auth_token: "{{ ilo.session.token }}"

A few things I've noticed when supplying the attribute_value.

When supplying one value, it's always the last field that gets updated.

DNS

attribute_value: "1.1.1.1" The Tertiary field would get update to 1.1.1.1, while the Primary and Secondary remain at 0.0.0.0.

SNTP

attribute_value: "1.1.1.1" The Secondary field would get updated to 1.1.1.1 and the Primary would be emtpty.

When running the playbook again, it's updating the "previous field".

DNS

attribute_value: "1.1.1.1" It would now show 0.0.0.0 on the Primary field and 1.1.1.1 on the Secondary and Tertiary field.

SNTP

attribute_value: "1.1.1.1" It would now show 1.1.1.1 on Primary and Secondary field.

When supplying more than one value.

DNS

attribute_value: "1.1.1.1 2.2.2.2" or attribute_value: "1.1.1.1 2.2.2.2 3.3.3.3" When running the playbook with two or three values, nothing gets updated. Everything remains at 0.0.0.0 or contain a single value from a previous run.

SNTP

attribute_value: "1.1.1.1 2.2.2.2" The Secondary field would get updated to 1.1.1.1 2.2.2.2 and the Primary would either be empty or containt the value from the previous run.

When running the same task multiple times with different values.

DNS

attribute_value: "1.1.1.1" in the first task attribute_value: "2.2.2.2" in the second task attribute_value: "3.3.3.3" in the third task Now the result is Primary: 1.1.1.1, Secondary: 2.2.2.2, Tertiary: 3.3.3.3

SNTP

attribute_value: "1.1.1.1" in the first task attribute_value: "2.2.2.2" in the second task Now the result is Primary: 1.1.1.1, Secondary: 2.2.2.2

So running this actually works, but you would expect that only the last value would be applied:

- name: "Set Primary DNS"
  community.general.ilo_redfish_config:
    category: Manager
    command: SetDNSserver
    baseuri: "{{ ilo_ip }}"
    attribute_name: DNSServers
    attribute_value: "1.1.1.1"
    auth_token: "{{ ilo.session.token }}"

- name: "Set Secondary DNS"
  community.general.ilo_redfish_config:
    category: Manager
    command: SetDNSserver
    baseuri: "{{ ilo_ip }}"
    attribute_name: DNSServers
    attribute_value: "2.2.2.2"
    auth_token: "{{ ilo.session.token }}"

- name: "Set Tertiary DNS"
  community.general.ilo_redfish_config:
    category: Manager
    command: SetDNSserver
    baseuri: "{{ ilo_ip }}"
    attribute_name: DNSServers
    attribute_value: "3.3.3.3"
    auth_token: "{{ ilo.session.token }}"

The following does not work, but would make more sense:

- name: "Set DNS"
  community.general.ilo_redfish_config:
    category: Manager
    command: SetDNSserver
    baseuri: "{{ ilo_ip }}"
    attribute_name: DNSServers
    attribute_value: "1.1.1.1 2.2.2.2 3.3.3.3"
    auth_token: "{{ ilo.session.token }}"
- name: "Set DNS"
  community.general.ilo_redfish_config:
    category: Manager
    command: SetDNSserver
    baseuri: "{{ ilo_ip }}"
    attribute_name: DNSServers
    attribute_value: 
      - 1.1.1.1
      - 2.2.2.2
      - 3.3.3.3
    auth_token: "{{ ilo.session.token }}"
rajeevkallur commented 1 year ago

we will check on it.

typerwrite commented 1 year ago

Thanks @dannybeuker and @rajeevkallur -

Additionally, I'm having trouble finding a way to 'Propagate NTP Time to Host'.

Did I miss this somewhere, by chance?

rajeevkallur commented 1 year ago

@dannybeuker , This is fixed in community.general collection. Please update the community.general and use the latest release of hpe.ilo collection at https://galaxy.ansible.com/hpe/ilo