Ansible 2.2:使用with_序列在列表中查找值

Ansible 2.2:使用with_序列在列表中查找值,ansible,ansible-2.x,ansible-template,Ansible,Ansible 2.x,Ansible Template,我想做以下工作: - lineinfile: dest: "file{{ item }}.properties" line: "port: {{ port_list[item - 1] }}" with_sequence: start=1 end={{ nb_process }} 我有port_列表变量,其中包含要插入到每个属性文件中的端口。我有以下错误作为回报: unsupported operand type(s) for -: 'unicode' and 'in

我想做以下工作:

- lineinfile:
     dest: "file{{ item }}.properties"
     line: "port: {{ port_list[item - 1] }}"
  with_sequence: start=1 end={{ nb_process }}
我有port_列表变量,其中包含要插入到每个属性文件中的端口。我有以下错误作为回报:

 unsupported operand type(s) for -: 'unicode' and 'int'
有什么想法吗?我也试过了

 line: "port: {{ port_list[(item - 1)|int] }}"
到目前为止还没有成功。

尝试:

line: "port: {{ port_list[item|int - 1] }}"