Skip to content

Instantly share code, notes, and snippets.

@vallard
Last active February 21, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vallard/048c132f1c46e1370f3591a2323f0313 to your computer and use it in GitHub Desktop.
Save vallard/048c132f1c46e1370f3591a2323f0313 to your computer and use it in GitHub Desktop.
UCS Ansible Modules Installation

1. Create CentOS VM server

  • 4GB of RAM
  • 8GB of Disk space

I did mine using VMM on an old RedHat server I had.

2. Install dependencies

SSH into machine (I used: root@192.168.2.225)

yum -y install ansible git
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py

Get UCS Ansible Files

pip install ucsmsdk
git clone https://github.com/ciscoucs/ucsm_apis
cd ucsm_apis
sudo make install
cd ~/
git clone https://github.com/dsoper2/ucsm-ansible
cd ucsm-ansible
python install.py

3. Configure Ansible to communicate with your UCS

cd ~/ucsm-ansible
touch inventory/pdx # alternatively name it something about your site. 

In this file make it similar to the following:

[pdx]
ucs1 ucs_ip=172.28.225.159 ucs_username=admin ucs_password=Cisco123
ucs2 ucs_ip=172.28.225.163 ucs_username=admin ucs_password=Cisco123

You can add additional systems. In this case the group is pdx and the server names are ucs1 and ucs2. In this way ansible can communicate with multiple UCS domains at the same time.

4. Playbook for VLANs

We created a playbook called VLANs that looks like the following:

---

- hosts: localhost
  connection: local
  gather_facts: no
  roles:
  - common

- hosts: pdx
  connection: local
  gather_facts: no
  tasks:
  - name: ensure VLANs 104-106 are in place.
    ucs_vlans:
      hostname: "{{ucs_ip}}"
      username: "{{ucs_username}}"
      password: "{{ucs_password}}"
      vlan_list:
      - name: vlan104
        id: "104"
      - name: vlan105
        id: "105"
      - name: vlan106
        id: "106"

Then we deploy it with:

ansible-playbook vlan.yml
---
- hosts: pdx
connection: local
gather_facts: no
tasks:
- name: ensure IP pools are in place.
ucs_ippool:
hostname: "{{ucs_ip}}"
username: "{{ucs_username}}"
password: "{{ucs_password}}"
ip_list:
- name: ext-mgmt
first_addr: 172.28.225.145
last_addr: 172.28.225.159
subnetmask: 255.255.255.0
default_gw: 172.28.225.1
primary_dns: 171.70.168.183
order: sequential
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment