Skip to content

Instantly share code, notes, and snippets.

@halberom
Created October 5, 2017 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halberom/859118d6da28493e17ad806e6b44e24c to your computer and use it in GitHub Desktop.
Save halberom/859118d6da28493e17ad806e6b44e24c to your computer and use it in GitHub Desktop.
ansible - type is not maintained, even with |int
TASK [Gathering Facts] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [debug] *******************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"ansible_memtotal_mb": 16384
}
TASK [command] *****************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]
TASK [debug] *******************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"mem": {
"changed": true,
"cmd": "echo 12345",
"delta": "0:00:00.007038",
"end": "2017-10-05 14:37:32.778004",
"failed": false,
"rc": 0,
"start": "2017-10-05 14:37:32.770966",
"stderr": "",
"stderr_lines": [],
"stdout": "12345",
"stdout_lines": [
"12345"
]
}
}
TASK [set_fact] ****************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [debug] *******************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"ansible_memtotal_mb": "12345"
}
---
- hosts: localhost
gather_facts: True
connection: local
tasks:
- debug:
var: ansible_memtotal_mb
- shell: echo 12345
register: mem
- debug:
var: mem
- set_fact:
ansible_memtotal_mb: "{{ mem.stdout|int }}"
- debug:
var: ansible_memtotal_mb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment