如何单独为ansible模块的单个选项设置条件
How to set condition for single option of ansible module alone
是否可以为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 }}"
是否可以为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 }}"