ok: [10.240.30.249] => {
"win_pf": {
"automatic_managed_pagefiles": false,
"changed": false,
"failed": false,
"pagefiles": [
{
"caption": "c:\\ 'pagefile.sys'",
"description": "'pagefile.sys' @ c:\\",
"initial_size": 0,
"maximum_size": 0,
"name": "c:\\pagefile.sys"
},
{
"caption": "e:\\ 'pagefile.sys'",
"description": "'pagefile.sys' @ e:\\",
"initial_size": 3583,
"maximum_size": 9133,
"name": "e:\\pagefile.sys"
}
]
}
}
Below there are a number of ways I have tried:
---
- hosts: all
vars_files:
- winrms.yml
tasks:
- name: Saving facts into win_pf variable
win_pagefile:
register: win_pf
- name: Set number of disks from where to retrieve facts
set_fact:
listapag: "{{win_pf.pagefiles|length - 1}}"
Here is where I struggle:
Attempt 1:
- name: save m_size
set_fact:
list_ms: "{{win_pf.pagefiles[item].maximum_size}}"
with_sequence:
- start=0 end={{lista}}
Gives error:
TASK [save m_size] *********************************************************************************************
fatal: [10.240.30.249]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'list object' has no attribute u'0'\n\nThe error appears to be in '/home/gabriel/Conex_ansible/mainwin12.yml': line 19, column 9, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: save m_size\n ^ here\n"}
I tried to put item in {{}}, "" or both, but it gave similar error messages.
Attempt 2:
- name: save m_size
set_fact:
list_ms: "{{win_pf.pagefiles}} + [{{item}}]"
with_sequence:
- start=0 end={{lista}}
or
- name: save m_size
set_fact:
list_ms: "{{win_pf.pagefiles}}"
with_sequence:
- start=0 end={{lista}}
Give:
TASK [show m_size] *****************************************************************************************************************************************************************************
ok: [10.240.30.249] => {
"list_ms": [
{
"caption": "c:\\ 'pagefile.sys'",
"description": "'pagefile.sys' @ c:\\",
"initial_size": 0,
"maximum_size": 0,
"name": "c:\\pagefile.sys"
},
{
"caption": "e:\\ 'pagefile.sys'",
"description": "'pagefile.sys' @ e:\\",
"initial_size": 3583,
"maximum_size": 9133,
"name": "e:\\pagefile.sys"
},
1
]
}
But the form
- name: save m_size
set_fact:
list_ms: "{{win_pf.pagefiles}} + [{{item}}] + {{.maximum_size}}"
with_sequence:
- start=0 end={{lista}}
Gives the error:
fatal: [10.240.30.249]: FAILED! => {"msg": "template error while templating string: unexpected '.'. String: {{win_pf.pagefiles}} + [{{item}}] + {{.maximum_size}}"}
Attempt 3:
#I tried without .maximum_size first, as in Attempt 2
- name: Show maximum_size
debug:
msg: "{{item}}"
with_sequence:
- start=0 end={{listapag}} format=win_pf.pagefiles[%1x]
Just gives:
TASK [Show maximum_size] ***********************************************************************************************************************************************************************
ok: [10.240.30.249] => (item=win_pf.pagefiles[0]) => {
"msg": "win_pf.pagefiles[0]"
}
ok: [10.240.30.249] => (item=win_pf.pagefiles[1]) => {
"msg": "win_pf.pagefiles[1]"
}