Skip to content

Commit 9d675a3

Browse files
committed
Get Tags and Categories
Signed-off-by: Abhijeet Kasurde <[email protected]>
1 parent f245d9b commit 9d675a3

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Example Ansible playbook to manage VMware using HTTP APIs:
2222
- [Get a list of all Datastores available](../master/get_all_datastores.yml)
2323
- [Get a list of all Network available](../master/get_all_networks.yml)
2424
- [Get a list of all Virtual machine available](../master/get_all_vms.yml)
25+
- [Get a list of all categories available](../master/get_all_categories.yml)
26+
- [Get a list of all tags available](../master/get_all_tags.yml)
2527
- [Get information about the given Cluster](../master/get_cluster_info.yml)
2628

2729

get_all_categories.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
- name: Gather all Categories for vCenter
3+
gather_facts: no
4+
vars_files:
5+
- vcenter_vars.yml
6+
hosts: localhost
7+
tasks:
8+
- name: Login task
9+
include_tasks: login.yml
10+
11+
- name: Get Categories from vCenter
12+
uri:
13+
url: https://{{ vcenter_server }}/rest/com/vmware/cis/tagging/category
14+
force_basic_auth: yes
15+
validate_certs: "{{ validate_certs }}"
16+
headers:
17+
Cookie: "{{ login.set_cookie }}"
18+
register: vCategories
19+
20+
- name: Print names of Categories in the given vCenter
21+
debug:
22+
msg: "{{ item }}"
23+
with_items: "{{ vCategories.json.value }}"

get_all_tags.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
- name: Gather all Tags for vCenter
3+
gather_facts: no
4+
vars_files:
5+
- vcenter_vars.yml
6+
hosts: localhost
7+
tasks:
8+
- name: Login task
9+
include_tasks: login.yml
10+
11+
- name: Get Tags from vCenter
12+
uri:
13+
url: https://{{ vcenter_server }}/rest/com/vmware/cis/tagging/tag
14+
force_basic_auth: yes
15+
validate_certs: "{{ validate_certs }}"
16+
headers:
17+
Cookie: "{{ login.set_cookie }}"
18+
register: vTags
19+
20+
- name: Print names of Tags in the given vCenter
21+
debug:
22+
msg: "{{ item }}"
23+
with_items: "{{ vTags.json.value }}"

0 commit comments

Comments
 (0)