1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/0-init/tasks/hostname.yml

44 lines
1.6 KiB
YAML

- name: Does /etc/cloud/cloud.cfg exist e.g. is this Ubuntu Server 18+ ?
stat:
path: /etc/cloud/cloud.cfg
register: cloudcfg_test
- name: "If so, ensure 'preserve_hostname: true' is in /etc/cloud/cloud.cfg"
lineinfile:
path: /etc/cloud/cloud.cfg
regexp: '^preserve_hostname*'
line: 'preserve_hostname: true'
state: present
when: cloudcfg_test.stat.exists
- name: 'Set /etc/hostname by running: hostnamectl set-hostname "{{ iiab_hostname }}"'
command: hostnamectl set-hostname "{{ iiab_hostname }}"
# 2021-08-31: Periods in /etc/hostname fail with some WiFi routers (#2904)
# command: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}"
#- name: Install /etc/sysconfig/network from template (redhat)
# template:
# src: roles/network/templates/network/sysconfig.network.j2
# dest: /etc/sysconfig/network
# owner: root
# group: root
# mode: 0644
# when: is_redhat
# roles/network/tasks/hosts.yml [no longer in use] ALSO did this:
- name: 'Put FQDN & hostnames in /etc/hosts: "127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan"'
lineinfile:
path: /etc/hosts
regexp: '^127\.0\.0\.1'
line: '127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan'
#owner: root
#group: root
#mode: 0644
#- name: Re-configuring httpd - not initial install
# include_tasks: roles/httpd/tasks/main.yml
# when: iiab_stage|int > 3
#- name: Re-configuring rest of networking - not initial install
# include_tasks: roles/network/tasks/main.yml
# when: iiab_stage|int > 4