extending a module, try/finally

Hello,

is there a way to invoke other modules? Basically, I want to do this:

tmp = template(password_script, mode=0700)
try:
synchronize(args, SUDO_ASKPASS=tmp)
finally:
os.remove(tmp)

Is this possible or do I have to copy-n-paste code here?

Regards
Mirko

That’s a feature expected in the 2.0 release.

Yes, this will be easier to do in 2.0. However, to do it today you can set “ignore_errors: yes” on the task while registering the result, and then have a follow-up task which runs when the previous result failed.

For example:

  • command: /bin/false
    ignore_errors: yes
    register: failed_result

  • command: /do/something/else
    when: failed_result|failed

Hope that helps!