2017-08-17 96 views
0

我已经创建了用于更新iLO固件的Ansible操作手册,并且它工作正常。然而,它给了我一个逗号分隔值的列表已被弃用警告(我的其他剧本没有给出这个警告)。我假设这必须与iLO_Models变量,所以我试图改变变量只有一个模型,仍然得到警告。Ansible list给出了弃用警告

Ansible版本是2.3.2.0。我只想修复我的代码以删除警告并确保它不会中断。

--- 
- name: iLO Firmware Upgrade for Standalone Servers 
    hosts: testing 
    gather_facts: true 
    gather_subset: hardware 
    become: true 
    vars: 
    firmware_directory: /firmware 
    iLO4: iLO4-2.54-CP032620.scexe 
    iLO4_Models: 
     - 'ProLiant DL320e Gen8 v2' 
     - 'ProLiant DL380 Gen9' 
     - 'ProLiant DL580 G9' 
     - 'ProLiant BL460c Gen8' 
     - 'ProLiant BL460c Gen9' 
    tasks: 
    - name: Copy iLO4 update 
     copy: > 
      src={{ firmware_directory }}/{{ iLO4 }} 
      dest=/tmp/ 
      owner=root 
      group=root 
      mode=0640 
     when: ansible_product_name in iLO4_Models 

    - name: Install iLO4 Update 
     shell: /bin/bash /tmp/{{ iLO4 }} -s 
     when: ansible_product_name in iLO4_Models 
     register: ilo_result 
     changed_when: ilo_result.rc == 0 
     failed_when: ilo_result.rc == 1 or ilo_result.rc == 4 

我得到以下警告:

[DEPRECATION WARNING]: Using comma separated values for a list has been deprecated. You should instead use the correct YAML syntax for lists. . 
This feature will be removed in a future release. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg. 

回答

1

这是因为gather_subset: hardware

替换:

gather_subset: [hardware] 

或:

gather_subset: 
    - hardware