Here is the output of df -k from the target server:
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"
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 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/3b69b2c9-4f77-4c25-af9b-61547d05a688%40googlegroups.com.