Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
roles/user_verify*: change grep pattern for home dir change (#452)
Browse files Browse the repository at this point in the history
* roles/user_verify*: change grep pattern for home dir change

It looks like coreos/rpm-ostree#1726 changed how `useradd`
operates on `ostree` hosts, so we have to look for `/var/home/<user>`
now.  Except that not all the `ostree` hosts will have this change, so
make it an optional part of the regex pattern.

* fixup! roles/user_verify*: change grep pattern for home dir change

* fixup! roles/user_verify*: change grep pattern for home dir change
  • Loading branch information
miabbott authored and mike-nguyen committed Feb 5, 2019
1 parent 6ad234b commit 14c8a67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion roles/user_verify_missing/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
fail:
msg: "uvm_uid is undefined"

- name: Set regex pattern
set_fact:
regex_pattern: "^atomic-user-{{ uvm_uid }}:x:{{ uvm_uid }}:{{ uvm_uid }}::{{ '\\(/var\\)\\?' | regex_escape() }}/home/atomic-user-{{ uvm_uid }}:/bin/bash"

- name: Check to see if the user is in /etc/passwd
command: "grep atomic-user-{{ uvm_uid }}:x:{{ uvm_uid }}:{{ uvm_uid }}::/home/atomic-user-{{ uvm_uid }}:/bin/bash /etc/passwd"
command: "grep -e {{ regex_pattern }} /etc/passwd"
register: grep_user
failed_when: grep_user.rc != 1
6 changes: 5 additions & 1 deletion roles/user_verify_present/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
fail:
msg: "uvp_uid variable is undefined"

- name: Set regex pattern
set_fact:
regex_pattern: "^atomic-user-{{ uvp_uid }}:x:{{ uvp_uid }}:{{ uvp_uid }}::{{ '\\(/var\\)\\?' | regex_escape() }}/home/atomic-user-{{ uvp_uid }}:/bin/bash"

- name: Verify users in /etc/passwd
command: "grep atomic-user-{{ uvp_uid }}:x:{{ uvp_uid }}:{{ uvp_uid }}::/home/atomic-user-{{ uvp_uid }}:/bin/bash /etc/passwd"
command: "grep -e {{ regex_pattern }} /etc/passwd"

- name: Verify password is a SHA-512 hash
command: "grep '^atomic-user-{{ uvp_uid }}:$6$.*' /etc/shadow"

0 comments on commit 14c8a67

Please sign in to comment.