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

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

问题描述

在Ansible(1.9.4)或2.0.0

In Ansible (1.9.4) or 2.0.0

我执行了以下操作:

- debug: msg="line1 \n {{ var2 }} \n 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 = \n\nfsroot[ {{ slave_fsroot }} ],\n master[ {{ slave_master }} ],\n connectingToMasterAs[ {{ slave_user }} ],\n description[ {{ slave_desc }} ],\n No.Of.Executors[ {{ slave_execs }} ],\n LABELs[ {{ slave_labels }} ],\n 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 \ n {{var2}} \ n line3 with var3 = {{var3}}"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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