set hostname ansible code example
Example: 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'