将变量注册到预先存在的列表

时间:2016-10-06 11:46:28

标签: ansible ansible-playbook ansible-2.x

我有一个列表和一个with_items循环,我在列表中查看。我的问题是,当我查看列表时,如何将结果注册/附加到现有列表?我使用的是Ansible 2.0.1.0版。

我的清单:

channels:
  channel1:
    item1: 'value'
    item2: 'value'
  channel2:
    item1: 'value'
    item2: 'value'

循环:

- name: Do a shell command for each channel
  shell: some command that returns a number with the help {{ item }}
  with_items: "{{ channels }}"
  register: channels.item3.result #?? not sure how to do this

执行debug var = channels时输出应该是什么:

channels:
  channel1:
    item1: 'value'
    item2: 'value'
    item3: 'result from shell command'
  channel2:
    item1: 'value'
    item2: 'value'
    item3: 'result from shell command'

0 个答案:

没有答案