From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B8DF08498 for ; Thu, 31 Aug 2023 10:13:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CF7CC433C7; Thu, 31 Aug 2023 10:13:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693476805; bh=mTvkYMLlmubKAALKpfiATUGsKE6DUGtckkk9jBTJe6E=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=UTK957AcYDzXKbJ3NbNkJyKl2ke9r5Q8r6ishotWE00MVTUIbAaED9PMOQdg0am2Y O3O4fBVvbXEPajkMjegR0psLoGUp6YGLJUcsuQYkm+EMF8mkd505t2POv6odXjJSaM +KYeuxaPb1QInIg9s1OZl+vYy70Had54Sg4HnofEZU027sHAyS7bpteDNa0EquNKau c78IEYBhKMxusNQrok6cStVPLwhSzw7sUH6zToJHNFHP1M/KT2wyQfKlUzPPYVh0AR yE1nXv7hWWPZjFg5EaBiHubmeu+YAopteg9ygtrio/kBL+cf16wHaxCgw6+sWxb5jk c3pFv2OwAfShg== Message-ID: Subject: Re: [RFC PATCH] fstests: Request inferred user From: Jeff Layton To: Frederick Lawler , mcgrof@kernel.org Cc: kdevops@lists.linux.dev, kernel-team@cloudflare.com Date: Thu, 31 Aug 2023 06:13:23 -0400 In-Reply-To: <20230830235333.1658555-1-fred@cloudflare.com> References: <20230830235333.1658555-1-fred@cloudflare.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2023-08-30 at 18:53 -0500, Frederick Lawler wrote: > Currently when running make fstests for bare-metal setups, the data_user > 'vagrant' is set for the /data partition. This is currently set as the de= fault > data_user. We have the option to edit this in extra_vars.yml. >=20 > make linux checks for an inferred user prior to setting the uid/gid for > the /data partition. >=20 > In the situation where we don't add the 'vagrant' user to the > bare-metal, we get a "user does not exist" on make fstests. >=20 > In both cases we do not want to switch users between the two targets, > nor do we want to necessarily ensure that the 'vagrant' user exists on > the metal. Therefore, request the inferred user on make fstests. >=20 > Signed-off-by: Frederick Lawler > --- > Since this is essentially in two places, I figure this should be more > generic and then included in other make targets like cxl. But this is to > get the discussion going if this or some other generic approach is > preferred. > --- > playbooks/roles/fstests/tasks/main.yml | 37 ++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) >=20 > diff --git a/playbooks/roles/fstests/tasks/main.yml b/playbooks/roles/fst= ests/tasks/main.yml > index e2d7ce5295b7..2898833b0732 100644 > --- a/playbooks/roles/fstests/tasks/main.yml > +++ b/playbooks/roles/fstests/tasks/main.yml > @@ -10,6 +10,43 @@ > skip: true > tags: vars > =20 > +- name: Get username we are using > + command: > + cmd: whoami > + register: username_on_target > + when: > + - infer_uid_and_group|bool > + > +- name: Set target user as a fact > + set_fact: > + target_user: "{{ username_on_target.stdout }}" > + when: > + - infer_uid_and_group|bool > + > +- name: Run getent against the inferred target user > + getent: > + database: passwd > + key: "{{ target_user }}" > + register: getent_running_user > + when: > + - infer_uid_and_group|bool > + > +- name: Run getent against the inferred target group > + getent: > + database: group > + key: "{{ target_user }}" > + register: getent_on_group > + when: > + - infer_uid_and_group|bool > + > +- name: Override user and group with inferred settings if feature is ena= bled > + set_fact: > + user: "hplip" Why "hplip" here? > + data_user: "{{ target_user }}" > + data_group: "{{ ((getent_on_group.values() | first).values() | first= ).keys() | first }}" > + when: > + - infer_uid_and_group|bool > + > - include_role: > name: create_data_partition > tags: [ 'oscheck', 'data_partition' ] --=20 Jeff Layton