I have a simple ansible playbook which builds 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
So when I launch ansible-playbook on the remote as root "Build etcd" fails with error:
failed: [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
17th line in "build" contains the following:
go install github.com/coreos/etcd
But go is installed and I can build etcd manually on the remote server. What am I doing wrong?
Module joshualund.golang
installs go
to non-standart directory /usr/local/go
(look at the sources) so a problem most likely because of this fact.
To resolve it you should somehow update $PATH
variable which used by ansible. One of the way is to explicitly specify it:
- name: Build etcd
command: chdir={{repo_location}} ./build
environment:
PATH: /sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With