Skip to contentSkip to conversation

fstests: Request inferred user

RFC PATCH In review Frederick Lawler 3 participants 7 messages Aug 30, 2023 – Aug 31, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 fstests: Request inferred user

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 default data_user. We have the option to edit this in extra_vars.yml.

make linux checks for an inferred user prior to setting the uid/gid for the /data partition.

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.

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.

---
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(+)
playbooks/roles/fstests/tasks/main.yml +37 -0
index e2d7ce5295b7..2898833b0732 100644
@@ -10,6 +10,43 @@
       skip: true
   tags: vars
 
+- 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 enabled
+  set_fact:
+    user: "hplip"
+    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' ]
Signature · 1 line
2.34.1
#1 lore raw
Quoted 54 lines · Frederick Lawler

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 default data_user. We have the option to edit this in extra_vars.yml.

make linux checks for an inferred user prior to setting the uid/gid for the /data partition.

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.

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.

---
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(+)
playbooks/roles/fstests/tasks/main.yml +22 -0
index e2d7ce5295b7..2898833b0732 100644
@@ -10,6 +10,43 @@
       skip: true
   tags: vars
 
+- 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

playbooks/roles/fstests/tasks/main.yml line 44

Quoted 10 lines
playbooks/roles/fstests/tasks/main.yml +10 -0
+  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 enabled
+  set_fact:
+    user: "hplip"

Why "hplip" here?

Quoted 8 lines
playbooks/roles/fstests/tasks/main.yml +5 -0
+    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' ]
Signature · 1 line
Jeff Layton <[email protected]>
#2 lore raw
Quoted 59 lines · Jeff Layton
Quoted 58 lines · Frederick Lawler

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 default data_user. We have the option to edit this in extra_vars.yml.

make linux checks for an inferred user prior to setting the uid/gid for the /data partition.

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.

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.

---
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(+)
playbooks/roles/fstests/tasks/main.yml +26 -0
index e2d7ce5295b7..2898833b0732 100644
@@ -10,6 +10,43 @@
       skip: true
   tags: vars
 
+- 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
Quoted 8 lines

playbooks/roles/fstests/tasks/main.yml line 44

Quoted 6 lines
playbooks/roles/fstests/tasks/main.yml +6 -0
+  when:
+    - infer_uid_and_group|bool
+
+- name: Override user and group with inferred settings if feature is enabled
+  set_fact:
+    user: "hplip"

Why "hplip" here?

This was mostly copy/pasted from ./playbooks/roles/bootlinux/tasks/main.yml. I see it was introduced in commit f10add06446b ("kdevops: remove ansible galaxy dependency") for that file, but I'm unclear the use there. I'd like to know as well.

Quoted 12 lines
Quoted 9 lines
playbooks/roles/fstests/tasks/main.yml +5 -0
+    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' ]
Signature · 1 line
Jeff Layton <[email protected]>

Fred

#3 lore raw
Quoted 69 lines · Frederick Lawler
Quoted 59 lines · Jeff Layton
Quoted 58 lines · Frederick Lawler

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 default data_user. We have the option to edit this in extra_vars.yml.

make linux checks for an inferred user prior to setting the uid/gid for the /data partition.

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.

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.

---
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(+)
playbooks/roles/fstests/tasks/main.yml +26 -0
index e2d7ce5295b7..2898833b0732 100644
@@ -10,6 +10,43 @@
       skip: true
   tags: vars
 
+- 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
Quoted 8 lines

playbooks/roles/fstests/tasks/main.yml line 44

Quoted 6 lines
playbooks/roles/fstests/tasks/main.yml +6 -0
+  when:
+    - infer_uid_and_group|bool
+
+- name: Override user and group with inferred settings if feature is enabled
+  set_fact:
+    user: "hplip"

Why "hplip" here?

Quoted 4 lines

This was mostly copy/pasted from ./playbooks/roles/bootlinux/tasks/main.yml. I see it was introduced in commit f10add06446b ("kdevops: remove ansible galaxy dependency") for that file, but I'm unclear the use there. I'd like to know as well.

I recall fstets having odd user requirements but that was just for some odd tests. I can't trace hplip down to anything so I say we just remove it for both.

Luis

#4 lore raw
Quoted 70 lines · Luis Chamberlain
Quoted 69 lines · Frederick Lawler
Quoted 67 lines · Jeff Layton
Quoted 54 lines · Frederick Lawler

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 default data_user. We have the option to edit this in extra_vars.yml.

make linux checks for an inferred user prior to setting the uid/gid for the /data partition.

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.

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.

---
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(+)
playbooks/roles/fstests/tasks/main.yml +22 -0
index e2d7ce5295b7..2898833b0732 100644
@@ -10,6 +10,43 @@
       skip: true
   tags: vars
 
+- 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

playbooks/roles/fstests/tasks/main.yml line 44

Quoted 10 lines
playbooks/roles/fstests/tasks/main.yml +10 -0
+  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 enabled
+  set_fact:
+    user: "hplip"

Why "hplip" here?

Quoted 8 lines
Quoted 4 lines

This was mostly copy/pasted from ./playbooks/roles/bootlinux/tasks/main.yml. I see it was introduced in commit f10add06446b ("kdevops: remove ansible galaxy dependency") for that file, but I'm unclear the use there. I'd like to know as well.

I recall fstets having odd user requirements but that was just for some odd tests. I can't trace hplip down to anything so I say we just remove it for both.

If you have an HP printer/scanner/copier then there is an "hplip" package for Fedora with some of their drivers and such.

That's why it seemed so weird here.

Signature · 1 line
Jeff Layton <[email protected]>
#5 lore raw
Quoted 76 lines · Jeff Layton
Quoted 75 lines · Luis Chamberlain
Quoted 73 lines · Frederick Lawler
Quoted 59 lines · Jeff Layton
Quoted 58 lines · Frederick Lawler

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 default data_user. We have the option to edit this in extra_vars.yml.

make linux checks for an inferred user prior to setting the uid/gid for the /data partition.

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.

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.

---
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(+)
playbooks/roles/fstests/tasks/main.yml +26 -0
index e2d7ce5295b7..2898833b0732 100644
@@ -10,6 +10,43 @@
       skip: true
   tags: vars
 
+- 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
Quoted 8 lines

playbooks/roles/fstests/tasks/main.yml line 44

Quoted 6 lines
playbooks/roles/fstests/tasks/main.yml +6 -0
+  when:
+    - infer_uid_and_group|bool
+
+- name: Override user and group with inferred settings if feature is enabled
+  set_fact:
+    user: "hplip"

Why "hplip" here?

This was mostly copy/pasted from ./playbooks/roles/bootlinux/tasks/main.yml. I see it was introduced in commit f10add06446b ("kdevops: remove ansible galaxy dependency") for that file, but I'm unclear the use there. I'd like to know as well.

Quoted 8 lines
Quoted 3 lines

I recall fstets having odd user requirements but that was just for some odd tests. I can't trace hplip down to anything so I say we just remove it for both.

If you have an HP printer/scanner/copier then there is an "hplip" package for Fedora with some of their drivers and such.

That's why it seemed so weird here.

Indeed, super odd! Well good riddance, I nuked it.

Luis

#6 lore raw
In reply to Frederick Lawler
Quoted 14 lines · Frederick Lawler

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 default data_user. We have the option to edit this in extra_vars.yml.

make linux checks for an inferred user prior to setting the uid/gid for the /data partition.

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.

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.

Quoted 6 lines

---
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.

Looks good to me, sharing is certainly desriable so we have a bug in just one place. You can do that later.

I've applied this patch and then also removed hlip user from both places. We'll see what breaks, I can't think of anything that should depend on it.

What's your github username or gitlab? You should just get access to commit.

Luis