community.vmware.vmware_host_user_manager 模块 – 管理 ESXi 用户

注意

此模块是 community.vmware 集合 (版本 5.2.0) 的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.vmware

要在 playbook 中使用它,请指定: community.vmware.vmware_host_user_manager

概要

  • 此模块可以添加、更新或删除 ESXi 主机上的本地用户。

参数

参数

注释

esxi_hostname

字符串 / 必需

管理本地用户的 ESXi 主机的名称。

hostname

字符串

vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。

如果任务中未指定此值,则将使用环境变量 VMWARE_HOST 的值。

override_user_password

布尔值

如果本地用户存在并更新密码,则将此参数值更改为 true。

选项

  • false ← (默认)

  • true

password

别名:pass,pwd

字符串

vSphere vCenter 或 ESXi 服务器的密码。

如果任务中未指定此值,则将使用环境变量 VMWARE_PASSWORD 的值。

port

整数

vSphere vCenter 或 ESXi 服务器的端口号。

如果任务中未指定此值,则将使用环境变量 VMWARE_PORT 的值。

默认值: 443

proxy_host

字符串

将接收所有 HTTPS 请求并转发它们的代理的地址。

格式为主机名或 IP。

如果任务中未指定此值,则将使用环境变量 VMWARE_PROXY_HOST 的值。

proxy_port

整数

将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。

如果任务中未指定此值,则将使用环境变量 VMWARE_PROXY_PORT 的值。

state

字符串

如果设置为 present,则添加新的本地用户或更新信息。

如果设置为 absent,则删除本地用户。

选项

  • "present" ← (默认)

  • "absent"

user_description

别名:local_user_description

字符串

本地用户描述。

user_name

别名:local_user_name

字符串 / 必需

本地用户的名称。

user_password

别名:local_user_password

字符串

本地用户的密码。

如果您想更新密码,则需要 override_user_password=true

username

别名:admin,user

字符串

vSphere vCenter 或 ESXi 服务器的用户名。

如果任务中未指定此值,则将使用环境变量 VMWARE_USER 的值。

validate_certs

布尔值

允许在 SSL 证书无效时连接。当证书不受信任时,设置为 false

如果任务中未指定此值,则将使用环境变量 VMWARE_VALIDATE_CERTS 的值。

选项

  • false

  • true ← (默认)

备注

注意

  • 所有模块都需要 API 写访问权限,因此在免费 ESXi 许可证上不支持。

  • 所有变量和 VMware 对象名称都区分大小写。

示例

- name: Add new local user to ESXi host
  community.vmware.vmware_host_user_manager:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    validate_certs: false
    esxi_hostname: "{{ esxi1 }}"
    user_name: example
    user_description: "example user"
    user_password: "{{ local_user_password }}"
    state: present

- name: Update the local user password in ESXi host
  community.vmware.vmware_host_user_manager:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    validate_certs: false
    esxi_hostname: "{{ esxi1 }}"
    user_name: example
    user_description: "example user"
    user_password: "{{ local_user_password }}"
    override_user_password: true
    state: present

- name: Delete the local user in ESXi host
  community.vmware.vmware_host_user_manager:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    validate_certs: false
    esxi_hostname: "{{ esxi1 }}"
    user_name: example
    state: absent

返回值

常见返回值已在 此处 记录,以下是此模块特有的字段

描述

msg

字符串

模块的执行结果。

返回:始终

示例: "{\n    \"msg\": \"Added the new user.\n}"

作者

  • sky-joker (@sky-joker)