fix: use var .native.set_hostname

Signed-off-by: William Wang <williamw0825@gmail.com>
This commit is contained in:
William Wang 2025-12-03 22:51:03 +08:00
parent 67fd6098c1
commit 99116417d1
2 changed files with 3 additions and 3 deletions

View File

@ -3,7 +3,7 @@
hostnamectl set-hostname {{ .inventory_hostname }} \
&& sed -i '/^127.0.1.1/s/.*/127.0.1.1 {{ .inventory_hostname }}/g' {{ .item }}
when:
- .set_hostname
- .native.set_hostname
- .inventory_hostname | ne "localhost"
loop: "{{ .native.localDNS | toJson }}"
- name: OS | Synchronize initialization script to remote node

View File

@ -2,13 +2,13 @@
- name: OS | Assert valid system hostname format
block:
- name: OS | Validate inventory hostname is RFC-compliant
when: .set_hostname
when: .native.set_hostname
assert:
that: .inventory_hostname | regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$"
fail_msg: >-
The hostname "{{ .inventory_hostname }}" is invalid. Hostnames must use only lowercase alphanumeric characters, '.', or '-', and must start and end with an alphanumeric character.
- name: OS | Validate current host system hostname is RFC-compliant
when: .set_hostname | not
when: .native.set_hostname | not
assert:
that: .hostname | regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$"
fail_msg: >-