小编Vee*_*anu的帖子

Ansible 显示实时 shell 标准输出

我想查看实时shell标准输出,而不是register在变量中输入,然后在完成后显示。

示例剧本 - test.yml

- name: Testing RUN Shell Command
  hosts: localhost
  connection: local

  tasks:
  - name: Runnig Update
    shell: apt update
Run Code Online (Sandbox Code Playgroud)

默认输出

$ ansible-playbook  test.yml 

PLAY [Testing RUN Shell Command] ******************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************
ok: [localhost]

TASK [Runnig Update] ******************************************************************************************************************
changed: [localhost]

PLAY RECAP ****************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0   

Run Code Online (Sandbox Code Playgroud)

但是我想看看当我们运行apt update终端时它在做什么

$ sudo apt update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable Release                                                                            
Hit:3 http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu bionic InRelease                                                              
Get:4 http://security.ubuntu.com/ubuntu bionic-security …
Run Code Online (Sandbox Code Playgroud)

stdout ansible

5
推荐指数
1
解决办法
8658
查看次数

标签 统计

ansible ×1

stdout ×1