信息+目标:
我正在使用MAAS来部署带有Ubuntu的工作站。
MAAS只需使用现成的Ubuntu部署机器,然后运行我编写的bash脚本来设置所需的一切。
到目前为止,我已经在新部署的机器上手动运行了bash脚本。现在,我正在尝试让MAAS自动运行该脚本。
我做了什么+错误:
在MAAS机器中,我创建了以下名为/var/snap/maas/current/preseeds/curtin_userdata_ubuntu的curtin文件,其中包含以下内容:
write_files:
bash_script:
path: /root/script.sh
content: |
#!/bin/bash
echo blabla
... very long bash script
permissions: '0755'
late_commands:
run_script: ["/bin/bash /root/script.sh"]但是,在日志中,我看到了以下内容:
known-caiman cloud-init[1372]: Command: ['/bin/bash /root/script.sh']
known-caiman cloud-init[1372]: Exit code: -
known-caiman cloud-init[1372]: Reason: [Errno 2] No such file or directory: '/bin/bash /root/script.sh': '/bin/bash /root/script.sh'问题
我不确定在curtin文件中放入这么大的bash脚本是不是一个好主意。有没有办法将bash脚本存储在MAAS机器上,并让curtin将其上传到服务器,然后执行它?如果没有,有没有可能修复我遇到的错误?
感谢大家的支持!
发布于 2021-06-23 17:19:47
这在执行命令时起到了作用:
["curtin", "in-target", "--", "/bin/bash", "/root/script.sh"]虽然这个方法仍然意味着我必须写入文件,然后执行它。我仍然希望有一种上传文件并执行它的方法。
发布于 2022-01-18 14:08:48
我没有将我的脚本添加到curtin文件中。我运行下面的命令并部署服务器。
maas admin machine deploy $system_id user_data=$(base64 -w0 /root/script.sh)
https://stackoverflow.com/questions/68082437
复制相似问题