Hi,
I keep getting errors related to my ‘when’ conditionals in my following playbook:
Hi,
I keep getting errors related to my ‘when’ conditionals in my following playbook:
conditionals apply to tasks, not vars_prompt, which is not a task.
Hi Brian,
Thanks for the reply. After error testing, I commented out the conditional in vars_prompt and reinserted it right after the task command, however it’s not liking the logic in my when-statement. Do you happen to know where I’m running into an error? I’m trying to add an exception to prevent the script from running if a user specifies the wrong account to delete such as ‘root’.
I took out the quotes and brackets from the remove_user variable, but after running the playbook kicked back this message:
ERROR! Syntax Error while loading YAML.
The offending line appears to be:
command: “userdel {{ user_to_remove }}”
when: user_to_remove != “root”
^ here
when is a 'task' keyword, there you are making it an option for the
command module, unindent.
- command: "userdel {{ user_to_remove }}"
when: user_to_remove != "root"
also i recommend using the 'user' module instead.