]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
testnodes: Set hostnames properly 163/head
authorZack Cerza <zack@redhat.com>
Tue, 3 Nov 2015 21:15:17 +0000 (14:15 -0700)
committerZack Cerza <zack@redhat.com>
Tue, 3 Nov 2015 21:15:17 +0000 (14:15 -0700)
Instead of using convoluted logic to determine whether or not to set the
hostname, just do it. The hostname module is nice and idempotent.

This was inspired by http://tracker.ceph.com/issues/13679

Signed-off-by: Zack Cerza <zack@redhat.com>
roles/testnode/tasks/set_hostname.yml

index 3424f67c7025ca563cf80d82faf943e280bbd243..8c51e566f153be8b3c8d46f332e930b884ec48a0 100644 (file)
@@ -1,23 +1,8 @@
 ---
-- name: Get hostname.
-  command: hostname
-  register: existing_hostname
-  changed_when: false
-
-- name: Correct hostname if it is 'localhost'
-  set_fact:
-    new_hostname: "{{ inventory_hostname.split('.')[0] }}"
-  when: existing_hostname is defined and
-        existing_hostname.stdout.find("localhost") != -1
-
-- name: Remove lab domain from hostname.
+- name: Set hostname var
   set_fact:
-    new_hostname: "{{ existing_hostname.stdout.split('.')[0] }}"
-  when: existing_hostname is defined and
-        existing_hostname.stdout.find("{{ lab_domain }}") != -1
+    hostname: "{{ inventory_hostname.split('.')[0] }}"
 
-- name: Set hostname.
+- name: "Set the system's hostname"
   hostname:
-     name: "{{ new_hostname }}"
-  when: existing_hostname is defined and
-        existing_hostname.stdout != new_hostname
+     name: "{{ hostname }}"