gpt4 book ai didi

conditional - 如何单独为ansible模块的单个选项设置条件

转载 作者:行者123 更新时间:2023-12-04 02:52:12 24 4
gpt4 key购买 nike

是否可以为 ansible 模块的单个选项设置条件。

   Using set_fact we can set condition aand use that variable in the ansible module. Alternatively is there any other option to set the condition using if loop in jinja or something like that.

例如:
 - name: Simple PUT operation
s3:
bucket: mybucket
object: /my/desired/key.txt
src: /usr/local/myfile.txt
mode: put

我要 添加 s3_url 选项 如果它满足条件 sample_var= myapp.If 它不满足它就不必添加 s3_url
   - name: Simple PUT operation
s3:
bucket: mybucket
object: /my/desired/key.txt
src: /usr/local/myfile.txt
mode: put
s3_url: "s3my url"------if it satisfies sample_var=myapp

当它满足我的条件时,我如何在这里使用 jinja 需要将此选项添加到 ansible 模块?

提前致谢..

最佳答案

您可能想了解 omitting parameters :

- name: Simple PUT operation
s3:
bucket: mybucket
object: /my/desired/key.txt
src: /usr/local/myfile.txt
mode: put
s3_url: "{{ 's3my_url' if sample_var == 'myapp' else omit }}"

关于conditional - 如何单独为ansible模块的单个选项设置条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41311041/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com