【问题标题】:Ansible loops - Printing what the command is doingAnsible 循环 - 打印命令正在做什么
【发布时间】:2023-02-06 16:36:28
【问题描述】:

下面是剧本中的 sn-p。在为每个循环项运行命令后,如何打印消息。就像是。

image.pyc is now running for item1
image.pyc is now running for item2

... 等等

    - name: Image Server(s)
      command: python3 image.pyc {{item}} "{{systemVersion}}"
      register: async_out
      async: 7200
      poll: 0
      with_items: "{{hostinfo_input.hosts}}"

【问题讨论】:

    标签: ansible


    【解决方案1】:

    查看Ansibledebug模块的文档:https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html

    例如。

    - name: Prints two lines of messages, but only if there is an environment value set
      ansible.builtin.debug:
        msg:
        - "Provisioning based on YOUR_KEY which is: {{ lookup('ansible.builtin.env', 'YOUR_KEY') }}"
        - "These servers were built using the password of '{{ password_used }}'. Please retain this for later use."
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多