Merge "Workaround for Bifrost being unable to write to /etc/hosts"

This commit is contained in:
Zuul 2018-03-13 08:24:23 +00:00 committed by Gerrit Code Review
commit e160734abc

View File

@ -44,15 +44,16 @@
- { src: "id_rsa.pub", dest: "id_rsa.pub" } - { src: "id_rsa.pub", dest: "id_rsa.pub" }
- { src: "ssh_config", dest: "ssh_config" } - { src: "ssh_config", dest: "ssh_config" }
# NOTE(mgoddard): The following two tasks were lifted from the Bifrost plays. # NOTE(mgoddard): The following task was lifted from a Bifrost play
# Because Bifrost cannot modify /etc/hosts from within the container we must # (playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml). Because
# do it here. # Bifrost cannot modify /etc/hosts from within the container we must do it
- name: "RabbitMQ - Testing if hostname is defined in /etc/hosts" # here.
command: grep -i "{{ ansible_hostname }}" /etc/hosts - name: "Ensure /etc/hosts has good defaults"
ignore_errors: yes lineinfile:
register: test_grep_fix_hostname dest: "/etc/hosts"
regexp: "{{ item.regexp }}.*({{ ansible_hostname }}|localhost).*"
- name: "RabbitMQ - Fixing /etc/hosts" line: "{{ item.contents }}"
command: sed -i 's/localhost/{{ ansible_hostname }} localhost/' /etc/hosts with_items:
when: test_grep_fix_hostname.rc != 0 - { regexp: '^127\.0\.0\.1', contents: '127.0.0.1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost' }
become: True - { regexp: '^::1', contents: '::1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost ipv6-localhost ipv6-loopback' }
become: true