【问题标题】:How to concatinate string with star character Ansible?如何将字符串与星号 Ansible 连接?
【发布时间】:2020-01-28 12:13:51
【问题描述】:

我有一个存储在 files_path 变量中的路径列表。 这是一项任务,我试图连接变量中的路径并使用连接添加路径的其余部分。

- name: Changing supervisor files path
  replace:
    path: /etc/supervisor/supervisord.conf
    regexp: 'files(.*)'
    replace: 'files = /etc/supervisor/conf.d/*.conf {{ supervisor_files_path | join(' ')/shared/supervisor/*.conf }}
  notify: restart supervisor
  when: files_path is defined

我得到的错误:

fatal: [127.0.0.1]: FAILED! => {"msg": "template error while templating string: unexpected '*'. String: files = /etc/supervisor/conf.d/*.conf {{ files_path | join(' ')/shared/supervisor/*.conf }}"}

问题在于代码中的第二颗星:/shared/supervisor/*.conf

我试图使用\*[*] 逃脱,但得到了同样的错误。

我应该如何改变这个?

【问题讨论】:

    标签: regex join ansible supervisord


    【解决方案1】:

    我会尝试在它周围加上{{ }},这样它就变成了{{ /etc/supervisor/conf.d/*.conf }}。也不要忘记将" " 放在行的开头和结尾。

    【讨论】:

      猜你喜欢
      • 2016-01-28
      • 2011-04-18
      • 1970-01-01
      • 1970-01-01
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-31
      相关资源
      最近更新 更多