init commit

This commit is contained in:
2025-07-21 14:26:07 -05:00
commit 6a683a7a38
25 changed files with 635 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
---
- name: Check if user is in specified group
hosts: all
gather_facts: false
become: true
vars_prompt:
- name: check_user
prompt: "Enter the username to check"
private: no
- name: check_group
prompt: "Enter the group to verify membership"
private: no
tasks:
- name: Get groups for specified user
ansible.builtin.command: "id -nG {{ check_user }}"
register: user_groups
changed_when: false
failed_when: user_groups.rc != 0
- name: Set fact if user is in group
set_fact:
user_in_group: "{{ check_group in user_groups.stdout.split() }}"
- name: Report user group membership
debug:
msg: >
User '{{ check_user }}' {{ 'IS' if user_in_group else 'IS NOT' }}
in the '{{ check_group }}' group on {{ inventory_hostname }}.