more hosts [Web] 192.168.6.210:22 ansible_ssh_user=root ansible_ssh_pass=123 [Dubbo+Zookeeper] 192.168.6.212:22 ansible_ssh_user=root ansible_ssh_pass=123 [Mysql] 192.168.6.213:22 ansible_ssh_user=root ansible_ssh_pass=123
ansible Boss+Merchant+Web -m shell -a "hostname;ip a" 这里的Boss+Merchant+Web是我在hosts文件中定义的主机组 -m后面是接的模块 -a 就、后面是索要执行的命令 192.168.6.210 | success | rc=0 >> Pay-Boss+Merchant+Web 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:96:06:4e brd ff:ff:ff:ff:ff:ff inet 192.168.6.210/24 brd 192.168.6.255 scope global eth0
mkdir -p /etc/ansible/playbooks
touch boss.yml
more boss.yml
- hosts : Boss+Merchant+Web hosts 文件中的主机组
remote_user : root
tasks :
- name : update_boss 任务代号
shell : source /etc/profile;whoami;uptime;cat /etc/issue 模块+命令
# shell : echo "xxxxxxxxxxxxxxxxx"
ansible-playbook boss.yml
__________________________
< PLAY [Boss+Merchant+Web] >
--------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
_________________
< GATHERING FACTS >
-----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
ok: [192.168.6.210]
___________________
< TASK: update_boss >
-------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
changed: [192.168.6.210]
____________
< PLAY RECAP >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
192.168.6.210 : ok=2 changed=1 unreachable=0 failed=0
ansible Boss+Merchant+Web -m shell -a "hostname;ip a" -vvvv <192.168.6.210> ESTABLISH CONNECTION FOR USER: root <192.168.6.210> REMOTE_MODULE command hostname;ip a #USE_SHELL <192.168.6.210> EXEC sshpass -d6 ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o GSSAPIAuthentication=no -o PubkeyAuthentication=no -o ConnectTimeout=10 192.168.6.210 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1435819148.95-1730630738440 && echo $HOME/.ansible/tmp/ansible-tmp-1435819148.95-1730630738440' <192.168.6.210> PUT /tmp/tmpRfkD3R TO /root/.ansible/tmp/ansible-tmp-1435819148.95-1730630738440/command <192.168.6.210> EXEC sshpass -d6 ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o GSSAPIAuthentication=no -o PubkeyAuthentication=no -o ConnectTimeout=10 192.168.6.210 /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1435819148.95-1730630738440/command; rm -rf /root/.ansible/tmp/ansible-tmp-1435819148.95-1730630738440/ >/dev/null 2>&1' 192.168.6.210 | success | rc=0 >> Pay-Boss+Merchant+Web 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:96:06:4e brd ff:ff:ff:ff:ff:ff inet 192.168.6.210/24 brd 192.168.6.255 scope global eth0
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有