ansible hostname code example
Example 1: ansible hosts
[webserver]
192.164.0.1 ansible_password=passwd
Example 2: ansible set hostname from facts
- name: Set proper hostname
hostname:
#name: hostvars[inventory_hostname].ansible_host
name: "{{ hostvars[inventory_hostname].ansible_host }}"
become: yes
when:
- ansible_facts['os_family'] == 'Suse'