Сер*_*нин 4 ansible ansible-playbook etcd
我有一个简单的 ansible playbook 来构建 etcd:
- hosts: all
vars:
repo_location: /var/lib/etcd/src/
roles:
- joshualund.golang
#to install go
tasks:
- name: Clone etcd
action: git repo=https://github.com/coreos/etcd dest={{repo_location}}
- name: Build etcd
command: chdir={{repo_location}} ./build
- name: Start etcd
service: ./bin/etcd state=started
Run Code Online (Sandbox Code Playgroud)
因此,当我以 root 身份在远程启动 ansible-playbook 时,“Build etcd”失败并出现错误:
失败:[test] => {"changed": true, "cmd": ["./build"], "delta": "0:00:00.002628", "end": "2014-06-10 07: 44:23.952227", "rc": 127, "start": "2014-06-10 07:44:23.949599"} stderr: ./build: 17: ./build: go: not found
“build”中的第 17 行包含以下内容:
go install github.com/coreos/etcd
Run Code Online (Sandbox Code Playgroud)
但是安装了 go,我可以在远程服务器上手动构建 etcd。我究竟做错了什么?
模块joshualund.golang安装go到非标准目录/usr/local/go(查看源代码),因此很可能因为这个事实而出现问题。
要解决它,您应该以某种方式更新$PATHansible 使用的变量。一种方法是明确指定它:
- name: Build etcd
command: chdir={{repo_location}} ./build
environment:
PATH: /sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3068 次 |
| 最近记录: |