Skip to content
Snippets Groups Projects
Commit e6ff8c92 authored by Oliver Moser's avatar Oliver Moser Committed by Matthew Mosesohn
Browse files

Using 'hostnamectl' to set unconfigured hostname on CoreOS (#1600)

parent 9bce364b
No related branches found
No related tags found
No related merge requests found
...@@ -21,9 +21,20 @@ ...@@ -21,9 +21,20 @@
- name: Gather nodes hostnames - name: Gather nodes hostnames
setup: setup:
gather_subset: '!all' gather_subset: '!all'
filter: ansible_hostname filter: ansible_*
- name: Assign inventory name to unconfigured hostnames - name: Assign inventory name to unconfigured hostnames (non-CoreOS)
hostname: hostname:
name: "{{inventory_hostname}}" name: "{{inventory_hostname}}"
when: ansible_hostname == 'localhost' when: ansible_os_family not in ['CoreOS', 'Container Linux by CoreOS']
- name: Assign inventory name to unconfigured hostnames (CoreOS only)
command: "hostnamectl set-hostname {{inventory_hostname}}"
register: hostname_changed
when: ansible_hostname == 'localhost' and ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
- name: Update hostname fact (CoreOS only)
setup:
gather_subset: '!all'
filter: ansible_hostname
when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] and hostname_changed.changed
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment