有setup.ini,它位于文件夹TEMP中,您需要从中获取变量。我无法将file路径作为变量传递给参数。我不想硬核,我按照这里写的做了。
- name: Set some fact about Autodesk product
when:
- ansible_os_family == 'Windows'
- ansible_env.PROCESSOR_ARCHITECTURE == 'AMD64'
vars:
autodesk_path_to_setup_ini_file: '{{ ansible_env.TMP }}\setup-{{ autodesk_product_directory }}.ini'
autodesk_product_directory: autocad
set_fact:
autodesk_adlm_version_fact: "{{ lookup('ini', 'ADLM_VERSION section=SETUP file={{ autodesk_path_to_setup_ini_file }} encoding=utf-16') }}"
delegate_to: "{{ inventory_hostname }}"
错误:
fatal: [10.10.10.178]: FAILED! => {
"msg": "An unhandled exception occurred while running the lookup plugin 'ini'. Error was a <class 'ansible.errors.AnsibleParserError'>, original message: Invalid filename: 'None'"
}
ansible 2.9.13
我找到了一个方法。有一个名为psini的插件模块将其
ini转换为对象。然后我们导出到json,json把它变成一个事实,一切都开始工作了。像这样的东西: