- name: Set a hostname via hostnamectl ansible.builtin.hostname: name: "{{ server_hostname }}" use: systemd when: ansible_virtualization_type == "kvm" or ansible_virtualization_type == "openstack" or ansible_virtualization_type == "NA" - name: Set a hostname and FQDN in /etc/hosts ansible.builtin.template: src: hosts dest: /etc/hosts owner: root group: root mode: 0644 - name: Set a hostname in /etc/hostname ansible.builtin.template: src: hostname dest: /etc/hostname owner: root group: root mode: 0644