在ansible中声明动态列表?

时间:2016-06-10 18:17:09

标签: ansible ansible-playbook ansible-2.x

是否有任何规定在Ansible剧本中动态声明列表? 我想要像set_fact或register

这样的东西
- setfact: list_name= list_of(1, {{ n }}) # should return a list of 1 to n numbers 

1 个答案:

答案 0 :(得分:0)

以上可以实现:

- name: "Registering list varibles count "
  shell: python -c "print [x for x in range( 1, {{ server_var['count'] }} )]"
  register: list_name
- name: "debug statement to checkout the output"
  debug:
    msg: "{{ list_name.stdout }}"
# the list_name.stdout can also be used as jinja list variable