Loading

Ansible的安装与配置

1. 安装Ansible

1.1 yum安装

# 从epel源安装
yum -y install epel-release
yum -y install  ansible
yum -y install ansible-collection-community-general

1.2 pip安装

# 需要提前安装Python3环境
python3 -m pip install --user ansible

2. Ansible的配置

Ansible 配置文件可以存放在不同的位置,但只有一个可用。在下列列表中,ansible从上往下依次检查,检查到哪个可用就用哪个。

  • ANSIBLE_CONFIG 环境变量,可以定义配置文件的位置
  • ./ansible.cfg 存在于当前工作目录
  • ~/.ansible.cfg 存在与当前用户家目录
  • /etc/ansible/ansible.cfg
# 生成配置文件,yum安装的配置文件默认位置为/etc/ansible/ansible.cfg
ansible-config init --disabled > ansible.cfg
# 包含插件的配置文件    
ansible-config init --disabled -t all > ansible.cfg  
posted @ 2017-11-05 16:58  头痛不头痛  阅读(352)  评论(0编辑  收藏  举报