How to emulate Make semantics?

I need to execute a play, which uses file A to generate file B, if B does not exist or if B exists and is older than A.

How can I compare file dates in the when condition?

Cleanest solution would be to use two stat commands with "register:
file_A" and compare those variables (I guess file_A.stat.mtime might
work).

Johannes

Using stat in a local action with become does not seem to work. Shell seems to be the only module, which works with become in local actions. This works with become:

shell: |-
test -e {{ users_pw_hash }} -a {{ users_pw_hash }} -nt /etc/shadow ||
echo needs_update
register: etc_shadow_result
delegate_to: 127.0.0.1

become: true

Using stat in a local action with become does not seem to work.

Why not, what error are you getting?

  delegate_to: 127.0.0.1

I am not sure, but I thing I remember there is a difference between
"delegate_to: 127.0.0.1" and "delegate_to: localhost". If there is, I
do not know if this has an impact on your task...

Johannes

Maybe I am wrong and stat works, but what does not work is copy. The error is, that copy has no read permission to read /etc/shadow in a local action, although I use become.

Without the actual error (and your playbook) it is hard to guess...

Johannes