Izhuceul 发表于 2018-1-2 17:50:57

Ansible自动化运维笔记2(Ansible的组件介绍)

> USER  Manage user accounts and user attributes.
  Options (= is mandatory):
  - append
  If `yes', will only add groups, not set them to just the list
  in `groups'. (Choices: yes, no)
  - comment
  Optionally sets the description (aka `GECOS') of user account.
  - createhome
  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. (Choices: yes, no)
  - expires
  An expiry time for the user in epoch, it will be ignored on
  platforms that do not support this. Currently supported on
  Linux and FreeBSD.
  - force
  When used with `state=absent', behavior is as with `userdel
  --force'. (Choices: yes, no)
  - generate_ssh_key
  Whether to generate a SSH key for the user in question. This
  will *not* overwrite an existing SSH key. (Choices: yes, no)

  - group
  Optionally sets the user's primary group (takes a group name).
  - groups
  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
  Optionally set the user's home directory.
  - login_class

  Optionally sets the user's login>  and NetBSD systems.
  - move_home
  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. (Choices: yes, no)
  = name
  Name of the user to create, remove or modify.
  - non_unique
  Optionally when used with the -u option, this option allows to

  change the user>
  - password
  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. Note on Darwin system,
  this value has to be cleartext. Beware of security issues.
  - remove
  When used with `state=absent', behavior is as with `userdel
  --remove'. (Choices: yes, no)
  - shell
  Optionally set the user's shell.
  - ssh_key_bits
  Optionally specify number of bits in SSH key to create.

  - ssh_key_comment
  Optionally define the comment for the SSH key. [Default:
  ansible-generated on $HOSTNAME]
  - ssh_key_file

  Optionally specify the SSH key filename. If this is a>
  filename then it will be>  directory.
  - ssh_key_passphrase
  Set a passphrase for the SSH key.If no passphrase is
  provided, the SSH key will default to having no passphrase.
  - ssh_key_type
  Optionally specify the type of SSH key to generate. Available
  SSH key types will depend on implementation present on target
  host.
  - state
  Whether the account should exist or not, taking action if the
  state is different from what is stated. (Choices: present,
  absent)
  - system
  When creating an account, setting this to `yes' makes the user
  a system account.This setting cannot be changed on existing
  users. (Choices: yes, no)
  - uid
  Optionally sets the `UID' of the user.
  - update_password
  `always' will update passwords if they differ.`on_create'
  will only set the password for newly created users. (Choices:
  always, on_create)
  Requirements:useradd, userdel, usermod
  EXAMPLES:
  # Add the user 'johnd' with a specific uid and a primary group of 'admin'
  - user: name=johnd comment="John Doe" uid=1040 group=admin
  # Add the user 'james' with a bash shell, appending the group 'admins' and 'developers' to the user's groups
  - user: name=james shell=/bin/bash groups=admins,developers append=yes
  # Remove the user 'johnd'
  - user: name=johnd state=absent remove=yes
  # Create a 2048-bit SSH key for user jsmith in ~jsmith/.ssh/id_rsa
  # added a consultant whose account you want to expire
  - user: name=james18 shell=/bin/zsh groups=developers expires=1422403387

nagios 发表于 2018-1-2 18:09:50

``````````````
页: [1]
查看完整版本: Ansible自动化运维笔记2(Ansible的组件介绍)