简介
ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。
无客户端。
install-部署
:
1.dns resolve:配置host(主)
2.install ansible:
yum install -y epel-release
yum install -y ansible
列出所有文件:rpm -ql ansible
查看配置文件:rpm -qc ansible
看yum模块,了解其功能:ansible-doc -s yum
ssh-key(可选)
ansible基础:
1.定义主机清单:
vim /etc/ansible/hosts
添加主机域名
2.测试连通性:
ansible host1 -m ping -u root -k -o
-m:指定模块 -u:用户名 -k:密码 -o:简洁输出
3.know_hosts:
去掉(yes/no)的询问:
vim /etc/ssh/ssh_config
StrictHostKeyChecking no
Ad-Hoc-点对点模式
:
1.shell模块:ansible-doc shell
获取主机名:
ansible webserver -m shell -a 'hostname' -o
-f 2 指定线程数:
ansible webserver -m shell -a 'hostname' -o -f 2
部署apache:
ansible host2 -m shell -a 'yum -y in