dongyongju9560 2015-10-19 13:48
浏览 56
已采纳

Ansible GVM-Go版本管理器

Writing my first Ansible Script. I am trying to install GVM.

I install GVM ok (I logged into the box and checked) when I run gvm version on the box direct I get: Go Version Manager v1.0.22 installed at /d1/golang/gvm

But when I run it as a command in Ansible:

- name: GVM Version
  shell: gvm version
  become: yes

I get the following error:

failed: [prod2] => {"changed": true, "cmd": "gvm version", "delta": "0:00:00.002081", "end": "2015-10-19 13:41:54.123575", "rc": 127, "start": "2015-10-19 13:41:54.121494", "warnings": []}
stderr: /bin/bash: gvm: command not found

FATAL: all hosts have already failed -- aborting

I am running a bash script which contains: source /d1/golang/gvm/scripts/gvm which is supposed to ensure you don't have to restart the terminal - see ansible command below.

- name: Run gvm source
  shell: . /etc/profile.d/golang.sh executable=/bin/bash
  become: yes

Any ideas what I am doing wrong?

  • 写回答

1条回答 默认 最新

  • dslf46995 2015-10-19 14:30
    关注

    I ended up running two commands in the ansible command

    name: Install go
      shell: . /etc/profile.d/golang.sh && gvm install go1.5 executable=/bin/bash
    

    This ensures the source has been set then allows the gvm command to be run.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?