我正在编写以下 cloud-init 文件,该文件将在 OpenStack 中部署 VM 时执行:
#cloud-config
password: passwword
chpasswd: { expire: False }
ssh_pwauth: True
write_files:
- content: |
This is the write_files and should be line 1 of 2
path: /home/ubuntu/file.txt
- content: |
echo "This is the runcmd and should be line 3 of 3" >> /home/ubuntu/file.txt
owner: root:root
permissions: '755'
path: /home/ubuntu/bin/test
runcmd:
- echo "This is the runcmd and should be line 2 of 2" >> /home/ubuntu/file.txt
- test
VM启动后,输出为cat file.txt
:
This is the write_files and should be line 1 of 2
This is the runcmd and should be line 2 of 2
cloud-init
因此,不会执行运行名为 的 shell 脚本的最后一行,test
该脚本会写入file.txt
..
我究竟做错了什么 ?!
答案1
我猜这/home/ubuntu/bin/
不在 PATH 中。尝试/home/ubuntu/bin/test
在runcmd