我正在尝试安装Kiex https://github.com/taylor/kiex版本管理器Elixir http://elixir-lang.org/install.html使用 Ansible 的编程语言。
这些是我为此使用的戏剧:
- name: Kiex Installation
hosts: web
gather_facts: false
remote_user: deployer
tasks:
- shell: \curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | bash -s
- name: Add Kiex Bin to Path
lineinfile:
dest: /home/deployer/.bashrc
regexp: '^test -s'
line: '[[ -s "$HOME/.kiex/scripts/kiex" ]] && source "$HOME/.kiex/scripts/kiex"'
- name: Reload Path
shell: source /home/deployer/.bashrc
args:
executable: /bin/bash
- shell: echo $PATH
register: pathul
- debug:
var: pathul
- name: Elixir Installation
hosts: web
gather_facts: false
remote_user: deployer
tasks:
- shell: echo $PATH
register: pathul
- debug:
var: pathul
- name: Install Elixir Version
command: /home/deployer/.kiex/bin/kiex list
args:
executable: /bin/bash
chdir: /home/deployer/
- name: Set Elixir Version as Default
shell: kiex default 1.4
Kiex 安装成功,如果我登录到远程计算机,我只需使用以下命令即可运行它kiex
命令。我可以这样做,因为我在“~/.kiex/scripts/kiex”中获取了二进制文件。当我回响$PATH
变量显示 kiex 二进制文件路径/home/deployer/.kiex/bin
in it:
$ echo $PATH
/home/deployer/.kiex/bin:/home/deployer/.kiex/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
但是,那kiex
, kiex list
甚至是/home/deoployer/.kiex/bin/kiex list
in the Elixir 安装上面显示的播放失败并显示消息:
TASK [Set Elixir Version as Default] *******************************************
fatal: [local-web-2]: FAILED! => {"changed": true, "cmd": "kiex default 1.4", "delta": "0:00:00.002042", "end": "2017-01-26 22:13:32.898082", "failed": true, "rc": 127, "start": "2017-01-26 22:13:32.896040", "stderr": "/bin/sh: 1: kiex: not found", "stdout": "", "stdout_lines": [], "warnings": []}
还有pathul
注册通过 ansible 回显路径结果的变量不包含/home/deployer/.kiex/bin
:
"stdout": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
我怎样才能使kiex
命令通过 Ansible 正常工作吗?