Creating directory based on dates

Look up “register” in the docs.

also you can use the file module to create it, no need to shell

I thought is not possible to use the file module because I’m creating the directory based on the current timestamp.

I’m currently creating it like this:

action: shell mkdir -p /to/path/date +%F.%H:%M:%S

How would I use the file module?

How would I use the file module?

I think something like this could do the trick:

          tasks:
          - action: shell date '+%F.%H:%M:%S'
            register: mydate
          - action: file dest=/tmp/{{ mydate.stdout }} state=directory

Note how the 'register' keyword as mentioned by Michael "picks" up the
stdout of the command. Later, the `file' action creates the directory
proper, as Brian pointed out.

BTW, the facts obtained by Ansible via `setup' contain the current
date/time in a variety of formats; you may want to look at those.

        -JP

Thanks. Will take a look.

I was also looking into the var variables that can be passed by the command line too.