【发布时间】:2014-08-21 05:23:01
【问题描述】:
我需要:
vars_prompt:
- name: loopvar
prompt: Enter the loop variable
private: False
default: 16
- hosts: epcs
serial:1
gather_facts: no
tasks:
- name: Do some mathematics divide multiply
#insert logic here
register: my_content # save logic in register
with_sequence: count={{loopvar}} #I need a loop sequence here
when: inventory_hostname == "vm1"
ignore_errors: yes
c++ 中的一个简单循环应该是这样的:
int x=0;
for (int i=1; i<loopvar; i+=pow(2,x)) //pow is a math function with pow(2,x)= 2^x
{
cout<<hi;
x++;
}
还有一件事,我如何将每次迭代的结果存储在寄存器中,以便在 playbook 第二次、第三次或第四次连续运行时可用。
更新: Jinja2 允许: 将左操作数提升到右操作数的幂。
{{ 2**3 }} would return 8.
现在牢记这些新信息,我们可以做 2 次幂循环吗?
【问题讨论】:
标签: loops variables math prompt ansible-playbook