【问题标题】:Ansible and debugging scriptAnsible 和调试脚本
【发布时间】:2018-02-04 23:00:39
【问题描述】:

我想在本地运行一个 python 脚本,并打印(调试)输出。在 ansible 之外运行脚本给了我这个:

$ python ../scripts/test-winrm-v5.py 
i-746726df

这是我的剧本:

$ cat test4.yml 
- name: list instance ids
  hosts: all
  gather_facts: false
  tasks:
    local_action: shell python ../scripts/test-winrm-v5.sh
    register: result
    debug: msg="{{ result }}"

这是我运行 playbook 时得到的结果:

$ ansible-playbook -i ../inventory/phani test4.yml

PLAY [list instance ids] ****************************************************** 

PLAY RECAP ******************************************************************** 

为什么不显示脚本的输出?

【问题讨论】:

  • 更正:将剧本中的 .sh 更改为 .py,但没有任何区别。

标签: ansible


【解决方案1】:

看起来我在调试行上有一些控制字符。我再次输入了该行,现在它正在工作。这是剧本:

- name: list instance ids
  hosts: windows
  tasks:
  - debug: msg="System {{ inventory_hostname }}"
  - local_action: shell python ../scripts/test-winrm-v5.py
    register: result
  - debug: msg="Result of running script is {{ result.stdout }}"

【讨论】:

    猜你喜欢
    • 2020-01-24
    • 2017-01-24
    • 1970-01-01
    • 2016-12-10
    • 2020-02-11
    • 2012-01-17
    • 2021-01-24
    • 1970-01-01
    • 2022-11-18
    相关资源
    最近更新 更多