2016-06-10 112 views
0

是否有任何規定可以在Ansible劇本中動態聲明列表? 我想要的東西,像set_fact或註冊聲明動態列表?

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

回答

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