Hello,

I use some fact variables in my playbook in my tasks code (I've been using 
roles). I know that they don't need to be defined in the vars part, but is 
it a good practice to do so?

I have something like:

hostname: "{{ ansible_hostname }}"
> year: "{{ ansible_date_time.year }}"
> month: "{{ ansible_date_time.month }}"
> day: "{{ ansible_date_time.day }}"
> date: "{{ ansible_date_time.date }}"
> dest_file: "/tlp_adm/recoverydata/linux/{{ year }}/{{ month }}/{{ day 
> }}/{{ hostname }}.recoverydata.{{ date }}"
>

 in vars.

while the tasks code does something like this:

- name: Ensure destination path exists
>   file: path=/tlp_adm/recoverydata/linux/{{ year }}/{{ month }}/{{ day }} 
> state=directory
> - name: Output recovery log
>   local_action: template src=tlp_recoveryData.j2 dest="{{ dest_file }}"
>

I think that defining variables like this on top makes the code a little 
bit more readable, but I don't know if it makes sense to put everything in 
variables, like for example the source path or the facts (?).

What is your opinion? What are the best practices on this?


-- 
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/30395053-a693-4dff-8909-7183dfeffa11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to