信息+目标:
我正在使用 MAAS 来部署带有 Ubuntu 的工作站。
MAAS 只是用股票 Ubuntu 部署机器,然后我运行我编写的 bash 脚本来设置所需的一切。
到目前为止,我已经在新部署的机器上手动运行了该 bash 脚本。现在,我正在尝试让 MAAS 自动运行该脚本。
我做了什么+错误:
在 MAAS 机器中,我创建了以下名为 curtin 的文件/var/snap/maas/current/preseeds/curtin_userdata_ubuntu
,其中包含以下内容:
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'
问题
我不确定将这么大的 bash 脚本放在 curtin 文件中是个好主意。有没有办法将 bash 脚本存储在 MAAS 机器上,并让 curtin 将其上传到服务器,然后执行它?如果没有,是否可以修复我遇到的错误?
提前谢谢!