Upload var_files based on a value or ignore if not exist

22 views
Skip to first unread message

dudu.c...@gmail.com

unread,
Jul 18, 2021, 8:46:46 AM7/18/21
to Ansible Project

- hosts: server1
  vars_files:
    - main.yml
    - second.yml

 

Hi,

I have a a small playbook that is using variables based on a file.

Main.yml the file will always exist while second.yml might exist.

 

 

1.       Is it possible to configure the playbook to continue in case second.yml file does not existt?

2.       If I will add to the main. yam the following value

              Additional_file: yes

   Can I configure the playbook to load second.yml only in case Additional_file value = yes

 

Thanks 

Dick Visser

unread,
Jul 18, 2021, 3:37:02 PM7/18/21
to ansible...@googlegroups.com
Add a stat task first and only include the file if it's there 

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c5f132d2-745e-454a-8a62-bea207121f23n%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Reply all
Reply to author
Forward
0 new messages