1---
2# Example Playbook: cisco.ucs.ucs_query
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        # use "<<: *login_info" to substite the information below in each task
14        # this is not required, however it makes the playbook shorter.
15        login_info: &login_info
16          hostname: "{{ ucs_hostname }}"
17          username: "{{ ucs_username }}"
18          password: "{{ ucs_password }}"
19
20    - name: Query UCS Class ID
21      cisco.ucs.ucs_query:
22        <<: *login_info
23        class_ids: computeBlade
24        delegate_to: localhost
25      register: response
26
27    - name: show response
28      debug:
29        msg: "{{ response }}"
30
31    - name: Query UCS Class IDs
32      cisco.ucs.ucs_query:
33        <<: *login_info
34        class_ids: computeBlade, fabricVlan
35        delegate_to: localhost
36      register: response
37
38    - name: show response
39      debug:
40        msg: "{{ response }}"
41
42    - name: Query UCS Distinguished Name
43      cisco.ucs.ucs_query:
44        <<: *login_info
45        distinguished_names: org-root
46        delegate_to: localhost
47      register: response
48
49    - name: show response
50      debug:
51        msg: "{{ response }}"
52
53    - name: Query UCS Distinguished Names
54      cisco.ucs.ucs_query:
55        <<: *login_info
56        distinguished_names: org-root, sys/rack-unit-1, sys/chassis-1/blade-2
57        delegate_to: localhost
58      register: response
59
60    - name: show response
61      debug:
62        msg: "{{ response }}"