xlab_si.nuage_miq_automate
Ansible Role: nuage_miq_automate
This role connects to the ManageIQ Automation Workspace to give you Nuage credentials (the variable nuage_auth) and EMS event data (the variable event).
- Nuage credentials. You need to follow the format specified in the Nuage Ansible module documentation. Here is an example:
 
nuage_auth:
  api_username: user
  api_password: pass
  api_enterprise: csp
  api_url: https://nuagedemo.net:8443
  api_version: v5_0
- EMS event data. This data provides details about the event you're handling. Here’s a sample:
 
event:
  ems_id: '2'                   # EMS ID for the generated event
  type: CREATE                  # Event type
  entityType: enterprise         # Type of entity for the event
  entity:                       # Entity details
    entity_type: enterprise
    ID: 07f2726a-7f83-4826-87bd-7f7664803938
    name: DEMO3
  full_data:                   # Complete event data from Nuage server
    associatedEvent: false
    enterpriseName: csp
    entities:
    - entityType: enterprise
      ID: 07f2726a-7f83-4826-87bd-7f7664803938
      name: DEMO3
    eventReceivedTime: 1535011120658
    requestID: 62c58aa6-4150-46c7-95fe-ed4051e70864
    type: CREATE
For more information about what this role does, please check out this blog post and this YouTube video.
Requirements
Make sure you have the following attributes set up on your Automate Instance running the nuage_miq_automate role:
nuage_username, e.g. usernuage_password(encrypted), e.g. passnuage_enterprise, e.g. cspnuage_url, e.g. https://nuagedemo.net:8443nuage_api_version, e.g. v5_0

This role's main purpose is to retrieve these attributes from the Automation Workspace.
NOTE: You don’t need to specify these five attributes for every Automate Instance. You can set default values in the Schema, making them accessible to all Instances of a class. If your credentials change, you only have to update those defaults.
Role Variables
| Variable | Default | Description | 
|---|---|---|
| manageiq | / | Provided by Automate. | 
| manageiq_connection | / | Provided by Automate. | 
manageiq:
  X_MIQ_Group: Tenant My Company access
  api_token: 2d5d9031361a6ac570d810406f267cea
  api_url: 'http://localhost:4000'
  automate_workspace: automate_workspaces/82632486-7529-45c6-8fa7-fc53ebbb157d
  group: groups/1
  user: users/1
manageiq_connection:
  X_MIQ_Group: Tenant My Company access
  token: 2d5d9031361a6ac570d810406f267cea
  url: 'http://localhost:4000'
You won’t need to manually provide the role inputs as ManageIQ Automate takes care of that.
Outputs
This role will set these variables for you:
| Variable | Description | 
|---|---|
| nuage_auth | Nuage authentication details. Can be used directly with the nuage_vspk module. | 
| event | EMS event data (as described above). | 
| object | The current Automate Instance's absolute name. | 
event:
  type:        CREATE
  ems_id:      4
  entity_type: subnet
  full_data:   { ... } # complete event data from Nuage provider
  entity:      { ... } # event['entities'].first
Dependencies
This role needs the following roles available on Ansible Galaxy:
Example Playbook
If you want to create a DomainTemplate every time a new Enterprise is created, here’s a playbook you can use:
- name: Nuage event callback example
  hosts: localhost
  connection: local
  gather_facts: False
  roles:
  - xlab_si.nuage_miq_automate
  tasks:
  - debug: msg="I am a playbook running as an event callback and I can access Nuage credentials"
  - debug: var=nuage_auth
  - debug: msg="I also have details of the event that triggered me"
  - debug: var=event
  - debug: msg="Now I'm ready to take action!"
  
  - name: Create Domain Template on Enterprise
    delegate_to: localhost
    nuage_vspk:
      auth: "{{ nuage_auth }}"            # forwarding `nuage_auth`
      type: DomainTemplate
      parentType: Enterprise
      parentId: "{{ event.entity.ID }}"  # accessing the `event` variable
      state: present
      properties:
        name: "Demo Domain Template"
This playbook can be hooked to the nuage_enterprise_create event. 
License
BSD
This role accesses ManageIQ Automation Workspace for you to provide you with Nuage credentials and EMS event data.
ansible-galaxy install xlab_si.nuage_miq_automate