I have written this task that is supposed to go through a list of files and display the total amount of files located.
- name: "Total File Count"
shell: "kubectl exec pod/{{pod}} -- sh -c \"rclone size current-folder\""
register: fileCount
ignore_errors: True
- debug: var=fileCount
it printout the following:
"fileCount": {
"changed": true,
"cmd": "kubectl exec pod/files -- sh -c \"rclone size current-folder"",
"delta": "0:12:43.170671",
"end": "2021-09-29 18:04:47.206004",
"failed": false,
"rc": 0,
"start": "2021-09-29 17:52:04.035333",
"stderr": "",
"stderr_lines": [],
"stdout": "Total objects: 867936\nTotal size: 6.730 TBytes (7400217383962 Bytes)",
"stdout_lines": [
"Total objects: 867936",
"Total size: 6.730 TBytes (7400217383962 Bytes)"
]
}
}
I want to get the total number of files/objects from the json output.
I have tried the following, but prints out the key and value "msg": "Total objects: 867936"
debug: msg="{{fileCount.stdout_lines[0]}}"
Is there a command I can retrieve that 867936 number?