ansible/roles/hostname/tasks/main.yaml

24 lines
580 B
YAML
Raw Permalink Normal View History

2024-09-15 14:12:48 +03:00
- 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