我随身带着一个mac地址。让我们假设
00:ae:cd:09:db:4f我需要创建一个循环,在这个循环中,每当这个mac地址被值1递增时,这个循环就会被迭代2次。
预期产出:
00:ae:cd:09:db:50
00:ae:cd:09:db:51我需要创建一个输出列表。
我尝试了ipmath(1),尝试使用hwdaddr()和其他lib转换成不同的格式。但没有得到任何运气。救命啊!!
发布于 2022-10-31 13:03:51
使用with_sequence。例如,
- hosts: localhost
vars:
mac: 00:ae:cd:09:db:4f
count: 2
macs: []
tasks:
- set_fact:
macs: "{{ macs + [new|join(':')] }}"
with_sequence: count="{{ count }}"
vars:
arr: "{{ mac.split(':') }}"
ar5: "{{ '%02x' % (arr.5|int(base=16) + item|int) }}"
new: "{{ arr[:5] + [ar5] }}"
- debug:
var: macs给予(删节)
macs:
- 00:ae:cd:09:db:50
- 00:ae:cd:09:db:51https://stackoverflow.com/questions/74262060
复制相似问题