将字符串命令拆分为多行

nrz53378

让我们考虑以下命令:

command: "curl http://{{ my_server }}:1234/xaw?x={{ x }}&y={{ y }}&z={{ z }}""

如何将其写成多行,例如:

command:
  "curl http://{{ my_server }}:1234/xaw?
  x={{ x }}&
  y={{ y }}&
  z={{ z }}"
iptizer

您可以在行尾附加一个“\”:

- hosts: all
  tasks:
    - set_fact:
        my_server: "x"
        ax: "x"
        ay: "y"
        az: "z"
    - set_fact:
        yourCommand: "curl http://{{ my_server }}:\
        1234/xaw?x={{ ax }}\
        &y={{ ay }}\
        &z={{ az }}"
    - debug: 
        var: yourCommand

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章