- name: Does /etc/cloud/cloud.cfg exist i.e. is this ubuntu-18 server? stat: path: /etc/cloud/cloud.cfg register: U18_server - name: 'Put "preserve_hostname: true" in /etc/cloud/cloud.cfg (ubuntu-18 server)' lineinfile: path: /etc/cloud/cloud.cfg regexp: '^preserve_hostname*' line: 'preserve_hostname: true' state: present when: U18_server is defined and U18_server.stat.exists - name: 'Turn the crank for systemd: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}" (debuntu)' shell: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}" when: is_debuntu | bool - 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 | bool # 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