是否有任何规定在Ansible剧本中动态声明列表? 我想要像set_fact或register
这样的东西- setfact: list_name= list_of(1, {{ n }}) # should return a list of 1 to n numbers
答案 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