added hostname setting

This commit is contained in:
Markus Rosenstihl 2024-02-12 17:10:16 +01:00
parent e5b9b9b702
commit d0bcad1a06

View File

@ -184,7 +184,7 @@
- name: Update default dock confuguration
command: dconf update
- name: Search for string in file
- name: Search for inventory in file
command:
cmd: grep -oP inventory_number=\\K\\d+ /etc/inventory_number.cmdline
register: result
@ -200,5 +200,19 @@
{{ result.stdout_lines[0] }}
when: result.rc == 0
- name: Search for hostname in file
command:
cmd: grep -oP inventory_number=\\K\\w+ /etc/inventory_number.cmdline
register: result_hostname
# Since it is a reporting task
# which needs to deliver a result in any case
failed_when: result_hostname.rc != 0 and result_hostname.rc != 1
check_mode: false
changed_when: false
- name: Set hostname
command: hostnamectl set-hostname {{ result_hostname.stdout_lines[0] }}
when: result_hostname.rc == 0
- name: Enable login screen after install
command: systemctl start systemd-logind.service