Skip to content

Commit

Permalink
Merge pull request #163 from ceph/wip-correct-hostname
Browse files Browse the repository at this point in the history
testnodes: Set hostnames properly

Reviewed-by: Dan Mick <dmick@redhat.com>
  • Loading branch information
dmick committed Nov 3, 2015
2 parents 853d140 + c5189b1 commit a49991c
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions roles/testnode/tasks/set_hostname.yml
@@ -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 }}"

0 comments on commit a49991c

Please sign in to comment.