Yes, you should be able to use set_fact to initialize it to some other
value and test that in your when: statement.

On Tue, Oct 21, 2014 at 9:07 AM, Torsten Reinhard <[email protected]>
wrote:

> No there are no other modules using that variable. But The question still
> is: Can i clear The variable somehow?
>
> For now i removed The stat task and when condition -and added a simple
> Shell if statement instead to the mv operation.
>
> Torsten
> ------------------------------
> Von: James Cammarata <[email protected]>
> Gesendet: ‎20.‎10.‎2014 20:24
> An: [email protected]
> Betreff: Re: [ansible-project] unregister a variable ?
>
> Hi Torsten,
>
> Since there is no `when` conditional on the stat task, it should be re-run
> and overwrite the registered variable, so I'm a bit unclear why this would
> be showing the behavior you're seeing. Is this the complete list of tasks,
> and/or there any other tasks that also use that registered variable name?
>
>
> On Mon, Oct 20, 2014 at 5:05 AM, Torsten Reinhard <[email protected]
> > wrote:
>
>> Hi all,
>>
>> is it possible to "clear" or "unregister" a variable ?
>>
>> I have this situation:
>>
>> deploy.yml
>> - include "deploy-apache.yml"
>> - include "deploy-tomcat.yml"
>>
>> deploy-apache and deploy-tomcat both have a dependency to a
>> "deliver-artifact" role, and both run on the same server(s).
>> The {{installdir}} is either opt/web/install/apache or
>> /opt/web/install/tomcat (read from included *.yml files)
>>
>> The following task is implemented in this "shared" "deliver-artifact"
>> role:
>>
>> ...
>> # for each run, backup the old installdir and install into an empty
>> directory
>> - name: stat installdir
>>   stat: path={{installdir}}
>>   register: installdir_stat
>>
>> - name: get the current time for a timestamp
>>   command: date +%Y%m%d-%H%M%S
>>   register: time
>>
>> - name: backup installdir
>>   command: mv {{installdir}} {{installdir}}_{{time.stdout}}
>>   when: installdir_stat.stat.exists
>> ...
>>
>> It seems that the "installdir_stat.stat.exists" is true from the
>> "deploy-apache.yml" run - where {{installdir}} was /opt/web/install/apache
>>
>> For "deploy-tomcat.yml" run the task now tries to mv a directory that
>> doesnt exists - but the variable installdir_stat.stat.exists is true !
>>
>> => Can I clear the register ? Or what´s the solution here?
>>
>> Thanx, Torsten
>>
>>  --
>> 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/43f4a80b-d931-4dbc-92c2-ce82b11a89ef%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/43f4a80b-d931-4dbc-92c2-ce82b11a89ef%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/CAMFyvFgwTH%3Do%2B%2Bh2EjRSxTrxExTeB4b%2BtVMeER%3Dq6kV-8jSVbg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAMFyvFgwTH%3Do%2B%2Bh2EjRSxTrxExTeB4b%2BtVMeER%3Dq6kV-8jSVbg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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/54468501.04b6700a.7869.fffffbeeSMTPIN_ADDED_MISSING%40gmr-mx.google.com
> <https://groups.google.com/d/msgid/ansible-project/54468501.04b6700a.7869.fffffbeeSMTPIN_ADDED_MISSING%40gmr-mx.google.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMFyvFgsfZ8KLX%2B1Pos2nHB5yT0Q89CSmm5svMxan-xpCyH4PQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to