Properly add hostname and FQDN

This commit is contained in:
Thomas Kleinendorst 2024-04-10 17:53:34 +02:00
parent 8d27bd892c
commit d1cf27d277
2 changed files with 10 additions and 1 deletions

View file

@ -1,2 +1,2 @@
[raspberry_pis] [raspberry_pis]
192.168.50.27 192.168.50.27 hostname=raspberry-pi-1

View file

@ -34,6 +34,15 @@
# content: "{{ ansible_facts }}" # content: "{{ ansible_facts }}"
# mode: "0600" # mode: "0600"
# TODO: Replace this with setup that sets up unnattended updates on the machine itself. # TODO: Replace this with setup that sets up unnattended updates on the machine itself.
- name: Configure hostname
become: true
ansible.builtin.hostname:
name: "{{ hostname }}"
- name: Add FQDN name in /etc/hosts
become: true
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ ansible_facts['default_ipv4']['address'] }} {{ hostname }}.kleinendorst.info {{ hostname }}"
- name: Update all packages to their latest version # noqa: package-latest - name: Update all packages to their latest version # noqa: package-latest
become: true become: true
ansible.builtin.apt: ansible.builtin.apt: