Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C34552F8B for ; Sat, 9 Mar 2024 23:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710027368; cv=none; b=nL695b92kpVBtZ7QrmlULQDUtcMFba2syk2VtW490ufpZyeUG7uMMdg5uRPP3UBfZMRtM6JAGbwfM0vdPYAmCKbBpa1GidLnezoYbAXhkSUKTjl44vJ/3xSVFTXWZNkfp4Ti+0pjg8VNDpPVRVV/cQ7gdNKK35th4iEPt63mTwg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710027368; c=relaxed/simple; bh=QtJhPLTGMr7molSnvJAN2u1oE5lrWRdNlO8xBvPTm4E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DnRa9+tKeH3qv46fC/nPeWxJGx4FlKH5Bt/d+XMBoyaZ53cM83mlRYX/OQl0xVU3Y1t3tYOUIkffFOdVOOYtZdhU6X/MUkuVYJ+1bL8autxuy5stUK5Fq4Vo5XBkcy+dapoRz9VTT8Dhx53eKZYBI9tU/oACumO4ZN3ugdz0FT4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ft2e9ypa; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ft2e9ypa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710027365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=17Em+yXhMwi7GyReKEHGl4ToDO5ufhKrlsvUIQSX+50=; b=ft2e9ypajJH+XQne/U66YwOQKuDbxPsGmYTGw6C1N78slh/KU7EkThQP2R/CPckcoUPM2H VcXwtNxuKw151RtkTrrzALH6K60e3yfsMa2I5DMrwV/apAYfWL8h4a/75h2MQYFv3z8Bwo m9MNhPRh6i2bwCf5PHqhjGEwMiazCF4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-dD3ykuOSOY60XXS2zXID4w-1; Sat, 09 Mar 2024 18:36:04 -0500 X-MC-Unique: dD3ykuOSOY60XXS2zXID4w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4EFF9185A784 for ; Sat, 9 Mar 2024 23:36:04 +0000 (UTC) Received: from aion.redhat.com (unknown [10.22.16.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41BB3200E1B3 for ; Sat, 9 Mar 2024 23:36:04 +0000 (UTC) Received: from aion.redhat.com (localhost [IPv6:::1]) by aion.redhat.com (Postfix) with ESMTP id E8A7912D1FB for ; Sat, 9 Mar 2024 18:36:03 -0500 (EST) From: Scott Mayhew To: kdevops@lists.linux.dev Subject: [PATCH v2 04/10] devconfig: set /etc/hostname earlier Date: Sat, 9 Mar 2024 18:35:57 -0500 Message-ID: <20240309233603.1306533-5-smayhew@redhat.com> In-Reply-To: <20240309233603.1306533-1-smayhew@redhat.com> References: <20240309233603.1306533-1-smayhew@redhat.com> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true I noticed that opensuse-tumbleweed guestfs VMs were still showing up as 'localhost.localdomain', even though /etc/hostname had the correct hostnames. Update /etc/hostname before the distro-specific install tasks, so that the reboot that occurs causes the hostname change to actually take effect. Signed-off-by: Scott Mayhew --- playbooks/roles/devconfig/tasks/main.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/playbooks/roles/devconfig/tasks/main.yml b/playbooks/roles/devconfig/tasks/main.yml index 1f18e588..1e67f91e 100644 --- a/playbooks/roles/devconfig/tasks/main.yml +++ b/playbooks/roles/devconfig/tasks/main.yml @@ -17,6 +17,18 @@ setup: tags: always +# Update /etc/hostname first so the change gets picked up by the reboot +# that occurs during the distro-specific tasks + +- name: Ensure /etc/hostname is set + become: yes + become_flags: 'su - -c' + become_method: sudo + template: + src: hostname + dest: /etc/hostname + tags: hostname + # Distro specific - name: Install dependencies import_tasks: install-deps/main.yml @@ -28,15 +40,6 @@ # Distro agnostic stuff goes below -- name: Ensure /etc/hostname is set - become: yes - become_flags: 'su - -c' - become_method: sudo - template: - src: hostname - dest: /etc/hostname - tags: hostname - - name: Check if the developer has a git config delegate_to: localhost stat: -- 2.43.0