community.network.nuage_vspk 模块 – 管理 Nuage VSP 环境

注意

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

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

要安装它,请使用: ansible-galaxy collection install community.network。您需要其他要求才能使用此模块,有关详细信息,请参阅要求

要在 playbook 中使用它,请指定: community.network.nuage_vspk

注意

community.network 集合已被弃用,并将从 Ansible 12 中删除。有关更多信息,请参阅讨论主题

已弃用

已移除版本:

6.0.0 版本

原因:

此集合及其中的所有内容均未维护且已弃用。

替代方案:

未知。

概要

  • 管理或查找 Nuage VSP 实体,包括创建、更新、删除、分配、取消分配和查找,以及所有受支持的属性。

别名: network.nuage.nuage_vspk

要求

执行此模块的主机需要满足以下要求。

  • Python 2.7

  • 支持 Nuage VSP 4.0Rx & 5.x.y

  • 为您的 Nuage 版本安装正确的 VSPK-Python

  • 已使用 NuageX https://nuagex.io 进行测试

参数

参数

注释

auth

字符串 / 必填

包含连接到 Nuage VSP 环境所需的身份验证信息的字典。

需要一个 api_username 参数(例如 csproot)。

需要一个 api_password 参数(例如 csproot)或 api_certificateapi_key 参数,这些参数指向基于证书的身份验证的证书和密钥文件。

需要一个 api_enterprise 参数(例如 csp)。

需要一个 api_url 参数(例如 https://10.0.0.10:8443)。

需要一个 api_version 参数(例如 v4_0)。

children

字符串

可用于指定一组子实体。

每个子项的强制属性是 type

每个子项支持的可选属性是 idpropertiesmatch_filter

这些属性中的每一个的功能与常规任务定义中的功能相同。

可以递归使用

仅在 state=present 的情况下可用。

command

字符串

指定要执行的命令。

如果定义了 command=findparent_idparent_type,它将仅在父项中搜索。否则,如果允许,将在根对象中搜索。

如果指定了 command=findid,它将仅返回与 ID 匹配的单个实体。

如果定义了 command=find,否则,如果定义了 match_filter,它将使用该过滤器进行搜索。

如果定义了 command=find,否则,如果定义了 properties,它将使用所有属性执行 AND 搜索。

使用 command=change_password,可以更改用户的密码。警告 - 如果密码与现有密码相同,则会抛出错误。

使用 command=wait_for_job,该模块将等待作业状态为 SUCCESS 或 ERROR。如果发现 ERROR 状态,该模块将退出并显示错误。

使用 command=wait_for_job,即使状态为 ERROR,作业也始终会返回。

需要定义 statecommand 中的一个,两者不能同时定义。

选项

  • "find"

  • "change_password"

  • "wait_for_job"

  • "get_csp_enterprise"

id

字符串

您要操作的实体的 ID。

command=find 结合使用时,它将仅返回单个实体。

state 结合使用时,它将更新或删除此实体。

当需要查找实体时,将优先于 match_filterproperties

match_filter

字符串

在查找(在 commandstate 中)实体时使用的过滤器,格式为 Nuage VSP API 所期望的格式。

如果定义了 match_filter,它将优先于 properties,但不会优先于 id

parent_id

字符串

您要操作的实体的父项的 ID。

当指定了 state 时,如果存在,将从此父项收集该实体,除非指定了 id

当指定了 command=find 时,将在此父项中搜索该实体,除非指定了 id

如果指定了,还需要指定 parent_type

parent_type

字符串

为其指定 ID 的父项的类型(例如 Enterprise)。

这应与 VSPK-Python 中的对象的 CamelCase 类名匹配。

可以在 https://nuagenetworks.github.io/vspkdoc/index.html 上找到此类名。

如果指定了,还需要指定 parent_id

properties

字符串

属性是实体具有的不同属性的键值对。

如果未指定 id 且未指定 match_filter,则使用它们来查找或确定实体是否存在。

state

字符串

指定实体的所需状态。

如果 state=present,如果实体已存在,将根据需要更新实体。

如果 state=present,并且与父级的关系是成员关系,则会将实体指定为父级的成员。

如果 state=absent,并且与父级的关系是成员关系,则会取消将实体指定为父级的成员。

需要定义 statecommand 中的一个,两者不能同时定义。

选项

  • "present"(存在)

  • "absent"(不存在)

类型

字符串 / 必填

您要操作的实体类型(例如,企业)。

这应与 VSPK-Python 中的对象的 CamelCase 类名匹配。

可以在 https://nuagenetworks.github.io/vspkdoc/index.html 上找到此类名。

注释

注意

  • 支持检查模式,但有一些注意事项。它不会进行任何更改,并且如果可能,会尝试确定是否能够执行请求的操作。

  • 如果从之前的任务中提供了父级 ID,它可能为空,如果可以在根目录上进行搜索,它将会执行搜索,这可能会影响性能。

示例

# This can be executed as a single role, with the following vars
# vars:
#   auth:
#     api_username: csproot
#     api_password: csproot
#     api_enterprise: csp
#     api_url: https://10.0.0.10:8443
#     api_version: v5_0
#   enterprise_name: Ansible-Enterprise
#   enterprise_new_name: Ansible-Updated-Enterprise
#
# or, for certificate based authentication
# vars:
#   auth:
#     api_username: csproot
#     api_certificate: /path/to/user-certificate.pem
#     api_key: /path/to/user-Key.pem
#     api_enterprise: csp
#     api_url: https://10.0.0.10:8443
#     api_version: v5_0
#   enterprise_name: Ansible-Enterprise
#   enterprise_new_name: Ansible-Updated-Enterprise

# Creating a new enterprise
- name: Create Enterprise
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: Enterprise
    state: present
    properties:
      name: "{{ enterprise_name }}-basic"
  register: nuage_enterprise

# Checking if an Enterprise with the new name already exists
- name: Check if an Enterprise exists with the new name
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: Enterprise
    command: find
    properties:
      name: "{{ enterprise_new_name }}-basic"
  ignore_errors: true
  register: nuage_check_enterprise

# Updating an enterprise's name
- name: Update Enterprise name
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: Enterprise
    id: "{{ nuage_enterprise.id }}"
    state: present
    properties:
      name: "{{ enterprise_new_name }}-basic"
  when: nuage_check_enterprise is failed

# Creating a User in an Enterprise
- name: Create admin user
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: User
    parent_id: "{{ nuage_enterprise.id }}"
    parent_type: Enterprise
    state: present
    match_filter: "userName == 'ansible-admin'"
    properties:
      email: "[email protected]"
      first_name: "Ansible"
      last_name: "Admin"
      password: "ansible-password"
      user_name: "ansible-admin"
  register: nuage_user

# Updating password for User
- name: Update admin password
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: User
    id: "{{ nuage_user.id }}"
    command: change_password
    properties:
      password: "ansible-new-password"
  ignore_errors: true

# Finding a group in an enterprise
- name: Find Administrators group in Enterprise
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: Group
    parent_id: "{{ nuage_enterprise.id }}"
    parent_type: Enterprise
    command: find
    properties:
      name: "Administrators"
  register: nuage_group

# Assign the user to the group
- name: Assign admin user to administrators
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: User
    id: "{{ nuage_user.id }}"
    parent_id: "{{ nuage_group.id }}"
    parent_type: Group
    state: present

# Creating multiple DomainTemplates
- name: Create multiple DomainTemplates
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: DomainTemplate
    parent_id: "{{ nuage_enterprise.id }}"
    parent_type: Enterprise
    state: present
    properties:
      name: "{{ item }}"
      description: "Created by Ansible"
  with_items:
    - "Template-1"
    - "Template-2"

# Finding all DomainTemplates
- name: Fetching all DomainTemplates
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: DomainTemplate
    parent_id: "{{ nuage_enterprise.id }}"
    parent_type: Enterprise
    command: find
  register: nuage_domain_templates

# Deleting all DomainTemplates
- name: Deleting all found DomainTemplates
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: DomainTemplate
    state: absent
    id: "{{ item.ID }}"
  with_items: "{{ nuage_domain_templates.entities }}"
  when: nuage_domain_templates.entities is defined

# Unassign user from group
- name: Unassign admin user to administrators
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: User
    id: "{{ nuage_user.id }}"
    parent_id: "{{ nuage_group.id }}"
    parent_type: Group
    state: absent

# Deleting an enterprise
- name: Delete Enterprise
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: Enterprise
    id: "{{ nuage_enterprise.id }}"
    state: absent

# Setup an enterprise with Children
- name: Setup Enterprise and domain structure
  connection: local
  community.network.nuage_vspk:
    auth: "{{ nuage_auth }}"
    type: Enterprise
    state: present
    properties:
      name: "Child-based-Enterprise"
    children:
    - type: L2DomainTemplate
      properties:
        name: "Unmanaged-Template"
      children:
      - type: EgressACLTemplate
        match_filter: "name == 'Allow All'"
        properties:
          name: "Allow All"
          active: true
          default_allow_ip: true
          default_allow_non_ip: true
          default_install_acl_implicit_rules: true
          description: "Created by Ansible"
          priority_type: "TOP"
      - type: IngressACLTemplate
        match_filter: "name == 'Allow All'"
        properties:
          name: "Allow All"
          active: true
          default_allow_ip: true
          default_allow_non_ip: true
          description: "Created by Ansible"
          priority_type: "TOP"

返回值

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

描述

entities(实体)

list / elements=string

处理的实体列表。每个元素都是实体的 to_dict()。

返回:在 state=present 和 find 的情况下,如果 state=present 或 find=one,则只有一个元素。

示例: [{"ID": "acabc435-3946-4117-a719-b8895a335830\"", "assocEntityType": "DOMAIN", "command": "BEGIN_POLICY_CHANGES", "creationDate": 1487515656000, "entityScope": "ENTERPRISE", "externalID": null, "lastUpdatedBy": "8a6f0e20-a4db-4878-ad84-9cc61756cd5e", "lastUpdatedDate": 1487515656000, "owner": "8a6f0e20-a4db-4878-ad84-9cc61756cd5e", "parameters": null, "parentID": "a22fddb9-3da4-4945-bd2e-9d27fe3d62e0", "parentType": "domain", "progress": 0.0, "result": null, "status": "RUNNING"}]

id

字符串

找到、创建、更新或分配的实体的 ID。

返回:在 state=present 和 command=find 的情况下,如果找到一个实体。

示例: "bae07d8d-d29c-4e2b-b6ba-621b4807a333"

状态

  • 此模块将在 6.0.0 版本中删除。[已弃用]

  • 有关更多信息,请参阅已弃用

作者

  • Philippe Dellaert (@pdellaert)