ansible 运维技巧记录
1.指定配置文件
ansible -i /etc/ansible/hosts KD1 -m shell -a ‘uptime‘
ansible -i /root/shiye/hkhost ten -m shell -a 'uptime'
ansible -i /root/shiye/hkhost ten -m shell -a 'uptime'|awk '{print $1,$3}'|xargs
2.非22端口
如果有主机的SSH端口不是标准的22端口,可在主机名之后加上端口号,用冒号分隔.
192.168.10.20:1092
3.在ip数据末尾加上ssh端口
sed "s/[0-9]$/&:37878/g" hosts
4.检测语法
ansible-playbook ldgame_StopPay.yaml --syntax-check
5.匹配判断
echo "Q-hk-aoa-static2"|grep -w "Q-hk-aoa-static[1-2]"
6.发布系统调试
ansible-playbook /home/fabu/ansible_playbook/fabu.yml --extra-vars "project_name=omweb project_pack=/home/ftp/fabu01/tomcat_omweb.zip project_port=9055 backup_time=2016-11-29 10:00:00" -f 1 -v