what will be jinja template if I would like to create report only for / and /var partition? Or haw would I accomplish that?
Thanks Regards On Sunday, January 24, 2021 at 10:17:24 AM UTC+1 [email protected] wrote: > On 1/23/21 1:11 PM, j..r.. wrote: > > Thanks, this works great, can you explain me more what this jinja2 > template do especially: > > > > / ( 1024 | pow(3))) | round(2) } > > > > / ( 1024 | pow(3)) --> is this divide1024 three times? what is pow ? > > round(2) --> two decimal ? > > > > where can I get more jinja2 examples or tutorial? > > 1024 | pow(3) ... that is 1024³ = 1024 * 1024 * 1024 = 1 GB > > round ... rounds a number with optional decimals, so 10.445 | round(2) => > 10.45. > > So we divide the available size by 1 GB and round it up. The parentheses > are important > to process in the correct orders. > > I maintain a couple of filter examples at > > https://wiki.linuxia.de/library/stefan-hornburg-racke-ansible-provisioning-en#text-amuse-label-filters > > > Regards > Racke > > > > > Thanks > > On Friday, January 22, 2021 at 8:39:35 PM UTC+1 [email protected] > wrote: > > > > On 1/22/21 5:29 PM, j..r.. wrote: > > > Hi > > > > > > I would like to create report for free partition size under > "ansible_mounts" > > > > > > "ansible_mounts": [ > > > { > > > "block_available": 3911145, > > > "block_size": 4096, > > > "block_total": 4452864, > > > "block_used": 541719, > > > "device": "/dev/mapper/vg_root-lv_root", > > > "fstype": "xfs", > > > "inode_available": 8871855, > > > "inode_total": 8910848, > > > "inode_used": 38993, > > > * "mount": "/", * > > > "options": > "rw,seclabel,relatime,attr2,inode64,noquota", > > > *"size_available": 16020049920, * > > > "size_total": 18238930944, > > > "uuid": "e2968252-bcd8-45ac-9604-714aa932deb9" > > > }, > > > { > > > "block_available": 222270, > > > "block_size": 4096, > > > "block_total": 259584, > > > "block_used": 37314, > > > "device": "/dev/sda1", > > > "fstype": "xfs", > > > "inode_available": 523988, > > > "inode_total": 524288, > > > "inode_used": 300, > > > * "mount": "/boot", * > > > "options": > "rw,seclabel,relatime,attr2,inode64,noquota", > > > *"size_available": 910417920, * > > > "size_total": 1063256064, > > > "uuid": "bcce38b2-0c6c-44aa-99be-20e3553d23ee" > > > > > > > > > how can I get variables for /, /var /boot and other partitions and > create report like this in a file: > > > root: 10GB free > > > /boot: 800MB free > > > /var: 2GB free > > > > > > Thanks > > > > - copy: > > content: | > > {% for mt in ansible_mounts %} > > {{ mt.mount }}: {{ ( mt.size_available / ( 1024 | pow(3))) | round(2) }} > GB free > > {% endfor %} > > dest: > > /tmp/freespace.txt > > > > This creates a report in /tmp/freespace.txt with the GB values with two > decimal spaces. > > Distinguishing between GB and MB would be a bit more complicated. > > > > Regards > > Racke > > > > > > > > -- > > Ecommerce and Linux consulting + Perl and web application programming. > > Debian and Sympa administration. Provisioning with Ansible. > > > > -- > > 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] <mailto: > [email protected]>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/ansible-project/610532a8-4d79-4efc-850b-46b7d6de02dcn%40googlegroups.com > > > < > https://groups.google.com/d/msgid/ansible-project/610532a8-4d79-4efc-850b-46b7d6de02dcn%40googlegroups.com?utm_medium=email&utm_source=footer>. > > > > > -- > Ecommerce and Linux consulting + Perl and web application programming. > Debian and Sympa administration. Provisioning with Ansible. > > -- 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/2b0b0b31-8f27-4d92-857d-253b54b86fadn%40googlegroups.com.
