关于#ansible#在同一台主机上执行多遍脚本

ansible-playbook在同一台主机上执行多遍脚本

hosts主机清单中有两台主机,执行脚本时却在一台主机中执行两边脚本,在安装openssh-clients前是正常的,安装后出现上述情况,
由于要使用ansible的跳板机功能所以要安装openssh-clients。

hosts清单

111.111.111.111  ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass="xxx"
222.222.222.222 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass="xxx"

yml文件

- hosts: all
  remote_user: root
  tasks:
    - name: deploy
      script: deploy.sh
      register: result
    - name: Get detail info
      debug: msg="{{result.stdout_lines | join('\n')}}"

deploy.sh

#!/bin/sh
ifconfig 

执行结果

ok: [111.111.111.111] => {}

MSG:

        inet 111.111.111.111  
ok: [222.222.222.222] => {}

MSG:

        inet 111.111.111.111  

img

操作环境、软件版本等信息

系统:centso7
ansible:2.9.21
openssh :OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017

预期结果

每个主机执行一遍