首页 > 解决方案 > 在 M1 Mac 上的 Rosetta 2 仿真下,Ansible 以“ansible_machine”和“ansible_architecture”的形式返回什么

问题描述

在 M1 MacBook 上,ansible_architecture返回ansible_machine相同的值arm64

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

在 M1 Mac 上的 Rosetta 2 仿真下呢?

标签: ansibleapple-m1

解决方案


在 M1 Mac 上使用 Rosetta 2 仿真(Intel 模式)时,Ansible 返回x86_64的值类似于之前的 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",

请注意,Ansible 添加了ansible_userspace_architecture事实。

参考


推荐阅读