user - Manage user accounts

Author:Stephen Fromm

Synopsis

Manage user accounts and user attributes.

Options

parameter required default choices comments
append no
    If yes, will only add groups, not set them to just the list in groups.
    comment no
      Optionally sets the description (aka GECOS) of user account.
      createhome no yes
      • yes
      • no
      Unless set to no, a home directory will be made for the user when the account is created or if the home directory does not exist.
      force no no
      • yes
      • no
      When used with state=absent, behavior is as with userdel --force.
      generate_ssh_key no no
      • yes
      • no
      Whether to generate a SSH key for the user in question. This will not overwrite an existing SSH key. (added in Ansible 0.9)
      group no
        Optionally sets the user's primary group (takes a group name).
        groups no
          Puts the user in this comma-delimited list of groups. When set to the empty string ('groups='), the user is removed from all groups except the primary group.
          home no
            Optionally set the user's home directory.
            login_class no
              Optionally sets the user's login class for FreeBSD, OpenBSD and NetBSD systems.
              move_home no no
              • yes
              • no
              If set to yes when used with home=, attempt to move the user's home directory to the specified directory if it isn't there already.
              name yes
                Name of the user to create, remove or modify.
                non_unique no no
                • yes
                • no
                Optionally when used with the -u option, this option allows to change the user ID to a non-unique value. (added in Ansible 1.1)
                password no
                  Optionally set the user's password to this crypted value. See the user example in the github examples directory for what this looks like in a playbook. The `FAQ <http://docs.ansible.com/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module>`_ contains details on various ways to generate these password values.
                  remove no no
                  • yes
                  • no
                  When used with state=absent, behavior is as with userdel --remove.
                  shell no
                    Optionally set the user's shell.
                    ssh_key_bits no 2048
                      Optionally specify number of bits in SSH key to create. (added in Ansible 0.9)
                      ssh_key_comment no ansible-generated
                        Optionally define the comment for the SSH key. (added in Ansible 0.9)
                        ssh_key_file no $HOME/.ssh/id_rsa
                          Optionally specify the SSH key filename. (added in Ansible 0.9)
                          ssh_key_passphrase no
                            Set a passphrase for the SSH key. If no passphrase is provided, the SSH key will default to having no passphrase. (added in Ansible 0.9)
                            ssh_key_type no rsa
                              Optionally specify the type of SSH key to generate. Available SSH key types will depend on implementation present on target host. (added in Ansible 0.9)
                              state no present
                              • present
                              • absent
                              Whether the account should exist. When absent, removes the user account.
                              system no no
                              • yes
                              • no
                              When creating an account, setting this to yes makes the user a system account. This setting cannot be changed on existing users.
                              uid no
                                Optionally sets the UID of the user.
                                update_password no always
                                • always
                                • on_create
                                always will update passwords if they differ. on_create will only set the password for newly created users. (added in Ansible 1.3)

                                Note

                                Requires useradd

                                Note

                                Requires userdel

                                Note

                                Requires usermod

                                Examples


                                # Add the user 'johnd' with a specific uid and a primary group of 'admin'
                                - user: name=johnd comment="John Doe" uid=1040
                                
                                # Remove the user 'johnd'
                                - user: name=johnd state=absent remove=yes
                                
                                # Create a 2048-bit SSH key for user jsmith
                                - user: name=jsmith generate_ssh_key=yes ssh_key_bits=2048
                                

                                Table Of Contents

                                Previous topic

                                sysctl - Manage entries in sysctl.conf.

                                Next topic

                                zfs - Manage zfs