From 4ba25326ed23d646646c151f6cf853bf9f79cac5 Mon Sep 17 00:00:00 2001 From: Nirmoy Das Date: Thu, 22 Feb 2018 15:54:40 +0000 Subject: [PATCH] roles: bootstrap-os: Use 'hostname' command on Tumbleweed openSUSE Tumbleweed is having the same problems with CoreOS when it comes to using the hostname ansible module (#1588, #1600) so we need to apply a similar workaround. Co-authored-by: Markos Chandras Link: http://bugzilla.opensuse.org/show_bug.cgi?id=997614 --- roles/bootstrap-os/tasks/main.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/roles/bootstrap-os/tasks/main.yml b/roles/bootstrap-os/tasks/main.yml index 139e22b5e..c921b643e 100644 --- a/roles/bootstrap-os/tasks/main.yml +++ b/roles/bootstrap-os/tasks/main.yml @@ -29,18 +29,25 @@ gather_subset: '!all' filter: ansible_* -- name: Assign inventory name to unconfigured hostnames (non-CoreOS) +- name: Assign inventory name to unconfigured hostnames (non-CoreOS and Tumbleweed) hostname: name: "{{inventory_hostname}}" - when: ansible_os_family not in ['CoreOS', 'Container Linux by CoreOS'] and override_system_hostname + when: + - override_system_hostname + - ansible_distribution not in ['openSUSE Tumbleweed'] + - ansible_os_family not in ['CoreOS', 'Container Linux by CoreOS'] -- name: Assign inventory name to unconfigured hostnames (CoreOS only) +- name: Assign inventory name to unconfigured hostnames (CoreOS and Tumbleweed only) command: "hostnamectl set-hostname {{inventory_hostname}}" register: hostname_changed - when: ansible_hostname == 'localhost' and ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] and override_system_hostname + when: + - ansible_hostname == 'localhost' + - ansible_distribution in ['openSUSE Tumbleweed'] or ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] + - override_system_hostname -- name: Update hostname fact (CoreOS only) +- name: Update hostname fact (CoreOS and Tumbleweed only) setup: gather_subset: '!all' filter: ansible_hostname - when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] and hostname_changed.changed + when: + - hostname_changed.changed