Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from ceph/wip-correct-hostname
testnodes: Set hostnames properly Reviewed-by: Dan Mick <dmick@redhat.com>
- Loading branch information
Showing
1 changed file
with
4 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }}" |