我正在尝试使用通过RBENV安装的ruby。我已经确认RBENV按要求工作,并产生了可以通过终端调用的正确ruby版本
ruby -v
退货:
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]
哪个是所需的版本
bundler -v
退货:
Bundler version 2.3.10
这也是期望的版本。
然而,我的剧本中的以下任务失败了
- block:
- name: 'set ruby version'
shell: echo eval "$(rbenv init -)" >> ~/.zshrc
- name: 'set global ruby verison'
shell: 'rbenv global {{ ruby_version }}'
- name: 'restart shell'
shell: $shell
- name: 'Bundle install'
shell:
chdir: "{{ app_path }}"
cmd: bundle install
become: yes
become_user: '{{ deploy_user}}'
当我试图在我的剧本中执行这些任务时,我得到了以下输出
fatal: [45.77.186.234]: FAILED! => {"changed": true, "cmd": "bundle install", "delta": "0:00:00.001967", "end": "2022-03-25 00:33:48.231712", "msg": "non-zero return code", "rc": 127, "start": "2022-03-25 00:33:48.229745", "stderr": "/bin/sh: 1: bundle: not found", "stderr_lines": ["/bin/sh: 1: bundle: not found"], "stdout": "", "stdout_lines": []}
关于
docs page
对于ansible.builtin.shell,大纲下的第三个要点表示shell命令是使用用户的shell环境执行的。我看不到应该具体定义哪个shell的地方,我想知道我对ZSH的使用是否是问题所在?
在这一点上,我已经尝试了我能想到的一切,现在我请求帮助。如何在用户的shell环境中运行shell命令?