标签:perm sel .com mod php-mysql defaults debug 字符串 ftp
无服务、无agent、采用ssh管理远程主机、多线程远程管理
1、新建一个目录
[root@room8pc16 nsd1709]# mkdir ansi
[root@room8pc16 nsd1709]# cd ansi
2、创建配置文件
[root@room8pc16 ansi]# vim ansible.cfg
[defaults]
inventory = inventory # 定义被管理主机到哪个文件中查找
remote_user = root # ssh到远程主机的用户
3、创建主机清单
[root@room8pc16 ansi]# vim inventory
[dbservers] # 定义主机组名
192.168.4.1 # 定义组成员主机
[webservers]
192.168.4.2
192.168.4.3
4、列出主机命令,虽然all没有定义,但是它是保留字,表示所有主机
[root@room8pc16 ansi]# ansible all --list-hosts
[root@room8pc16 ansi]# ansible dbservers --list-hosts
[root@room8pc16 ansi]# ansible webservers --list-hosts
5、测试到远程主机的通信
[root@room8pc16 ansi]# ansible all -m ping -k
6、在所有的主机上执行任意命令
[root@room8pc16 ansi]# ansible all -a ‘touch /opt/abc.txt‘ -k
以下命令是远程开机命令,与ansible无关
[root@room8pc16 ansi]# ether-wake -i enp2s0 xx:xx:xx:xx:xx:xx
name: configure vsftpd
hosts: all
tasks:
name: install vsftpd
yum:
name: vsftpd
state: latest
标签:perm sel .com mod php-mysql defaults debug 字符串 ftp
原文地址:http://blog.51cto.com/13434975/2068234