I understand this is the basics, but I'm still learning... Could anybody help?
Its output is looking like:
ok: [localhost] => (item={'guest_name': 'xxxxxx', 'guest_fullname': 'Microsoft Windows Server 2022 (64-bit)', 'power_state': 'poweredOn', 'ip_address': 'xxxxxx', 'mac_address': ['xxxxxx'], 'uuid': 'xxxxxx', 'instance_uuid': 'xxxxxx', 'vm_network': {'xxxxxx': {'ipv4': ['xxxxxx'], 'ipv6': []}}, 'esxi_hostname': 'xxxxxx', 'datacenter': 'xxxxxx', 'cluster': 'xxxxxx', 'resource_pool': None, 'attributes': {}, 'tags': [], 'folder': 'xxxxxx', 'moid': 'xxxxxx', 'datastore_url': [{'name': 'xxxxxx', 'url': 'xxxxxx'}], 'allocated': {}}) => {
"msg": "server01"
}
ok: [localhost] => (item={'guest_name': 'xxxxxx', 'guest_fullname': 'Microsoft Windows Server 2022 (64-bit)', 'power_state': 'poweredOn', 'ip_address': 'xxxxxx', 'mac_address': ['xxxxxx'], 'uuid': 'xxxxxx', 'instance_uuid': 'xxxxxx', 'vm_network': {'xxxxxx': {'ipv4': ['xxxxxx'], 'ipv6': []}}, 'esxi_hostname': 'xxxxxx', 'datacenter': 'xxxxxx', 'cluster': 'xxxxxx', 'resource_pool': None, 'attributes': {}, 'tags': [], 'folder': 'xxxxxx', 'moid': 'xxxxxx', 'datastore_url': [{'name': 'xxxxxx', 'url': 'xxxxxx'}], 'allocated': {}}) => {
"msg": "server02"
}
ok: [localhost] => (item={'guest_name': 'xxxxxx', 'guest_fullname': 'Microsoft Windows Server 2022 (64-bit)', 'power_state': 'poweredOn', 'ip_address': 'xxxxxx', 'mac_address': ['xxxxxx'], 'uuid': 'xxxxxx', 'instance_uuid': 'xxxxxx', 'vm_network': {'xxxxxx': {'ipv4': ['xxxxxx'], 'ipv6': []}}, 'esxi_hostname': 'xxxxxx', 'datacenter': 'xxxxxx', 'cluster': 'xxxxxx', 'resource_pool': None, 'attributes': {}, 'tags': [], 'folder': 'xxxxxx', 'moid': 'xxxxxx', 'datastore_url': [{'name': 'xxxxxx', 'url': 'xxxxxx'}], 'allocated': {}}) => {
"msg": "server03"
}
Two questions, if you don't mind..:
01 - How, if even possible, could I have the output looking like something like this?
ok: [localhost]
msg": "server01"
ok: [localhost]
msg": "server02"
ok: [localhost]
msg": "server03"
02 - Would it be possible to send the loop output to a file?
I know that the whole "{{ vm_list }}" content can be send to a file using:
- name: Copy list to file
ansible.builtin.copy:
content: "{{ vm_list | to_yaml }}"
dest: "{{ path_to_file }}"
But I'd like to create a file with the already parsed content
Thanks a lot,
Alex
--
| Alex Wanderley Application and Infrastructure Analyst II Server Solutions & Automation Financial and Corporate Services | Open City and Technology 780-496-4156 Office 780-819-0273 Mobile
City of Edmonton Century Place, 19th Floor
9803 102A Avenue NW Edmonton AB, T5J 3A3 All information contained in this email post is proprietary to the City of Edmonton, confidential and intended only for the addressed recipient. If you have received this post in error, please disregard the contents, inform the sender of the misdirection, and remove it from your system. The copying, dissemination or distribution of this email, if misdirected, is strictly prohibited.
|