FreeKB - Ansible user module (groups)
Ansible - user module (groups)

If you are not familiar with modules, check out Ansible - Getting Started with Modules.

The user module is similar to the useradd and usermod commands. The user module is used to create or modify a users account on a managed node (e.g. target system).

If the users account does not exist, the users account will be created. If the users account already exists, the users account will be modified.

Before using this module, you should probably use the group module to create the group if the group does not yet exist on the managed node.

There are two group parameters:

  • group - update the users primary group
  • groups - add the user to be a member of additional groups

In this example, John Doe's primary group will be set to wheel.

- name: john.doe primary group is 'wheel'
  user:
    name: john.doe
    group: wheel

 

Let's say John Doe's primary group is 'john.doe' and you want to add John Doe to group2 and group3. In this scenario, you would use groups (with an "s") and append.

- name: add john.doe to 'group2' and 'group3'
  user:
    name: john.doe
    groups: group2,group3

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 4a968 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |