Hello everyone, 

My registered vars are not working with my math equation using to_datetime 
filter it will work with the string "2019-04-01" but not with my var. 

PLAY [localhost] 
*********************************************************************************************************************************************

TASK [Gathering Facts] 
***************************************************************************************************************************************
ok: [localhost]

TASK [get the file] 
******************************************************************************************************************************************
changed: [localhost]

TASK [debug] 
*************************************************************************************************************************************************
ok: [localhost] => {
    "today": {
        "changed": true, 
        "cmd": "du -h --time /etc/ansible/ansible.cfg | grep -Eo 
'[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'", 
        "delta": "0:00:00.011270", 
        "end": "2019-05-01 09:27:11.662919", 
        "failed": false, 
        "rc": 0, 
        "start": "2019-05-01 09:27:11.651649", 
        "stderr": "", 
        "stderr_lines": [], 
        "stdout": "2019-04-30", 
        "stdout_lines": [
            "2019-04-30"
        ]
    }
}

TASK [get current date] 
**************************************************************************************************************************************
changed: [localhost]

TASK [debug] 
*************************************************************************************************************************************************
ok: [localhost] => {
    "current": {
        "changed": true, 
        "cmd": "date +%F", 
        "delta": "0:00:00.010083", 
        "end": "2019-05-01 09:27:12.031688", 
        "failed": false, 
        "rc": 0, 
        "start": "2019-05-01 09:27:12.021605", 
        "stderr": "", 
        "stderr_lines": [], 
        "stdout": "2019-05-01", 
        "stdout_lines": [
            "2019-05-01"
        ]
    }
}

TASK [debug] 
*************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "the field 'args' has an invalid 
value ({u'msg': u\"{{ ( 'current' | to_datetime('%Y-%m-%d') - 'today' | 
to_datetime('%Y-%m-%d') ).days }}\"}), and could not be converted to an 
dict.The error was: time data 'current' does not match format 
'%Y-%m-%d'\n\nThe error appears to have been in '/etc/ansible/wipstat.yml': 
line 20, column 5, but may\nbe elsewhere in the file depending on the exact 
syntax problem.\n\nThe offending line appears to be:\n\n\n  - debug:\n    ^ 
here\n"}

PLAY RECAP 
***************************************************************************************************************************************************
localhost                  : ok=5    changed=2    unreachable=0    failed=1 
  



-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/42fd8517-ba60-4f6d-948a-11260d326dc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to