1

我想做以下事情:

- lineinfile:
     dest: "file{{ item }}.properties"
     line: "port: {{ port_list[item - 1] }}"
  with_sequence: start=1 end={{ nb_process }}

我有 port_list 变量,其中包含要插入每个属性文件的端口。我有以下错误作为回报:

 unsupported operand type(s) for -: 'unicode' and 'int'

任何的想法 ?我也试过

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

至今没有成功。

4

1 回答 1

2

尝试:

line: "port: {{ port_list[item|int - 1] }}"
于 2017-03-14T16:08:42.430 回答