I'm trying to find the architecture of the machine by using Ansible facts.
We can gather information about the machine by running ansible -m setup <host-name>
command, as described in the documentation: Discovering variables: facts and magic variables — Ansible Documentation.
But it seems that the ansible_architecture
and ansible_machine
are the same values. I'm not sure the difference between them. The example on the above documentation shows the following two values which have the same values:
"ansible_architecture": "x86_64",
"ansible_machine": "x86_64",
On my M1 MacBook, the result is the same like this:
shuuji3@momo mac-dev-playbook
> ansible -m setup localhost | egrep '_architecture|_machine'
"ansible_architecture": "arm64",
"ansible_machine": "arm64",
Can we use these values interchangeably? Or can they have other values in another case?
According to the code (https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/platform.py) it's mostly always the same.
The value can differ on Solaris, AIX and OpenBSD.
I guess ansible_machine
is supposed to be the machine architecture (value of platform.machine()
https://docs.python.org/3/library/platform.html), while ansible_architecture
is more the OS architecture?