dellemc.enterprise_sonic.sonic_users 模块 – 管理用户及其参数

注意

此模块是 dellemc.enterprise_sonic 集合 (版本 2.5.1) 的一部分。

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

要安装它,请使用:ansible-galaxy collection install dellemc.enterprise_sonic

要在 playbook 中使用它,请指定:dellemc.enterprise_sonic.sonic_users

dellemc.enterprise_sonic 1.1.0 中的新增功能

概要

  • 此模块提供运行 Enterprise SONiC 的设备上用户参数的配置管理。

注意

此模块具有相应的 action 插件

参数

参数

注释

config

列表 / 元素=字典

指定与用户相关的配置。

name

字符串 / 必需

指定用户名。

password

字符串

指定用户的密码。

role

字符串

指定用户的角色。

选项

  • "admin"

  • "operator"

  • "netadmin"

  • "secadmin"

update_password

字符串

指定更新密码标志。

如果为 always,则每次都会更新密码。

如果为 on_create,则只有在创建用户时才会更新密码。

选项

  • "always" ← (默认)

  • "on_create"

state

字符串

指定要对设备上配置的用户执行的操作。

如果为 merged,则输入配置将与设备上现有用户的配置合并。

如果为 deleted,则现有用户的配置将从设备中删除。

如果为 replaced,则现有指定用户的配置将替换为提供的配置。

如果为 overridden,则现有用户的配置将被提供的配置覆盖。

选项

  • "merged" ← (默认)

  • "deleted"

  • "overridden"

  • "replaced"

备注

注意

  • 已针对戴尔科技集团的 Enterprise SONiC 发行版进行测试。

  • 支持 check_mode

示例

# Using deleted
#
# Before state:
# -------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# sysadmin                          admin
# sysoperator                       operator

- name: Delete user
  dellemc.enterprise_sonic.sonic_users:
    config:
      - name: sysoperator
    state: deleted

# After state:
# ------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# sysadmin                          admin

# Using deleted
#
# Before state:
# -------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# sysadmin                          admin
# sysoperator                       operator

- name: Delete all users configurations except admin
  dellemc.enterprise_sonic.sonic_users:
    config:
    state: deleted

# After state:
# ------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin

# Using merged
#
# Before state:
# -------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin

- name: Merge users configurations
  dellemc.enterprise_sonic.sonic_users:
    config:
      - name: sysadmin
        role: admin
        password: admin
        update_password: always
      - name: sysoperator
        role: operator
        password: operator
        update_password: always
    state: merged

# After state:
# ------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# sysadmin                          admin
# sysoperator                       operator

# Using Overridden
#
# Before state:
# -------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# sysadmin                          admin
# sysoperator                       operator

- name: Override users configurations
  dellemc.enterprise_sonic.sonic_users:
    config:
      - name: user1
        role: secadmin
        password: 123abc
        update_password: always
    state: overridden

# After state:
# ------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# user1                             secadmin

# Using Replaced
#
# Before state:
# -------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# user1                             secadmin
# user2                             operator

- name: Replace users configurations
  dellemc.enterprise_sonic.sonic_users:
    config:
      - name: user1
        role: operator
        password: 123abc
        update_password: always
      - name: user2
        role: netadmin
        password: 123abc
        update_password: always
    state: replaced

# After state:
# ------------
#
# sonic# show users configured
# ----------------------------------------------------------------------
# User                              Role(s)
# ----------------------------------------------------------------------
# admin                             admin
# user1                             operator
# user2                             netadmin

返回值

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

描述

after

列表 / 元素=字符串

模块调用的结果配置。

返回:发生更改时

示例: ["The configuration returned will always be in the same format as the parameters above.\n"]

after(generated)

列表 / 元素=字符串

生成的模块调用配置。

返回:check_mode

示例: ["The configuration returned will always be in the same format as the parameters above.\n"]

before

列表 / 元素=字符串

模块调用之前的配置。

返回:始终

示例: ["The configuration returned will always be in the same format as the parameters above.\n"]

commands

列表 / 元素=字符串

推送到远程设备的命令集。

返回:始终

示例: ["command 1", "command 2", "command 3"]

作者

  • Niraimadaiselvam M (@niraimadaiselvamm)