我可以ssh到远程主机并做source /home/username/.bashrc- 一切正常.但是,如果我这样做:
- name: source bashrc
sudo: no
action: command source /home/username/.bashrc
Run Code Online (Sandbox Code Playgroud)
我明白了:
failed: [hostname] => {"cmd": ["source", "/home/username/.bashrc"], "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么......
我正在尝试使用下面的Ansible yml文件使用nvm安装节点js版本.
我收到错误,如找不到源"home /home/centos/.nvm/nvm.sh"文件.但如果我通过使用ssh登录机器来做同样的事情,那么它可以正常工作.
- name: Install nvm
git: repo=https://github.com/creationix/nvm.git dest=~/.nvm version={{ nvm.version }}
tags: nvm
- name: Source nvm in ~/.profile
lineinfile: >
dest=~/.profile
line="source ~/.nvm/nvm.sh"
create=yes
tags: nvm
- name: Install node {{ nvm.node_version }}
command: "{{ item }}"
with_items:
- "source /home/centos/.nvm/nvm.sh"
- nvm install {{ nvm.node_version }}
tags: nvm
Run Code Online (Sandbox Code Playgroud)
错误:
failed: [172.29.4.71] (item=source /home/centos/.nvm/nvm.sh) => {"cmd": "source /home/centos/.nvm/nvm.sh", "failed": true, "item": "source /home/centos/.nvm/nvm.sh", "msg": "[Errno 2] No such file or directory", "rc": 2}
failed: [172.29.4.71] (item=nvm …Run Code Online (Sandbox Code Playgroud) 我有一个文件中的别名列表.bash_aliases,正在被复制到远程服务器ansible playbook.该文件得到复制到目标,但.bashrc(这反过来加载.bash_aliases)文件是没有得到使用以下ansible任务加载.
我试过给出可执行参数
- name: source the .bashrc file
shell: source ~/.bashrc
args:
executables: "/bin/bash"
Run Code Online (Sandbox Code Playgroud)
没有争论
- name: source the .bashrc file
shell: source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
使用原始模块
- name: source the .bashrc file
raw: source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
使用命令模块 - 名称:源.bashrc文件命令:source~/.bashrc
什么都行不通!任何帮助