我让Ansible给ROS安排了几个树莓派。ROS安装得很好,但ansible不让我运行catkin_make:
fatal: [100.100.100.119]: FAILED! => {"changed": true, "cmd": "cd /home/ubuntu/catkin_ws; catkin_make", "delta": "0:00:00.012524", "end": "2019-09-23 13:47:24.918048", "msg": "non-zero return code", "rc": 127, "start": "2019-09-23 13:47:24.905524", "stderr": "/bin/bash: catkin_make: command not found", "stderr_lines": ["/bin/bash: catkin_make: command not found"], "stdout": "", "stdout_lines": []}以下是我的攻略:
- name: make Catkin folders
file:
path: "/home/ubuntu/catkin_ws/src"
state: directory
owner: ubuntu
group: ubuntu
mode: '0775'
tags:
- untested
- name: Clone Git into Catkin Folder
shell: cd /home/ubuntu/catkin_ws/src; git clone https://github.com/xxxxx
become_user: ubuntu
tags:
- untested
- name: Add bashrc
shell: echo "source /opt/ros/melodic/setup.bash" >> /home/ubuntu/.bashrc
become_user: ubuntu
tags:
- untested
- name: Load new ROS env
shell: cd /home/ubuntu/catkin_ws; source /home/ubuntu/.bashrc
become_user: ubuntu
args:
executable: /bin/bash
tags:
- untested
- name: Catkin Make
shell: cd /home/ubuntu/catkin_ws; catkin_make
become_user: ubuntu
tags:
- untested如果我在运行playbook之后登录,直到它失败,然后手动运行catkin_make,它工作得很好,我就被难住了。
发布于 2019-09-24 01:04:11
简短的回答
"/bin/bash: catkin_make:找不到命令“
这是不言而喻的:这意味着当您尝试启动命令时,该命令不在用户的路径中。
更长的答案
我不得不在这里猜测一下,但从我看到的情况来看,我相信当您添加行source /opt/ros/melodic/setup.bash时,catkin_make的路径已经设置在您的.bashrc文件中。如果我是对的,请看下面为什么它不能按照你的方式工作。
但首先,在你的行动手册中有几个错误/糟糕的实践,你应该修复。
shell任务中使用cd XXX,而您应该使用chdir arg,如以下演示任务中所示:- name: do something in shell
shell: do_something
args:
chdir: /home/my/usershell进行具有现有ansible模块的操作,这些模块更安全且幂等。例如,您可以使用lineinfile将行添加到文件中,或者使用git克隆git repository.shell任务中自动获取您的.bashrc,而无需启动任何其他命令。这不会做任何事情。一旦任务完成,所有的东西都会丢失。从上面的所有恢复,这是我要尝试的。只有这里的最后一个任务真正解决了你的问题(如果我的猜测是正确的话):
- name: make Catkin folders
file:
path: "/home/ubuntu/catkin_ws/src"
state: directory
owner: ubuntu
group: ubuntu
mode: '0775'
tags:
- untested
- name: Clone Git into Catkin Folder
git:
repo: https://github.com/xxxxx
dest: /home/ubuntu/catkin_ws/src
become_user: ubuntu
tags:
- untested
- name: Add bashrc
lineinfile:
path: /home/ubuntu/.bashrc
line: source /opt/ros/melodic/setup.bash
become_user: ubuntu
tags:
- untested
- name: Catkin Make with env loaded
shell: |-
source /home/ubuntu/.bashrc
catkin_make
become_user: ubuntu
args:
executable: /bin/bash
chdir: /home/ubuntu/catkin_ws
tags:
- untestedhttps://stackoverflow.com/questions/58065734
复制相似问题