| 1 |
--- |
| 2 |
|
| 3 |
- hosts: ucs |
| 4 |
connection: local |
| 5 |
gather_facts: false |
| 6 |
|
| 7 |
tasks: |
| 8 |
- name: Test that we have a UCS hostname, UCS username, and UCS password |
| 9 |
fail: |
| 10 |
msg: 'Please define the following variables: ucs_hostname, ucs_username and ucs_password.' |
| 11 |
when: ucs_hostname is not defined or ucs_username is not defined or ucs_password is not defined |
| 12 |
vars: |
| 13 |
|
| 14 |
|
| 15 |
login_info: &login_info |
| 16 |
hostname: "{{ ucs_hostname }}" |
| 17 |
username: "{{ ucs_username }}" |
| 18 |
password: "{{ ucs_password }}" |
| 19 |
|
| 20 |
- name: Add UCS Organization |
| 21 |
cisco.ucs.ucs_org: |
| 22 |
<<: *login_info |
| 23 |
org_name: level1 |
| 24 |
parent_org_path: root |
| 25 |
description: level1 org |
| 26 |
state: present |
| 27 |
delegate_to: localhost |
| 28 |
|
| 29 |
- name: Configure Network Control Policy |
| 30 |
cisco.ucs.ucs_managed_objects: |
| 31 |
<<: *login_info |
| 32 |
objects: |
| 33 |
- module: ucsmsdk.mometa.nwctrl.NwctrlDefinition |
| 34 |
class: NwctrlDefinition |
| 35 |
properties: |
| 36 |
parent_mo_or_dn: org-root/org-level1 |
| 37 |
cdp: enabled |
| 38 |
descr: '' |
| 39 |
lldp_receive: enabled |
| 40 |
lldp_transmit: enabled |
| 41 |
name: Enable-CDP-LLDP |
| 42 |
delegate_to: localhost |
| 43 |
|
| 44 |
- name: Remove Network Control Policy |
| 45 |
cisco.ucs.ucs_managed_objects: |
| 46 |
<<: *login_info |
| 47 |
objects: |
| 48 |
- module: ucsmsdk.mometa.nwctrl.NwctrlDefinition |
| 49 |
class: NwctrlDefinition |
| 50 |
properties: |
| 51 |
parent_mo_or_dn: org-root/org-level1 |
| 52 |
name: Enable-CDP-LLDP |
| 53 |
state: absent |
| 54 |
delegate_to: localhost |
| 55 |
|
| 56 |
- name: Configure Boot Policy Using JSON objects list with children |
| 57 |
cisco.ucs.ucs_managed_objects: |
| 58 |
<<: *login_info |
| 59 |
objects: |
| 60 |
- { |
| 61 |
"module": "ucsmsdk.mometa.lsboot.LsbootPolicy", |
| 62 |
"class": "LsbootPolicy", |
| 63 |
"properties": { |
| 64 |
"parent_mo_or_dn": "org-root/org-level1", |
| 65 |
"name": "Python_SDS", |
| 66 |
"enforce_vnic_name": "yes", |
| 67 |
"boot_mode": "legacy", |
| 68 |
"reboot_on_update": "no" |
| 69 |
}, |
| 70 |
"children": [ |
| 71 |
{ |
| 72 |
"module": "ucsmsdk.mometa.lsboot.LsbootVirtualMedia", |
| 73 |
"class": "LsbootVirtualMedia", |
| 74 |
"properties": { |
| 75 |
"access": "read-only-local", |
| 76 |
"lun_id": "0", |
| 77 |
"order": "2" |
| 78 |
} |
| 79 |
}, |
| 80 |
{ |
| 81 |
"module": "ucsmsdk.mometa.lsboot.LsbootStorage", |
| 82 |
"class": "LsbootStorage", |
| 83 |
"properties": { |
| 84 |
"order": "1" |
| 85 |
}, |
| 86 |
"children": [ |
| 87 |
{ |
| 88 |
"module": "ucsmsdk.mometa.lsboot.LsbootLocalStorage", |
| 89 |
"class": "LsbootLocalStorage", |
| 90 |
"properties": {}, |
| 91 |
"children": [ |
| 92 |
{ |
| 93 |
"module": "ucsmsdk.mometa.lsboot.LsbootDefaultLocalImage", |
| 94 |
"class": "LsbootDefaultLocalImage", |
| 95 |
"properties": { |
| 96 |
"order": "1" |
| 97 |
} |
| 98 |
} |
| 99 |
] |
| 100 |
} |
| 101 |
] |
| 102 |
} |
| 103 |
] |
| 104 |
} |
| 105 |
delegate_to: localhost |
| 106 |
|
| 107 |
- name: Remove Boot Policy Using JSON objects list |
| 108 |
cisco.ucs.ucs_managed_objects: |
| 109 |
<<: *login_info |
| 110 |
objects: |
| 111 |
- { |
| 112 |
"module": "ucsmsdk.mometa.lsboot.LsbootPolicy", |
| 113 |
"class": "LsbootPolicy", |
| 114 |
"properties": { |
| 115 |
"parent_mo_or_dn": "org-root/org-level1", |
| 116 |
"name": "Python_SDS" |
| 117 |
} |
| 118 |
} |
| 119 |
state: absent |
| 120 |
delegate_to: localhost |
| 121 |
|
| 122 |
- name: Remove UCS Organization |
| 123 |
cisco.ucs.ucs_org: |
| 124 |
<<: *login_info |
| 125 |
org_name: level1 |
| 126 |
parent_org_path: root |
| 127 |
state: absent |
| 128 |
delegate_to: localhost |