如何在Amazon Linux EC2中安装Ansible?

use*_*955 1 amazon-web-services ansible

我选择这个亚马逊Linux:亚马逊Linux AMI 2017.09.1(HVM),SSD卷类型 - ami-1a033c7a.我使用命令安装了Ansible:

sudo pip install ansible, 
Run Code Online (Sandbox Code Playgroud)

它显示安装完成.当我运行ansible --version时,它显示:

ansible 2.4.1.0
  config file = None
  configured module search path = [u'/home/ec2-    
user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-
packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.12 (default, Nov  2 2017, 19:20:38) [GCC 4.8.5     
20150623 (Red Hat 4.8.5-11)]
Run Code Online (Sandbox Code Playgroud)

为什么config file = None?它不应该显示/etc/ansible/ansible.cfg?我没有看到/etc/ansible/hosts,甚至没有文件夹/etc/ansible.我安装正确,文件夹在哪里/etc/ansible

tec*_*raf 5

为什么config file = None

因为在运行时ansible --version没有找到配置文件.

不应该显示/etc/ansible/ansible.cfg

不,它应该显示ansible.cfg实际使用情况.

根据文档,Ansible尝试在以下位置找到配置文件:

  • ANSIBLE_CONFIG (环境变量)
  • ansible.cfg (在当前目录中)
  • .ansible.cfg (在主目录中)
  • /etc/ansible/ansible.cfg

ansible --version 将显示正在使用的路径的确切路径.

严格来说,最后一点并非总是如此,因为包管理器和虚拟环境管理器可能会导致/etc目录位于其他位置.

我安装得正确吗?

您在安装过程中未提及任何错误或警告,并ansible --version返回了正确的响应.

没有理由不相信它已正确安装.

文件夹在哪里/etc/ansible

它不存在于您的系统上.没有默认的库存文件,也没有安装包创建的配置文件.

创建一个.