You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
I have a fact that I'm printing out currently for debug purposes. It's a list of user home folders. I'm trying to exclude certain folders, but not matter what I try, the folders I want to exclude are displayed. Here's what I'm trying:
when: (user_list != "/home/admin") or (user_list != "/home/jdxadmin") or (user_list != "/home/test2")
I've tried using "and" and "or" and they both print everything, including the items I'm trying to exclude. Any ideas on where I'm going wrong?
Thanks,
Harry
Stefan Hornburg (Racke)
unread,
Oct 5, 2021, 12:05:47 PM10/5/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
1. you compare apples (list) with pears (strings)
2. "and" would be correct if you compare with the list element: (item != "/home/admin") and (item != "/home/jdxadmin") and (item != "/home/test2")
3. readable version: item not in ["/home/admin", "/home/jdxadmin", "/home/test2"]
Note: the condition is checked for *every* loop element.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Worked perfectly! I appreciate your help and timely response!
Thanks,
Harry
flowerysong
unread,
Oct 5, 2021, 2:05:48 PM10/5/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
As the other reply pointed out you were comparing a string to a list, so it was always unequal. However, there's a much cleaner way to output the desired information (a task loop will still have output for skipped items):