Ansible - 打印消息 - 调试:msg=“line1 {{ var2 }} line3 with var3 = {{ var3 }}"; [英] Ansible - Print message - debug: msg="line1 {{ var2 }} line3 with var3 = {{ var3 }}"

查看:37
本文介绍了Ansible - 打印消息 - 调试:msg=“line1 {{ var2 }} line3 with var3 = {{ var3 }}";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Ansible (1.9.4) 或 2.0.0 中

In Ansible (1.9.4) or 2.0.0

我运行了以下操作:

- debug: msg="line1 
 {{ var2 }} 
 line3 with var3 = {{ var3 }}"

$ cat 角色/setup_jenkins_slave/tasks/main.yml

- debug: msg="Installing swarm slave = {{ slave_name }} at {{ slaves_dir }}/{{ slave_name }}"
  tags:
    - koba

- debug: msg="1 == Slave properties = fsroot[ {{ slave_fsroot }} ], master[ {{ slave_master }} ], connectingToMasterAs[ {{ slave_user }} ], description[ {{ slave_desc }} ], No.Of.Executors[ {{ slave_execs }} ], LABELs[ {{ slave_labels }} ], mode[ {{ slave_mode }} ]"
  tags:
    - koba


- debug: msg="print(2 == Slave properties = 

fsroot[ {{ slave_fsroot }} ],
 master[ {{ slave_master }} ],
 connectingToMasterAs[ {{ slave_user }} ],
 description[ {{ slave_desc }} ],
 No.Of.Executors[ {{ slave_execs }} ],
 LABELs[ {{ slave_labels }} ],
 mode[ {{ slave_mode }} ])"
  tags:
    - koba

但这不是用新行打印变量(用于第三个调试操作)?

But this is not printing the variable with new lines (for the 3rd debug action)?

推荐答案

作为一种解决方法,我使用了 with_items 并且它对我有用.

As a workaround, I used with_items and it kind of worked for me.

- debug: msg="Installing swarm slave = {{ slave_name }} at {{ slaves_dir }}/{{ slave_name }}"

- debug: msg="Slave properties = {{ item.prop }} [ {{ item.value }} ]"
  with_items:
   - { prop: 'fsroot', value: "{{ slave_fsroot }}" }
   - { prop: 'master', value: "{{ slave_master }}" }
   - { prop: 'connectingToMasterAs', value: "{{ slave_user }}" }
   - { prop: 'description', value: "{{ slave_desc }}"  }
   - { prop: 'No.Of.Executors', value: "{{ slave_execs }}" }
   - { prop: 'LABELs', value: "{{ slave_labels }}" }
   - { prop: 'mode', value: "{{ slave_mode }}" }
  tags:
    - koba

这篇关于Ansible - 打印消息 - 调试:msg=“line1 {{ var2 }} line3 with var3 = {{ var3 }}";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆