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

50 lines
2 KiB
YAML
Raw Normal View History

- name: "Set 'iiab_fqdn: {{ iiab_hostname }}.{{ iiab_domain }}'"
set_fact:
iiab_fqdn: "{{ iiab_hostname }}.{{ iiab_domain }}"
FQDN_changed: False
- 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:
2018-11-02 22:29:55 +00:00
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-10-29 16:22:42 +00:00
when: not ansible_is_chroot
# 2021-08-31: Periods in /etc/hostname fail with some WiFi routers (#2904)
# command: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}"
# should the first entry match just hostname and domain move to after localhost?
- name: 'Put FQDN & hostnames in /etc/hosts: "127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan"'
lineinfile:
2018-11-02 22:29:55 +00:00
path: /etc/hosts
2018-02-13 13:54:30 +00:00
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
# 2021-07-30: FQDN_changed isn't used as in the past -- its remaining use is
# for {named, dhcpd, squid} in roles/network/tasks/main.yml -- possibly it
# should be reconsidered? See PR #2876: roles/network might become optional?
- name: "Also set 'FQDN_changed: True' -- if iiab_fqdn != ansible_fqdn ({{ ansible_fqdn }})"
set_fact:
FQDN_changed: True
when: iiab_fqdn != ansible_fqdn
2017-11-18 17:40:40 +00:00
#- name: Re-configuring httpd - not initial install
# include_tasks: roles/httpd/tasks/main.yml
# when: iiab_stage|int > 3
2017-11-05 21:11:14 +00:00
2017-11-13 02:52:02 +00:00
#- name: Re-configuring rest of networking - not initial install
# include_tasks: roles/network/tasks/main.yml
# when: iiab_stage|int > 4