From: Andrew Schoen Date: Fri, 30 Sep 2016 22:07:52 +0000 (-0500) Subject: ansible: update the cloud-init templates for /etc/hosts X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4a17c58c8ba3813171e73eb21f6739f9d7dfd507;p=ceph-build.git ansible: update the cloud-init templates for /etc/hosts If a node is rebooted the /etc/hosts file is rewritten with these template files because ``manage_etc_hosts`` is set to ``true``. This causes jobs to fail because the hostname is no longer resolveable after reboot. Signed-off-by: Andrew Schoen --- diff --git a/ansible/examples/slave.yml b/ansible/examples/slave.yml index e61ea101..61a752e2 100644 --- a/ansible/examples/slave.yml +++ b/ansible/examples/slave.yml @@ -186,22 +186,29 @@ - name: Set Hostname with hostname command sudo: yes hostname: - name: "{{ ansible_hostname }}" + name: "ceph-builders" - - name: ensure that the current host is in /etc/hosts. Yes this is a thing. + - name: ensure that 127.0.1.1 is present with an actual hostname sudo: true - replace: - backup: yes + lineinfile: dest: /etc/hosts - regexp: '^(127\.0\.1\.1(?!.*\b{{ ansible_hostname }}\b).*)$' - replace: '\1 {{ ansible_hostname }} ceph-builders' + line: '127.0.1.1 ceph-builders' - - name: ensure that 127.0.1.1 is present with an actual hostname + # we need to update the cloud templates because 'manage_etc_hosts' is + # set to true on the image we use in OVH and some jobs will reboot + # these nodes causing the /etc/hosts file to be replace with these + # templates making jobs fail because the hostname is not resolvable + - name: update the etc cloud templates for debian /etc/hosts sudo: true lineinfile: - dest: /etc/hosts - regexp: '^(127\.0\.1\.1(?!.*\b{{ ansible_hostname }}\b).*)$' - line: '127.0.1.1 {{ ansible_hostname }} ceph-builders' + dest: /etc/cloud/templates/hosts.debian.tmpl + line: '127.0.1.1 ceph-builders' + + - name: update the etc cloud templates for debian /etc/hosts + sudo: true + lineinfile: + dest: /etc/cloud/templates/hosts.redhat.tmpl + line: '127.0.1.1 ceph-builders' - name: install six, latest one sudo: true