playbooks: roles: bifrost-ironic-install: Set defaults for /etc/hosts
If /etc/hosts is not properly configured for localhost, then mysql will fail with the following error: Aug 31 16:06:43 vagrant-openSUSE-Leap mysql-systemd-helper[20301]: Creating MySQL privilege database... Aug 31 16:06:43 vagrant-openSUSE-Leap mysql-systemd-helper[20301]: Neither host 'vagrant-openSUSE-Leap' nor 'localhost' could be looked up with Aug 31 16:06:43 vagrant-openSUSE-Leap mysql-systemd-helper[20301]: '/usr/bin/resolveip' Aug 31 16:06:43 vagrant-openSUSE-Leap mysql-systemd-helper[20301]: Please configure the 'hostname' command to return a correct Aug 31 16:06:43 vagrant-openSUSE-Leap mysql-systemd-helper[20301]: hostname. Aug 31 16:06:43 vagrant-openSUSE-Leap mysql-systemd-helper[20301]: If you want to solve this at a later stage, restart this script Aug 31 16:06:43 vagrant-openSUSE-Leap mysql-systemd-helper[20301]: with the --force option Aug 31 16:06:43 vagrant-openSUSE-Leap systemd[1]: mysql.service: Control process exited, code=exited status=1 Aug 31 16:06:43 vagrant-openSUSE-Leap systemd[1]: Failed to start MySQL server. As such, we need to ensure that /etc/hosts is configured before starting the mysql service. Change-Id: I5f1151ab86b6190cf2310bd7fade5290d88abc1e
This commit is contained in:
parent
53c7656d65
commit
60b9a9917e
@ -27,21 +27,21 @@
|
|||||||
enable_venv: true
|
enable_venv: true
|
||||||
when: lookup('env', 'VENV') | length > 0
|
when: lookup('env', 'VENV') | length > 0
|
||||||
|
|
||||||
|
- name: "Ensure /etc/hosts has good defaults"
|
||||||
|
lineinfile:
|
||||||
|
dest: "/etc/hosts"
|
||||||
|
regexp: "{{ item.regexp }}.*({{ ansible_hostname }}|localhost).*"
|
||||||
|
line: "{{ item.contents }}"
|
||||||
|
with_items:
|
||||||
|
- { regexp: '^127\.0\.0\.1', contents: '127.0.0.1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost' }
|
||||||
|
- { regexp: '^::1', contents: '::1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost ipv6-localhost ipv6-loopback' }
|
||||||
|
|
||||||
# NOTE(sean-k-mooney) only the RabbitMQ server and MySQL db are started
|
# NOTE(sean-k-mooney) only the RabbitMQ server and MySQL db are started
|
||||||
# during bootstrapping. all other services are started in the Start phase.
|
# during bootstrapping. all other services are started in the Start phase.
|
||||||
- name: "Start database service"
|
- name: "Start database service"
|
||||||
service: name={{ mysql_service_name }} state=started enabled=yes
|
service: name={{ mysql_service_name }} state=started enabled=yes
|
||||||
when: ironic.database.host == 'localhost'
|
when: ironic.database.host == 'localhost'
|
||||||
|
|
||||||
- name: "RabbitMQ - Testing if hostname is defined in /etc/hosts"
|
|
||||||
command: grep -i "{{ ansible_hostname }}" /etc/hosts
|
|
||||||
ignore_errors: yes
|
|
||||||
register: test_grep_fix_hostname
|
|
||||||
# NOTE(sean-k-mooney) in a docker container this will fail so /etc/hosts
|
|
||||||
# should be fixed before running the bootstrap phase in a container.
|
|
||||||
- name: "RabbitMQ - Fixing /etc/hosts"
|
|
||||||
command: sed -i 's/localhost/{{ ansible_hostname }} localhost/' /etc/hosts
|
|
||||||
when: test_grep_fix_hostname.rc != 0
|
|
||||||
# NOTE(hwoarang): The erlang SUSE package forces epmd to listen on localhost
|
# NOTE(hwoarang): The erlang SUSE package forces epmd to listen on localhost
|
||||||
# address which breaks rabbitmq-server when listening on a different address.
|
# address which breaks rabbitmq-server when listening on a different address.
|
||||||
# Make sure the systemd service and socket are stopped so rabbitmq-server will
|
# Make sure the systemd service and socket are stopped so rabbitmq-server will
|
||||||
|
Loading…
Reference in New Issue
Block a user