Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1BF19524D7 for ; Sat, 9 Mar 2024 23:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710027370; cv=none; b=uK8/zq/RqdY/HVDaRBxzpbM6OHEEXT+KWCfKmxS+cJggDdnf4XHQa0o7DaM0nEsOumKUbiOMXeKdY4zAds1QjGqyfq6DtROtSMrMvX7aPZJFPRlkAwsCbOVFn3vyYTSxsMOIiTfVsruL7sVmgibOb6MHdDo4ycQfY/cXBzE8PQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710027370; c=relaxed/simple; bh=AeZ7/ZAVc0fTaG+7fe3KaPtERG2UR8xh2CToqALYBcc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GGy3xlIAMFoGWJzP8Lv5C/i99RKH/acGIfbTMAeLP1M6yUNdN0MvZNmFkaagN8S91SfRk4HkLWkkbNHJqaZDfttvuvzVUOd553Fk8XY2/WVhEWmax4/XWbKPLx+mTzsdYRfZ9Q1okYPkIJKpWO56xTWQ+rWF6W/T5WoNQkLryJ0= 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=ELer9trA; arc=none smtp.client-ip=170.10.129.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="ELer9trA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710027366; 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=8kAaG8nOeYts3Cdj0nGYDMsdpcu1G9gbI5k7uk9Z1zA=; b=ELer9trA8LclPGI6fBeyL2gn3afsiZekcYAhTWLvDt7j5uMWWPhwIR4nt/pMHFaDto/Fgc 9YfDY8yf1tC+UlywwafUe9nVeGp3DYtHys2Ma+vSgoIU96k+tP243aJR9Xsh0iXGHk8EFT NO9GxOoSNCHHe3kAUPASaAcleAIxfY0= 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-259-hapS_I_4PvKDzjNWzrYYUg-1; Sat, 09 Mar 2024 18:36:04 -0500 X-MC-Unique: hapS_I_4PvKDzjNWzrYYUg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 388578007A6 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 2C700492BC6 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 D166F12D1F9 for ; Sat, 9 Mar 2024 18:36:03 -0500 (EST) From: Scott Mayhew To: kdevops@lists.linux.dev Subject: [PATCH v2 02/10] update_etc_hosts: fix up hostnames on debian guestfs hosts Date: Sat, 9 Mar 2024 18:35:55 -0500 Message-ID: <20240309233603.1306533-3-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.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Since we're not currently using DNS domains in our hostnames, debian guestfs hosts wind up with an entry like this in /etc/hosts: 127.0.1.1 unassigned-hostname.unassigned-domain foo which causes the ansible_fqdn variable to report "unassigned-hostname.unassigned-domain". Get rid of the "unassigned-hostname.unassigned-domain" part, so that ansible_fqdn reports the short hostname "foo" instead. Signed-off-by: Scott Mayhew --- playbooks/roles/update_etc_hosts/tasks/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/playbooks/roles/update_etc_hosts/tasks/main.yml b/playbooks/roles/update_etc_hosts/tasks/main.yml index dca61d9f..34a69f6d 100644 --- a/playbooks/roles/update_etc_hosts/tasks/main.yml +++ b/playbooks/roles/update_etc_hosts/tasks/main.yml @@ -65,3 +65,15 @@ with_items: "{{ ueh_hosts }}" when: - not terraform_private_net_enabled + +- name: Fix up hostname on Debian guestfs hosts + become: yes + become_method: sudo + lineinfile: + path: /etc/hosts + regexp: '^(127\.0\.1\.1)(\s+)unassigned-hostname\.unassigned-domain\s+({{ ansible_hostname }})$' + backrefs: yes + line: '\1\2\3' + when: + - ansible_os_family == 'Debian' + - kdevops_enable_guestfs -- 2.43.0