From edcd5bf67fd0ccc94afc60b6656216ac7de6c37c Mon Sep 17 00:00:00 2001 From: Stig Telfer Date: Fri, 26 Feb 2016 13:43:07 +0000 Subject: [PATCH] Provide a non-default hostname for CoreOS systems. A freshly-installed CoreOS system does not always have a hostname configured. This causes problems for etcd and BGP mesh configuration for Calico. Assign the Ansible inventory name as hostname as part of CoreOS bootstrap, if the hostname is the default ("localhost"). --- roles/coreos-bootstrap/tasks/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/coreos-bootstrap/tasks/main.yml b/roles/coreos-bootstrap/tasks/main.yml index 4a211ae56..bd81a2632 100644 --- a/roles/coreos-bootstrap/tasks/main.yml +++ b/roles/coreos-bootstrap/tasks/main.yml @@ -38,3 +38,11 @@ pip: name: "{{ item }}" with_items: pip_python_modules + +- name: Check configured hostname + shell: hostname + register: configured_hostname + +- name: Assign inventory name to unconfigured hostnames + shell: sh -c "echo \"{{inventory_hostname}}\" > /etc/hostname; hostname \"{{inventory_hostname}}\"" + when: configured_hostname.stdout == 'localhost'