Jenisha_T
(Jenisha T)
1
Hi Team
I want to execute ls -l command twice.
- ls -l # check if user in group
- sudo adduser user_name new_group # If not in group add user to group
- ls -l # Check if user added to group
Is there a way I can write a shell module for $ ls -l once and call for step 1 and step 3 in ansible
Thankyou!
Why you are using ls -l command and
For checking user group use below command
id username | grep -i groupname
Regard
Gg
racke
(Stefan Hornburg)
3
Why you are using ls -l command and
For checking user group use below command
# id username | grep -i groupname
Regard
Gg
That's pretty much off topic as this is not a group about shell scripts.
You should be able to replace ls with the find module in ansible.
You can add group to an user with the user module, for example:
- name: Ensure that ClamAV user is member of Exim group
user:
name: "clamav"
groups: "Debian-exim"
append: true
Regards
Racke