Am 12.11.2017 um 15:23 schrieb Kai Stian Olstad:
>> Here is a not working example playbook:
>> ---
>> - hosts: localhost
>> connection: local
>
> Instead of using hosts: localhost, you could use the inventory hostname or
> the group.
> Since you have connection: local it will run on the controller host.
>
> The benefits is that if you use "register: some_variable" then the variable
> will be registered on the host and not localhost.
>
>> tasks:
>> - name: snapshot operation
>> vmware_guest_snapshot:
>> hostname: "{{ vc }}"
>> username: "{{ vc_user }}"
>> password: "{{ vc_passwd }}"
>> datacenter: "{{ vc_datacenter }}"
>> folder: /mydatacenter/vm/"{{ item.folder }}"/
>> name: "{{ item.vm }}"
>> state: absent
>> snapshot_name: snap1
>> description: "Fuegen Sie hier Ihre Beschreibung ein"
>> validate_certs: false
>> delegate_to: localhost
>> with_item:
>> - "{{ nested_list }}"
>
> Then you could use "register: status_snapshot" on this task, and check it's
> status in the next play.
Ok, I'll try that. Since one of the common return values of ansible
modules is
[failed](http://docs.ansible.com/ansible/latest/common_return_values.html#id5)
I would like to use it in my play. But how could I use it? Do I simply
have to use "register: failed" to check it in the next play?
>> - hosts: staging
>> tasks:
>> - name: run yum -y update
>> yum:
>> name: "*"
>> state: latest
>
> Variables in one play is available in subsequent play in the same playbook.
> So you can then use the variable status_snapshot to decide what to do in this
> play.
Could you give an example how to evaluate the variable, please?
Best regards,
Joerg
--
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/3c38eb32-72c8-b232-96ef-99c72ba7b410%40gmail.com.
For more options, visit https://groups.google.com/d/optout.