Here is the output of df -k from the target server:
# df -k
> Filesystem 1K-blocks Used Available Use% Mounted on
> devtmpfs 1905280 0 1905280 0% /dev
> tmpfs 1922024 0 1922024 0% /dev/shm
> /dev/sda1 1942528 295616 1646912 16% /boot
> /dev/mapper/OMT-home 15718400 832120 14886280 6% /home
> /dev/mapper/OMT-tmp 6133760 33160 6100600 1% /tmp
> /dev/mapper/OMT-opt 10475520 4658356 5817164 45% /opt
> /dev/mapper/OMT-var 16734208 8803440 7930768 53% /var
> /dev/loop0 3704296 3704296 0 100% /mnt/media
> /dev/mapper/ihs_vg_yt 51466720 8790352 40038956 19% /ihs
> tmpfs 384408 0 384408 0% /run/user/0
I wish to get Use percentage for /ihs mount which is 19%.
Here is my playbook code:
- name: Generate JSON data
set_fact:
"{{ ansible_host }}_{{ item.mount }}: {{ (100 * ((item.size_total -
item.size_available) / item.size_available)) | round(1, 'common') }}"
when: item.mount == '/ihs'
with_items: '{{ ansible_mounts }}'
However, the output of my playbook run shows 28.5 % usage instead of 19%:
ok: [myhostone] => (item={u'block_used': 2857014, u'uuid':
u'3fa1ec29-aca5-476b-8041-6a7bc6b1efc2', u'size_total': 52701921280,
u'block_total': 12866680, u'mount': u'/ihs', u'block_available': 10009666,
u'size_available': 40999591936, u'fstype': u'ext4', u'inode_total': 3276800,
u'inode_available': 3264353, u'device': u'/dev/mapper/ihs_vg_yt',
u'inode_used': 12447, u'block_size': 4096, u'options':
u'rw,seclabel,relatime,stripe=256,data=ordered'}) => {
"ansible_facts": {
"_raw_params": "myhostone_/ihs: 28.5"
},
"ansible_loop_var": "item",
"changed": false,
"item": {
"block_available": 10009666,
"block_size": 4096,
"block_total": 12866680,
"block_used": 2857014,
"device": "/dev/mapper/ihs_vg_yt",
"fstype": "ext4",
"inode_available": 3264353,
"inode_total": 3276800,
"inode_used": 12447,
"mount": "/ihs",
"options": "rw,seclabel,relatime,stripe=256,data=ordered",
"size_available": 40999591936,
"size_total": 52701921280,
"uuid": "3fa1ec29-aca5-476b-8041-6a7bc6b1efc2"
Can you please tell me why is the percentage of the used disk shows 28.5%
with ansible while the df -k shows only 19% used? How can I get the correct
usage i.e 19% to s
--
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/55b43008-ae60-4c23-8199-299ab6f04528%40googlegroups.com.