我创建了一个Ansible脚本来下载PuTTY并在Windows上安装它。
- hosts: windows
tasks:
- name: Download Zip File
win_get_url:
url: "{{zipurl}}"
dest: "{{myvarfile}}"
- name: Extract zipfile
win_unzip:
src: "{{myvarfile}}"
dest: "C:\{{packagename}}"
recurse: yes
rm: true
然后:
ansible-playbook deploywar.yml \
--extra-vars="myvarfile=c:\putty.zip zipurl=https://the.earth.li/~sgtatham/putty/latest/w64/putty.zip packagename=putty"
现在我需要将包名称作为参数传递,并需要在:
中连接dest: "C:\\{{packagename}}"
我怎样才能做到这一点?
答案 0 :(得分:0)
使用单引号:
dest: 'C:\{{packagename}}'
或转义特殊字符:
dest: "C:\\{{packagename}}"