blob: f306c2f8f80260a1c57fee66210405ee8be85b7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
---
# File: /etc/ansible/shell/vcenter_matrix/vcenter_matrix.yml
# Location: /etc/ansible/shell/vcenter_matrix/
# Author: bgstack15
# Startdate: 2017-12-14
# Title: Playbook
# Purpose: Generate a csv of vcenter,VM,uuid
# History:
# 2017-12-15 Added exclusion for Windows
# Usage: used by generate.sh
# Reference:
# Improve:
# Document:
- hosts: all
vars_files:
- /etc/ansible/shell/vcenter_matrix/username.yml
tasks:
- debug:
msg: "Now checking vcenter {{ vc_hostname }}."
- vmware_vm_facts:
username: "{{ vc_username }}"
hostname: "{{ vc_hostname }}"
password: "{{ vc_password }}"
validate_certs: no
delegate_to: localhost
register: vmfacts
- debug:
msg: "{{ vmfacts }}"
# - pause:
# prompt: "Please check the facts above."
- name: generate yml file
lineinfile:
dest: "{{ outputfile_yml }}"
line: '- { vcenter: "{{ vc_hostname }}", hostname: "{{ item.key }}", uuid: "{{ item.value.uuid }}" }'
insertafter: EOF
create: yes
delegate_to: localhost
with_dict: "{{ vmfacts.virtual_machines }}"
when:
- '"Windows" not in item.value.guest_fullname'
- name: generate csv file
lineinfile:
dest: "{{ outputfile_csv }}"
line: "{{ vc_hostname }},{{ item.key }},{{ item.value.uuid }}"
insertafter: EOF
create: yes
delegate_to: localhost
with_dict: "{{ vmfacts.virtual_machines }}"
when:
- '"Windows" not in item.value.guest_fullname'
|