Add a playbook implementation of list-vm's per host
This commit is contained in:
parent
7b8d58fa80
commit
2e8d14a5e0
2 changed files with 26 additions and 0 deletions
6
files/virthost-lists.j2
Normal file
6
files/virthost-lists.j2
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% for key, value in virt_info.items() %}
|
||||
{% if value and 'state' in value %}
|
||||
{{inventory_hostname}}:{{key}}:{{value['state']}}:{{value['autostart']}}:{{value['nrVirtCpu']}}:{{value['memory']}}
|
||||
{% else %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
20
playbooks/list-vms-per-host.yml
Normal file
20
playbooks/list-vms-per-host.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# This playbook runs once per hour on batcave01 and generates a list of vms on virthosts
|
||||
#
|
||||
---
|
||||
- hosts: virtservers
|
||||
user: root
|
||||
gather_facts: True
|
||||
|
||||
vars_files:
|
||||
- /srv/web/infra/ansible/vars/global.yml
|
||||
- "/srv/private/ansible/vars.yml"
|
||||
- "/srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml"
|
||||
|
||||
tasks:
|
||||
|
||||
- virt: command=info
|
||||
register: virt_info
|
||||
|
||||
- template: src={{files}}/virthost-lists.j2 dest=/tmp/virthost-lists.out
|
||||
delegate_to: localhost
|
Loading…
Add table
Add a link
Reference in a new issue