An Ansible role to set the linux hostname on Debian and Ubuntu running systemd.
- Install or Update the HostName Support via APT
- Set the Linux HostName
Available variables are listed below, along with default values (see defaults/main.yml
):
# hostname package state ('present', 'latest') - 'absent' is not supported
# * 'present' ensures that the package is installed
# * 'latest' ensures that the latest version of the package is installed
linux_hostname__state: 'present'
# linux hostname
#linux_hostname: 'hostname'
- hosts: 'all'
tasks:
- ansible.builtin.include_role:
name: 'havlasme.linux.hostname'
vars:
linux_hostname: 'my-awesome-host'
Created in 2024 by Tomáš Havlas.