ansible的入门级使用
author: headsen chen
date: 2018-08-02 11:46:35
1,ansible的安装
yum install epel-release
yum -y install ansible
# 另一种安装方法 yum -y install epel-release yum -y install python36 pip3 install ansible
mkdir /etc/ansible
vim /etc/ansible/ansible.cfg
[root@iZj6cf244ucbfj060qys19Z usr]# cat /etc/ansible/ansible.cfg
[defaults]
inventory = /tmp/hosts
[ssh_connection]
ssh_args = -o StrictHostKeyChecking=no
# 因为pip安装的ansible 没有配置文件,所以要手动指定
2,配置需要管理的客户端:
2.1 添加ssh的免秘钥登陆
ssh-keygen -t rsa # 使用ssh2.0版本的加密方式
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.200
2.2 配置本地的ansible的hosts文件: /etc/ansible/hosts
[group1]
192.168.0.200