ansible-role-hostname/tasks/main.yml
2021-07-17 00:35:12 +02:00

28 lines
591 B
YAML

- name: install dbus (needed to set the hostname with systemd)
apt:
pkg: dbus
when: not rootpath
- name: set hostname with systemd
failed_when: false
hostname:
name: "{{ inventory_hostname_short }}"
when: not rootpath
- name: customize vm image hostname
copy:
dest: "{{ rootpath }}/etc/hostname"
content: '{{ inventory_hostname_short }}'
owner: root
group: root
mode: 0644
- name: customize vm image hosts file
template:
src: hosts.j2
dest: "{{ rootpath }}/etc/hosts"
owner: root
group: root
mode: 0644
when: vm is defined