huaweidatacom.ac.ac_token (1.0.0) — module

Get Token from HUAWEI iMaster NCE-Fabric Controller.

Authors: ZhiwenZhang (@maomao1995)

Install collection

Install with ansible-galaxy collection install huaweidatacom.ac:==1.0.0


Add to requirements.yml

  collections:
    - name: huaweidatacom.ac
      version: 1.0.0

Description

Get Tenant from HUAWEI iMaster NCE-Fabric Controller(AC).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get Token
  hosts: localhost
  serial: True
  vars_prompt:
    - name: "userName"
      prompt: "Please input userName "
      private: no
    - name: "password"
      prompt: "Please input password "
      echo: no
  tasks:
    - name: delete old access token
      tags: always
      vars:
        token_info:
          token: "{{lookup('file','/tmp/ansible-temp')}}"
      uri:
        url: 'https://{{north_ip}}:{{north_port}}/controller/v2/tokens'
        method: DELETE
        body: '{{token_info}}'
        body_format: json
        validate_certs: False
        headers:
          Accept: application/json
      ignore_errors: yes
    - name: get access token
      tags: always
      vars:
        auth_user:
          userName: '{{userName}}'
          password: '{{password}}'
      uri:
        url: 'https://{{north_ip}}:{{north_port}}/controller/v2/tokens'
        method: POST
        body: '{{auth_user}}'
        body_format: json
        validate_certs: False
        return_content: yes
        headers:
          Accept: application/json
        status_code: 200
      register: token_result
    - local_action: copy content='{{token_result.json.data.token_id}}' dest="/tmp/ansible-temp"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete Token
  hosts: localhost
  serial: True
  tasks:
    - name: delete access token
      tags: always
      vars:
        token_info:
          token: "{{lookup('file','/tmp/ansible-temp')}}"
      uri:
        url: 'https://{{north_ip}}:{{north_port}}/controller/v2/tokens'
        method: DELETE
        body: '{{token_info}}'
        body_format: json
        validate_certs: False
        return_content: yes
        headers:
          Accept: application/json
        status_code: 200
      register: token_result
    - name: response from delete access token
      tags: always
      debug:
        msg: "{{token_result.json}}"

Inputs

    
password:
    description:
    - AC User password.

userName:
    description:
    - AC User name.