2017-03-28 39 views
0

我正在使用Ansible 2.2.1.0,並且我正在處理由其他人出錯的舊項目。Ansible - 'unicode對象'沒有屬性'file_input'

我在我的代碼以下變量:

software_output: 
    - { file_input: 'Download_me.zip', file_output: 'download.zip' } 

software_version:"0.5,0.6" 

而且我有這個殼模塊指令下載一個FTP:

- name: "MySoftware | get package on FTP" 
    shell: > 
    curl --ftp-ssl -k {{ ' --ssl-allow-beast ' if os == 'aix' else "" }} -# -f -u {{ ftp_user }}:{{ ftp_password }} -f "{{ ftp_url | replace('@@[email protected]@',item[1]) }}{{ item[0].file_input }}" 
    -o {{ require_inst_dir }}/{{ item[0].file_output }} 2>/dev/null 
    with_nested: 
    - software_output 
    - "{{ software_version.split(',') }}" 
    when: software_version is defined 

但它不會在所有的工作,我有以下錯誤:

'unicode object' has no attribute 'file_input' 

它看起來像with_nested不使用,因爲它必須使用,我錯過了什麼?

回答

0

在:

with_nested: 
    - software_output 

software_output是一個字符串software_output

來引用變量值,更改爲:

with_nested: 
    - "{{ software_output }}" 

很早以前第一語法是有效的,但它是很久以前的事。

+0

哦,你是對的技術!我怎麼會錯過? 可能是因爲我們項目的很大一部分總是基於非常老的Ansible版本。 非常感謝您! – Matthew

相關問題