Ansible 剧本抱怨引号
Ansible playbook complains about quotes
我正在使用 Ubuntu 16 和 Ansible 2.2.1.0。
我正在尝试使用以下手册安装 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
我收到这个错误:
- 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'
有什么问题?我有开始和结束引号。
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"
可以使用get_url module to download the file to the destination and set permission. And I highly recommend using Ansible role that presented by contributors on the ansible galaxy而不是重请轮子!
我正在使用 Ubuntu 16 和 Ansible 2.2.1.0。
我正在尝试使用以下手册安装 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
我收到这个错误:
- 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'
有什么问题?我有开始和结束引号。
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"
可以使用get_url module to download the file to the destination and set permission. And I highly recommend using Ansible role that presented by contributors on the ansible galaxy而不是重请轮子!