相关疑难解决方法(0)

在ansible中使用动态键名设置事实

我试图收缩几个类似代码的块,看起来像:

- ... multiple things is going here
  register: list_register
- name: Generating list
  set_fact: my_list="{{ list_register.results | map(attribute='ansible_facts.list_item') | list }}"

# the same code repeats...
Run Code Online (Sandbox Code Playgroud)

事实上,它们之间的唯一区别是我在这里使用不同的列表名称而不是 my_list

事实上我想这样做:

set_fact:
  "{{ some var }}" : "{{ some value }}"
Run Code Online (Sandbox Code Playgroud)

我遇到过这篇文章,但在这里找不到任何答案.

是可以这样做还是有任何解决方法?

variables dynamic ansible

20
推荐指数
3
解决办法
3万
查看次数

Ansible syntax best practice, YAML dictionary (key: value) or equal sign (key=value)?

I'm used to see Ansible examples as:

- file: path=/tmp/file state=touch
Run Code Online (Sandbox Code Playgroud)

but someone at work told me that I should be consistent using only YAML syntax like this:

- file:
    path: /tmp/file
    state: touch
Run Code Online (Sandbox Code Playgroud)

or,

- file: {path: /tmp/file, state:touch}
Run Code Online (Sandbox Code Playgroud)

Which one satisfies Ansible best practices?

yaml ansible

4
推荐指数
1
解决办法
3184
查看次数

标签 统计

ansible ×2

dynamic ×1

variables ×1

yaml ×1