Seems like this request could be grouped with the easy conditionals
stuff earmarked for 0.9; there could be when_file_exists and
when_file_not_exists conditions (or possibly better names like
creates) which would translate to:
Would I need to break this up to register the boolean, or could I put it
into the loop somehow?
Are you wanting to extract each tarball depending on whether or not that
particular one has changed, or do you want to run it if any of them change?
The former would likely be best implemented using a task include file
containing your get_url and unpacking command, and using with_items on the
include, e.g.
tasks:
- include: fetch-extract.yml url=$s3/$item name=$item
with_items:
- $tarball1
- $tarball2
and in fetch-extract.yml:
- name: fetch file
action: get_url url=$url dest=/opt/$name
register: fetch_result
- name: extract file
action: command tar -xzf /opt/$name
when_boolean: ${fetch_result.changed}
The latter would be easier, just add register: foo and use ${foo.changed}.
It will be True if any of the items was changed, and False if they were all
unchanged.
Are you wanting to extract each tarball depending on whether or not that
particular one has changed, or do you want to run it if any of them change?
The former.
The former would likely be best implemented using a task include file
containing your get_url and unpacking command, and using with_items on the
include, e.g.
tasks:
- include: fetch-extract.yml url=$s3/$item name=$item
with_items:
- $tarball1
- $tarball2
and in fetch-extract.yml:
- name: fetch file
action: get_url url=$url dest=/opt/$name
register: fetch_result
- name: extract file
action: command tar -xzf /opt/$name
when_boolean: ${fetch_result.changed}
OK, I'll give that a go - thanks for the heads up.
BTW how does the register action populate the ${fetch_result.changed} flag? Does the get_url command save a checksum of the last downloaded file?