[英]Ansible playbook complains about quotes
I'm using Ubuntu 16 with Ansible 2.2.1.0.我正在使用带有 Ansible 2.2.1.0 的 Ubuntu 16。
I am trying to install docker-compose
with the following playbook:我正在尝试使用以下剧本安装
docker-compose
:
- name: Install Docker Compose.
shell: "curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose"
file:
dest=/usr/local/bin/docker-compose mode=x
src=/usr/local/bin/docker-compose dest=/usr/bin/docker-compose state=link
I get this error:我收到此错误:
- name: Install Docker Compose.
shell: "curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose"
^ here
This one looks easy to fix. It seems that there is a value started
with a quote, and the YAML parser is expecting to see the line ended
with the same kind of quote. For instance:
when: "ok" in result.stdout
Could be written as:
when: '"ok" in result.stdout'
What is the problem?问题是什么? I have starting and ending quotes.
我有开始和结束的引号。
shell module hasn't file parameter and shell and name should be on same column that why you got the error and also use a double quote for URL and not full shell command: shell 模块没有文件参数,shell 和名称应该在同一列上,这就是为什么你得到错误的原因,并且还对 URL 使用双引号而不是完整的 shell 命令:
- name: Install Docker Compose.
shell: curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose"
You can use the get_url module to download the file to the destination and set permission.您可以使用get_url模块将文件下载到目的地并设置权限。 And I highly recommend using Ansible role that presented by contributors on the ansible galaxy and not to reinvited wheels!
我强烈建议使用 Ansible 角色,该角色由 ansible星系的贡献者提供,而不是重新邀请轮子!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.