- set_fact: mylist={{["l10","j82","b83","8jk","j83"]|list}}
- debug: var=mylist
- set_fact: max_n={{1|int}}
- debug: var=max_n
- debug: var=mylist[-{{max_n}}:]PLAY [deploy] ******************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [cleanup_s3_folder : set_fact] ********************************************
ok: [localhost]
TASK [cleanup_s3_folder : debug] ***********************************************
ok: [localhost] => {
"mylist": [
"l10",
"j82",
"b83",
"8jk",
"j83"
]
}
TASK [cleanup_s3_folder : set_fact] ********************************************
ok: [localhost]
TASK [cleanup_s3_folder : debug] ***********************************************
ok: [localhost] => {
"max_n": "1"
}
TASK [cleanup_s3_folder : debug] ***********************************************
ok: [localhost] => {
"mylist[-1:]": [
"j83"
]
}
PLAY RECAP *********************************************************************
localhost : ok=6 changed=0 unreachable=0 failed=0- set_fact: elements=mylist[-{{max_n}}:]
- debug: var=elements
- set_fact: elements2={{ mylist[-{{max_n}}:] }}
- debug: var=elements2PLAY [deploy] ******************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [cleanup_s3_folder : set_fact] ********************************************
ok: [localhost]
TASK [cleanup_s3_folder : debug] ***********************************************
ok: [localhost] => {
"mylist": [
"l10",
"j82",
"b83",
"8jk",
"j83"
]
}
TASK [cleanup_s3_folder : set_fact] ********************************************
ok: [localhost]
TASK [cleanup_s3_folder : debug] ***********************************************
ok: [localhost] => {
"max_n": "1"
}
TASK [cleanup_s3_folder : debug] ***********************************************
ok: [localhost] => {
"mylist[-1:]": [
"j83"
]
}
TASK [cleanup_s3_folder : set_fact] ********************************************
ok: [localhost]
TASK [cleanup_s3_folder : debug] ***********************************************
ok: [localhost] => {
"elements": "mylist[-1:]"
}
TASK [cleanup_s3_folder : set_fact] ********************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! template error while templating string: expected token ':', got '}'"}
PLAY RECAP *********************************************************************
localhost : ok=8 changed=0 unreachable=0 failed=1- set_fact: mylist={{["l10","j82","b83","8jk","j83"]}}
- debug: var=mylist
- set_fact: max_n={{1|int}}
- debug: var=max_n
- debug: var=mylist[-{{max_n}}:]
- set_fact: elements={{mylist[-max_n:]}}
- debug: var=elements[...]
TASK [debug] *******************************************************************
ok: [localhost] => {
"mylist[-1:]": [
"j83"
]
}
TASK [set_fact] ****************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! an unexpected type error occurred. Error was bad operand type for unary -: 'unicode'"}