CiscoDevNet / ansible-ucs

Cisco UCS Ansible Collection
MIT License
13 stars 6 forks source link
ansible-collection

Ansible Collection - cisco.ucs

Ansible collection for managing and automing Cisco UCS Manager envrionments. Modules and roles are provided for common Cisco UCS Manager tasks.

Requirements

Install

Usage

Once Ansible is installed you can create inventory files and playbooks to manage your UCS domains. Each module supports ansible-doc which includes example usage:

# ansible-doc cisco.ucs.ucs_vlans
<snip>
EXAMPLES:
- name: Configure VLAN
  cisco.ucs.ucs_vlans:
    hostname: 172.16.143.150
    username: admin
    password: password
    name: vlan2
    id: '2'
    native: 'yes'

This repository includes a playbooks directory with examples including an inventory file that can be edited with information for the UCSM domain you want to configure:

# vi inventory
[ucs]
13.58.22.56

[ucs:vars]
username=admin
password=password

An example_playbook.yml playbook is included to test VLAN configuration on the UCSM domain given in the inventory file:

# vi example_playbook.yml 

---
# Example Playbook: VLAN configuration using the [ucs] hosts group
- hosts: ucs
  connection: local
  collections:
    - cisco.ucs
  gather_facts: false
  tasks:
    - name: Configure VLAN
      ucs_vlans:
        hostname: "{{ inventory_hostname }}"
        username: "{{ username | default(omit) }}"
        password: "{{ password }}"
        state: "{{ state | default(omit) }}"
        name: vlan2
        id: '2'
        native: 'no'
      delegate_to: localhost

Ansible will use data from the inventory file for the hostname and other variables above. Multiple UCSM domains can be listed in the inventory file and Ansible will configure all the listed domains in parallel using host specific data.

The ansible-playbook command can be used to run the above playbook and inventory file:

# ansible-playbook -i inventory example_playbook.yml 

PLAY [ucs] *********************************************************************

TASK [Configure VLAN] **********************************************************
ok: [13.58.22.56 -> localhost]

PLAY RECAP *********************************************************************
13.58.22.56                : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    

A more detailed configuration example is provided in the server_deploy.yml playbook.

Community: