【小提示】指定Python版本以消除运行Ansible时显示的警告

我正在编写 Ansible 手册来设置 Mac。当我运行它时,我收到警告,所以我会调查它并分享我解决的问题。

你好。我是Amazon Web Services团队的Sureing。

最近,我的 Mac 键盘无法正常工作,我把它修好了。在此期间,将提供替换设备,但设置为默认设置。您可以手动更改设置,但让我们使用 Ansible 来设置它!所以我决定写一本剧本。

当我运行我编写的剧本时,我收到以下警告:忽略它不会立即导致问题,但它很恶心,因此本文的目的是解决它。

[WARNING]: Platform linux on host 127.0.0.1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.8/reference_appendices/interpreter_discovery.html for more information.

先说结论
可以通过将以下设置添加到 Ansible 配置文件 (ansible.cfg) 来解决此问题。

vi /etc/ansible/ansible.cfg
[defaults]
interpreter_python=/usr/bin/python3

顺便说一下,Ansible 的版本是 2.8.8。

$ ansible --version
ansible 2.8.8
posted @ 2024-04-19 10:24  Sureing  阅读(67)  评论(0编辑  收藏  举报