I want to make sure a given user always exist in a system, so only create when it is not exist
my current tasks is:
- name: Create default user
action: user name={{ user }} groups={{ group }} state=present
However, it raise the error when a user already exists, so how to avoid the error when the user account already exist?
Modules, and therefore, playbooks like the one you show, have to be idempotent to be of any use.
Repeating the same action several times both with a playbook and a onliner does not result in any errors, as expected:
The playbook I have used:
Or you can just cheat and add
below the
action: user
line