Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command not found while trying to build package with ansible

Tags:

ansible

etcd

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?

like image 393
Сергей Дубинин Avatar asked Mar 19 '23 09:03

Сергей Дубинин


1 Answers

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
like image 103
Slava Semushin Avatar answered Apr 06 '23 11:04

Slava Semushin