Я пишу следующий файл cloud-init, который будет выполняться при развертывании виртуальной машины в OpenStack:
#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
После запуска виртуальной машины вывод 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
не выполняется, которая запускает сценарий оболочки с именем test
, который записывает в file.txt
..
что я делаю не так ?!
Я предполагаю, что /home/ubuntu/bin/
нет в ПУТИ.
Попробуйте указать абсолютный путь /home/ubuntu/bin/test
в runcmd