Hi Tom, all
I had a typo on my main task but anyway, I don’t get to manage to do this yet.
If I tried it as in the link provided by you, I get the following issue:
`
with_items: “{{VMIDs_per_user.stdout_lines}}”
`
`
TASK: [ON4_project_managment | Delete the VMs running under the user] *********
fatal: [m-opennebula4] => with_items expects a list or a set
`
Then, I have tried the following things:
`
shell: onevm delete {{ item.stdout.split(‘\n’) }}
shell: onevm delete “{{ item.stdout.split(‘\n’) }}”
shell: onevm delete {{ item.stdout.split(“\n”) }}
shell: onevm delete {{ item.stdout.splitlines() }}
`
`
with_items: “{{VMIDs_per_user.stdout_lines}}”
`
But I got the following issue:
`
failed: [m-opennebula4] => (item={u’cmd’: u’onevm list | grep testing-admin | awk 'BEGIN {FS=" “}{print $1}'‘, u’end’: u’2015-07-08 15:26:43.028904’, u’stderr’: u’‘, u’stdout’: u’685\n686’, u’changed’: True, u’rc’: 0, ‘item’: {‘value’: {‘login_name’: ‘testing-admin’}, ‘key’: ‘user’}, u’warnings’: , u’delta’: u’0:00:00.778189’, ‘invocation’: {‘module_name’: u’shell’, ‘module_args’: u’onevm list | grep testing-admin | awk 'BEGIN {FS=” "}{print $1}'‘}, ‘stdout_lines’: [u’685’, u’686’], u’start’: u’2015-07-08 15:26:42.250715’}) => {“changed”: true, “cmd”: “onevm delete [u’685’, u’686’]”, “delta”: “0:00:01.095980”, “end”: “2015-07-08 15:26:44.508902”, “item”: {“changed”: true, “cmd”: “onevm list | grep testing-admin | awk ‘BEGIN {FS=" "}{print $1}’”, “delta”: “0:00:00.778189”, “end”: “2015-07-08 15:26:43.028904”, “invocation”: {“module_args”: “onevm list | grep testing-admin | awk ‘BEGIN {FS=" "}{print $1}’”, “module_name”: “shell”}, “item”: {“key”: “user”, “value”: {“login_name”: “testing-admin”}}, “rc”: 0, “start”: “2015-07-08 15:26:42.250715”, “stderr”: “”, “stdout”: “685\n686”, “stdout_lines”: [“685”, “686”], “warnings”: }, “rc”: 255, “start”: “2015-07-08 15:26:43.412922”, “warnings”: }
stdout: VM named [u685 not found.
command delete: argument 0 must be one of range, vmid_list
`
So, it seems it is splitting the lines according to stdout_lines': [u'685', u'686'] and ``"stdout": "685\n686", "stdout_lines": ["685", "686"] . The problem is
that it is taking the [" characteres as [u and I don’t know how to remove that.
Any idea is welcome ![:slight_smile: :slight_smile:](/images/emoji/twitter/slight_smile.png?v=12)
Thanks in advance,
Esteban