playbook 剧本

1.shell模块  ansible webserver -m shell -a 'hostname' -o

                    ansible webserver -m shell -a 'hostname' -o -f 2

                    ansible host2 -m shell -a 'yum -y install httpd' -o

                    ansible host3 -m shell -a 'uptime' -o

2.复制模块

ansible webserver -m copy -a 'src=/etc/hosts dest=/tmp/2.txt owner=root group=bin mode=777'

ansible webserver -m copy -a 'src=/etc/hosts dest=/tmp/2.txt owner=root group=bin mode=777 backup=yes'

3.用户模块

ansible webserver -m user -a 'name=qianfeng state=present'

echo '512050951' | openssl passwd -1 -stdin $1$XVzsJMDr$5wI4oUaQ.emxap6s.N272.

生成加密密钥值

ansible webserver -m user -a 'name=qianfeng password="$1$XVzsJMDr$5wI4oUaQ.emxap6s.N272."'

ansible webserver -m user -a 'name=qianfeng shell=/sbin/nologin append=yes' 追加

ansible webserver -m user -a 'name=qianfeng state=absent' 删除

4.软件包管理

ansible host1 -m yum -a 'name="*" state=latest' 安装所有的软件包

ansible host2 -m yum -a 'name="httpd" state=latest'

5.服务模块

ansible host2 -m service -a 'name=httpd state=started'

ansible host2 -m service -a 'name=httpd state=started enabled=yes'

ansible host2 -m service -a 'name=httpd state=stopped'

ansible host2 -m service -a 'name=httpd state=restarted'

ansible host2 -m service -a 'name=httpd state=started enabled=no'

6.文件模块

ansible host1 -m file -a 'path=/tmp/88.txt mode=777 state=touch'

ansible host1 -m file -a 'path=/tmp/99 mode=777 state=directory'

7.收集模块

ansible host3 -m setup 查询所有信息

ansible host3 -m setup -a 'filter=ansible_all_ipv4_addresses'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值