ansible命令的不完全摘要

配置路径/etc/ansible/

ansible.cfg :
log_path = /var/log/ansible.log # 建议开启日志
host_key_checking = False # 首次连接ssh无需手动输入 yes
hosts :

 ###指定范围 
10.0.0.[1:92]
ctp[a:f].test.com :7891

ansible-doc

######显示模块的帮助文档
ansible-doc  ping    #查看ping模块信息
ansible-doc ping -s    #查看ping模块信息(精简)

ansible

ansible <分组> [-m 模块] [ -a 模块参数]

###插播生成密钥对############
  ####单台
  ssh-keygen 
  ssh-copy-id 172.16.0.2
  
  ####多台批量
  ssh-keygen -f /root/.ssh/id_rsa -P ' '
  NET=192.168.100
  export SSHPASS=JIANG123
  for IP in {1..100};do
       sshpass -e ssh-copy-id $NET.$IP
  done

###查看某分组中的主机
[root@test ~]# ansible test --list-hosts
  hosts (1):
    172.16.0.8
[root@test ~]# ansible '*' --list-hosts
  hosts (1):
    172.16.0.8
####支持 与:& 或: 非! 以及正则表达式 用~开头
####执行过程可以使用-vvvv来查看

ansible-pull

推送ansible命令到远程

ansible-playbook

执行编号的playbook任务(yaml格式)

ansible-playbook helloworld.yaml 

ansible-vault

通过加解密实现对敏感yaml文件的保存

ansible-vault  helloworld.yaml
ansible-vault decrypt helloworld.yaml 
## 除此以外还有 view edit rekey create可以使用

ansible-console

[root@test ~]# ansible-console
Welcome to the ansible console.
Type help or ? to list commands.

root@all (1)[f:5]$ list
172.16.0.8
root@all (1)[f:5]$ cd test
root@test (1)[f:5]$ list
172.16.0.8
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值