5

On a M1 MacBook, ansible_architecture and ansible_machine returns the same value that is arm64:

shuuji3@momo mac-dev-playbook
> ansible -m setup localhost | egrep '_architecture|_machine'
        "ansible_architecture": "arm64",
        "ansible_machine": "arm64",

What about under the Rosetta 2 emulation on M1 Mac?

U880D
  • 8,601
  • 6
  • 24
  • 40
shuuji3
  • 1,233
  • 13
  • 20

1 Answers1

3

When using the Rosetta 2 emulation (Intel mode) on the M1 Mac, Ansible returns x86_64 values like the previous intel Mac:

shuuji3@momo ~ % ansible -m setup localhost | egrep '_architecture|_machine'
        "ansible_architecture": "arm64",
        "ansible_machine": "arm64",

# Run the shell on the Intel mode
shuuji3@momo ~ % env /usr/bin/arch -x86_64 /bin/zsh --login

shuuji3@momo ~ % ansible -m setup localhost | egrep '_architecture|_machine'
        "ansible_architecture": "x86_64",
        "ansible_machine": "x86_64",
        "ansible_userspace_architecture": "x86_64",

Note that Ansible adds the ansible_userspace_architecture fact.

References

shuuji3
  • 1,233
  • 13
  • 20
  • 3
    As you will see in the [source code](https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/platform.py), ansible basically returns the result of `platform.machine()` of the `platform` python module in both variables except if you are running on AIX or Solaris. – Zeitounator Mar 28 '21 at 09:30