ansible 的组件inventory

P44

Ansible 的默认的inventory的是一个静态的ini格式的文件/etc/ansible/hosts.

我们还可以通过ansible_hosts环境变脸指定或者运行ansible和ansible-playbook的时候用-i参数临时设置

ansible all -m ping -o  让输出内容一行显示

ansible 的主机清单默认是一个ini格式的静态文件hosts,但是它支持有多个inventory文件,我们可以更具业务分类。我们可以创建一个专门的inventory的目录

然后在该目录下根据业务不同创建文件

最后的时候我们去修改ansible.cfg文件,不再指定某个inventory文件,而是指向inventory目录

inventory =  /home/inventory/

[root@git inventory]# ansible my_host --list-hosts

 

模块

command ,shell   模块

copy     模块

ansible my_host -m copy -a 'src = /home/root.py dest=/home/wwwad/ owner=bao group=bao mode=644 backup=yes' -o

文件的变化是通过md5来判断的

ansible  my_host -m shell -a 'md5sum /home/wwwad/'

或者也可以直接查看下面有没有这个文件

ansible   my_host  -m shell -a 'ls /homt/wwwad' -o

yum   模块

service  模块

我们可以通过ansible-doc -s <模块名> 来查看一下,模块都是怎么用的,支持哪些参数

posted @ 2016-07-13 09:22  BigBao的博客  阅读(355)  评论(0编辑  收藏  举报