Hi Tom,
Thanks a lot for your answer :)
I already tried this yesterday but it is not working for me. Probably, I am
not understanding it correctly. This is what I tried:
First, I tried this task:
- name: Getting the IDs for the VMs running under the user
sudo: True
sudo_user: oneadmin
shell: onevm list | grep {{ item.value.login_name }} | awk 'BEGIN {FS="
"}{print $1}'
with_dict: disable_users_account
register: VMIDs_per_user
ignore_errors: yes
tags:
- delete_VMs
- name: Delete the VMs running under the user
sudo: True
sudo_user: oneadmin
command: onevm delete {{ item }}
with_items: "{{VMIDs_per_user.stdout_lines}}"
tags:
- delete_VMs
But I got the following error:
ansible-playbook -i inventory/production site.yml -vvvvvvv --limit opennebula
--tags=delete_VMs
Traceback (most recent call last):
File "/usr/bin/ansible-playbook", line 324, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/bin/ansible-playbook", line 264, in main
pb.run()
File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line
310, in run
play = Play(self, play_ds, play_basedir, vault_password=self.vault_password)
File "/usr/lib/python2.7/site-packages/ansible/playbook/play.py", line 194, in
__init__
self._tasks = self._load_tasks(self._ds.get('tasks', []), load_vars)
File "/usr/lib/python2.7/site-packages/ansible/playbook/play.py", line 669, in
_load_tasks
loaded = self._load_tasks(data, mv, role_params, default_vars,
included_become_vars, list(included_additional_conditions),
original_file=include_filename, role_name=new_role)
File "/usr/lib/python2.7/site-packages/ansible/playbook/play.py", line 650, in
_load_tasks
(k,v) = t.split("=", 1)
ValueError: need more than 1 value to unpack
Also tried with stdout split, I don't remember now the exactly thing that I
tried it but it did not work.
This is my ansible version:
ansible --version
ansible 1.9.1
configured module search path = None
Thanks in advance,
Esteban
El lunes, 6 de julio de 2015, 22:59:14 (UTC+2), Tom Paine escribió:
>
>
> https://docs.ansible.com/playbooks_loops.html#iterating-over-the-results-of-a-program-execution
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/502864e3-a9e3-4b66-a09f-84c335f41124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.