Roles only run on intended supported OS, and minor cleanup of when statements to match
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
---
|
||||
# tasks file for ensure_hostname
|
||||
- name: Assert Target OS Is Supported
|
||||
when:
|
||||
- ansible_facts["system"] is defined
|
||||
ansible.builtin.assert:
|
||||
fail_msg: "Unsupported OS: {{ ansible_facts['system'] | default('unknown') }}"
|
||||
quiet: true
|
||||
that:
|
||||
- ansible_facts["system"] == 'Linux'
|
||||
- name: Set Hostname If Localhost
|
||||
when:
|
||||
- ansible_facts["system"] == 'Linux'
|
||||
- ansible_facts["fqdn"] == 'localhost.localdomain'
|
||||
ansible.builtin.hostname:
|
||||
name: '{{ inventory_hostname }}'
|
||||
- name: Assert Hostname Verification
|
||||
ansible.builtin.assert:
|
||||
fail_msg: "Hostname is not defined"
|
||||
quiet: true
|
||||
that:
|
||||
- ansible_facts["nodename"] is defined
|
||||
- ansible_facts["nodename"] != ''
|
||||
|
||||
Reference in New Issue
Block a user