Chris Hammer d737b08719
All checks were successful
continuous-integration/drone/push Build is passing
Nix hostname for containers; v1.0.27
2024-03-01 10:46:12 -05:00

19 lines
597 B
YAML

---
- name: Use hostname module to set hostname, or failback to command module
when:
- not ansible_virtualization_type | regex_search("docker|podman|container")
block:
- name: Set hostname for host using hostname module
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
notify:
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
rescue:
- name: Unable to set hostname
ansible.builtin.debug:
msg: "Unable to set hostname for {{ ansible_hostname }} to {{ inventory_hostname }}."
...