Ansible GVM – Go版本管理器

huangapple go评论96阅读模式
英文:

Ansible GVM - Go Version Manager

问题

我正在写我的第一个Ansible脚本,尝试安装GVM。

我成功安装了GVM(我登录到服务器并进行了检查),当我直接在服务器上运行gvm version时,得到的结果是:Go Version Manager v1.0.22 installed at /d1/golang/gvm

但是当我在Ansible中将其作为命令运行时,出现了以下错误:

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

我正在运行一个包含以下内容的bash脚本:source /d1/golang/gvm/scripts/gvm,它应该确保您无需重新启动终端-请参见下面的Ansible命令。

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

有任何想法我做错了什么吗?

英文:

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

得分: 0

我在ansible命令中运行了两个命令:

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

这样可以确保源已经设置好,然后允许运行gvm命令。

英文:

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.

huangapple
  • 本文由 发表于 2015年10月19日 21:48:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/33216185.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定