Make use of "if" condition for your disk 2 in Jinja. On Thu, 14 Jan, 2021, 1:03 pm Dick Visser, <[email protected]> wrote:
> And the question is...? > > On Thu, 14 Jan 2021 at 03:15, 'Aristotle D Aguirre' via Ansible Project < > [email protected]> wrote: > >> ******************************* >> --- >> - hosts: all >> name: >> become: yes >> tasks: >> >> - name: Template >> template: >> src: disk.j2 >> dest: /tmp/mydisk >> ignore_error: True >> ******************************* >> Jinja Template >> ARCH={{ ansible_architecture }} >> alias={{ ansible_default_ipv4.alias }} >> DISK1={{ ansible_devices.sda.partitions.sda1.size }} >> DISK2={{ ansible_devices.sdb.partitions.sdb1.size }} >> >> Expected Output: If Disk1 and Disk 2 is available >> ############### >> cat /tmp/mydisk >> ARCH=x86_64 >> alias=ens192 >> DISK1=1.00 GB >> DISK2=762.00 MB >> ############### >> >> Expected Output if Disk2 is not available. >> ############### >> cat /tmp/mydisk >> ARCH=x86_64 >> alias=ens192 >> DISK1=1.00 GB >> DISK2=Not Defined >> ############### >> >> -- >> 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 view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/b7ffe3b5-d40c-4603-87aa-26c983ae015dn%40googlegroups.com >> <https://groups.google.com/d/msgid/ansible-project/b7ffe3b5-d40c-4603-87aa-26c983ae015dn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > Sent from a mobile device - please excuse the brevity, spelling and > punctuation. > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAL8fbwPR%3DdW-PZ7XnMXZWcS%3DWfiEmCrDGcJPHLnROsnmZN3zyg%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAL8fbwPR%3DdW-PZ7XnMXZWcS%3DWfiEmCrDGcJPHLnROsnmZN3zyg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAAAufFoGGJG0JqUPiGDiLhaaJxo_puV11u8UxkFoYr-mEg7X0g%40mail.gmail.com.
