Search code examples
ansibleapple-m1ansible-facts

What does Ansible return as `ansible_machine` and `ansible_architecture` under the Rosetta 2 emulation on M1 Mac


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?


Solution

  • 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