kdevops.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Scott Mayhew <smayhew@redhat.com>
To: kdevops@lists.linux.dev
Subject: [PATCH 2/5] update_etc_hosts: fix up hostnames on debian guestfs hosts
Date: Thu,  7 Mar 2024 08:14:11 -0500	[thread overview]
Message-ID: <20240307131414.1244984-3-smayhew@redhat.com> (raw)
In-Reply-To: <20240307131414.1244984-1-smayhew@redhat.com>

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 <smayhew@redhat.com>
---
 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


  parent reply	other threads:[~2024-03-07 13:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07 13:14 [PATCH 0/5] add initial support for testing nfs with krb5 Scott Mayhew
2024-03-07 13:14 ` [PATCH 1/5] nfsd: make sure the appropriate fsprogs package is installed Scott Mayhew
2024-03-07 13:14 ` Scott Mayhew [this message]
2024-03-07 13:14 ` [PATCH 3/5] nfsd: use EXTRA_VAR_INPUTS for export options Scott Mayhew
2024-03-07 13:14 ` [PATCH 4/5] devconfig: set /etc/hostname earlier Scott Mayhew
2024-03-07 13:14 ` [PATCH 5/5] fstests/nfs: add krb5 support Scott Mayhew
2024-03-08 16:57   ` Luis Chamberlain
2024-03-08 19:33     ` Scott Mayhew
2024-03-08 21:08       ` Scott Mayhew
2024-03-08 21:20         ` Luis Chamberlain
2024-03-08 21:18       ` Luis Chamberlain
2024-03-08 22:13         ` Scott Mayhew
2024-03-08 22:47           ` Luis Chamberlain
2024-03-08 15:01 ` [PATCH 0/5] add initial support for testing nfs with krb5 Chuck Lever III
2024-03-08 15:50   ` Scott Mayhew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240307131414.1244984-3-smayhew@redhat.com \
    --to=smayhew@redhat.com \
    --cc=kdevops@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).