Hi all, I’m scratching my head on this one.
I am attempting to make a conditional message based on whether a variable value is 0 or not. Here’s what I have:
- debug:
msg: - “{{ ‘User is root’ if (user_id.stdout_lines == ‘0’) else not_root }}”
The user_id variable is basically just running the id -u
command on the server. if it’s root, it’ll be 0, if it’s not root then it’ll be whatever their ID number is.
The issue I’m having is that even when the id -u
returns 0, I’m still getting the ‘not_root’ variable passed into the output.
I am unable to get this to work so figured someone on here may be able to point me in the right direction?
Thanks in advance