Ansible playbook未在设备列表中循环

Ansible playbook未在设备列表中循环,ansible,ansible-2.x,ansible-inventory,Ansible,Ansible 2.x,Ansible Inventory,我试图将变量循环到一个剧本中,但我一直得到以下错误 TASK [Add policy package to model device] ******************************************************************************************************************************************************************** failed: [fmg01] (

我试图将变量循环到一个剧本中,但我一直得到以下错误

TASK [Add policy package to model device] ********************************************************************************************************************************************************************
failed: [fmg01] (item={'device_name': 'FGT1', 'device_ip': '192.168.0.103', 'group_name': 'Branch_Office', 'policy_package': 'default', 'device_serial': 'FGVM01TM12345678'}) => {"ansible_loop_var": "item", "changed": false, "item": {"device_ip": "192.168.0.103", "device_name": "FGT1", "device_serial": "FGVM01TM12345678", "group_name": "Branch_Office", "policy_package": "default"}, "meta": {"status": {"code": -10, "message": "The data is invalid for selected url"}, "url": "/pm/pkg/adom/root"}, "unreachable": false}
下面是我的YML剧本。当我使用静态变量(将单个IP地址和序列号作为字符串写出)时,它工作得很好

这是我的inventory.yml文件。我在第一个任务中测试了这个ok。它在ok中传入了IP地址。我用device_serial参数测试了其他任务,但没有成功

#feeds into playbook
#add_device / add_device_group
device_list:
  - device_name: FGT1
    device_ip: '192.168.0.103'
    group_name: Branch_Office
    policy_package: default
    device_serial: 'FGVM01TM12345678'


问题原来是带有参数的缩进问题

- name: Add policy package to model device
  fmgr_pm_pkg_adom_obj:
    loose_validation: true
    method: set
    url_params:
      adom: root
    params:
      - data:
          name: default
          scope member:
            - name: '{{item.device_serial}}'
              vdom: root
          type: pkg
  loop: '{{device_list}}'

这看起来不像是一个循环问题……也就是说,Ansible似乎在设备列表中循环。错误是“所选url的数据无效”,但我不熟悉fortinet模块,因此我不确定那里会发生什么。这是否表明存在yml格式问题?在添加变量之前,我单独运行了这些任务。我还在一个在线的yml格式化工具中运行了yml文件,检查它是否正常。谢谢,我找到了它。这是一个缩进问题。谢谢你的帮助!
- name: Add policy package to model device
  fmgr_pm_pkg_adom_obj:
    loose_validation: true
    method: set
    url_params:
      adom: root
    params:
      - data:
          name: default
          scope member:
            - name: '{{item.device_serial}}'
              vdom: root
          type: pkg
  loop: '{{device_list}}'