Hi All,
Could do with some Help with this issue:
I am trying to get the Powerstate of a Virtual Machine and power off when
powerstate != poweroff
and looking at a way to copy the copy the Cluster variable to a Text File:
---
- name: Running Create Virtual Machine Playbook
hosts: localhost
gather_facts: false
connection: local
tasks:
- name: Getting Info from Virtual Machine
vmware_vm_info:
validate_certs: no
hostname: "{{ vcenter }}"
username: "{{ user }}"
password: "{{ password }}"
folder: "/"
delegate_to: localhost
register: vminfo
- debug:
msg: "{{ item.power_state }}"
with_items:
- "{{ vm_info.virtual_machines | json_query(query) }}"
vars:
query: "[?guest_name=='win201_old']"
- vmware_guest_powerstate:
validate_certs: no
hostname: "{{ vcenter }}"
username: "{{ user }}"
password: "{{ password }}"
name: win201_old
state: powered-off
delegate_to: localhost
when: "{{ item.power_state }}" != "poweredOff"
- name: Copy Variable
copy:
content: '{{ item.cluster }}'
dest: /srv/ansible/test.txt
delegate_to: localhost
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5a5cc162-6dea-4af5-b5a9-af061ab8a1a0%40googlegroups.com.