Я пытаюсь запустить несколько скриптов и конфигурацию, используя составную конфигурацию.
Content-Type: multipart/mixed; boundary="MIMEBOUNDARY"
MIME-Version: 1.0
--MIMEBOUNDARY
Content-Disposition: attachment; filename="cloud-config.cfg"
Content-Transfer-Encoding: 7bit
Content-Type: text/cloud-config
Mime-Version: 1.0
package_upgrade: true
packages:
- jq
- docker
runcmd:
- service docker start
--MIMEBOUNDARY
Content-Disposition: attachment; filename="00-rancher_server_install"
Content-Transfer-Encoding: 7bit
Content-Type: text/x-shellscript
Mime-Version: 1.0
#!/bin/bash
# Pull required images
docker pull rancher/server:v1.0.2
--MIMEBOUNDARY--
Проблема заключается в том, в каком порядке выполняются сценарии ... - Сначала сценарии установки yum - Затем сценарии bash - Затем runcmd
скрипты
тогда служба докеров не была запущена при выполнении команд пользовательских скриптов
Я использую Amazon Linux AMI на EC2, это CentOS ...
Это журнал инициализации облака
Cloud-init v. 0.7.6 running 'modules:config' at Tue, 21 Jun 2016 01:30:44 +0000. Up 25.32 seconds.
Loaded plugins: priorities, update-motd, upgrade-helper
Metadata Cache Created
Loaded plugins: priorities, update-motd, upgrade-helper
No packages needed for security; 26 packages available
Resolving Dependencies
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 0:1.11.1-1.2.amzn1 will be installed
--> Processing Dependency: xfsprogs for package: docker-1.11.1-1.2.amzn1.x86_64
---> Package jq.x86_64 0:1.5-1.2.amzn1 will be installed
--> Processing Dependency: jq-libs(x86-64) = 1.5-1.2.amzn1 for package: jq-1.5-1.2.amzn1.x86_64
--> Processing Dependency: oniguruma for package: jq-1.5-1.2.amzn1.x86_64
--> Processing Dependency: libjq.so.1()(64bit) for package: jq-1.5-1.2.amzn1.x86_64
--> Processing Dependency: libonig.so.2()(64bit) for package: jq-1.5-1.2.amzn1.x86_64
--> Running transaction check
---> Package jq-libs.x86_64 0:1.5-1.2.amzn1 will be installed
---> Package oniguruma.x86_64 0:5.9.1-3.1.2.amzn1 will be installed
---> Package xfsprogs.x86_64 0:3.2.2-2.20.amzn1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
docker x86_64 1.11.1-1.2.amzn1 amzn-updates 17 M
jq x86_64 1.5-1.2.amzn1 amzn-updates 44 k
Installing for dependencies:
jq-libs x86_64 1.5-1.2.amzn1 amzn-updates 121 k
oniguruma x86_64 5.9.1-3.1.2.amzn1 amzn-main 149 k
xfsprogs x86_64 3.2.2-2.20.amzn1 amzn-main 1.7 M
Transaction Summary
================================================================================
Install 2 Packages (+3 Dependent packages)
Total download size: 19 M
Installed size: 60 M
Downloading packages:
--------------------------------------------------------------------------------
Total 11 MB/s | 19 MB 00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : oniguruma-5.9.1-3.1.2.amzn1.x86_64 1/5
Installing : jq-libs-1.5-1.2.amzn1.x86_64 2/5
Installing : xfsprogs-3.2.2-2.20.amzn1.x86_64 3/5
Installing : docker-1.11.1-1.2.amzn1.x86_64 4/5
Installing : jq-1.5-1.2.amzn1.x86_64 5/5
Verifying : docker-1.11.1-1.2.amzn1.x86_64 1/5
Verifying : oniguruma-5.9.1-3.1.2.amzn1.x86_64 2/5
Verifying : jq-1.5-1.2.amzn1.x86_64 3/5
Verifying : jq-libs-1.5-1.2.amzn1.x86_64 4/5
Verifying : xfsprogs-3.2.2-2.20.amzn1.x86_64 5/5
Installed:
docker.x86_64 0:1.11.1-1.2.amzn1 jq.x86_64 0:1.5-1.2.amzn1
Dependency Installed:
jq-libs.x86_64 0:1.5-1.2.amzn1 oniguruma.x86_64 0:5.9.1-3.1.2.amzn1
xfsprogs.x86_64 0:3.2.2-2.20.amzn1
Complete!
Cloud-init v. 0.7.6 running 'modules:final' at Tue, 21 Jun 2016 01:31:55 +0000. Up 96.28 seconds.
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Jun 21 01:31:55 cloud-init[2485]: util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/00-rancher_server_install [1]
Starting cgconfig service: [ OK ]
Starting docker: .[ OK ]
Jun 21 01:31:56 cloud-init[2485]: cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
Jun 21 01:31:56 cloud-init[2485]: util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
Cloud-init v. 0.7.6 finished at Tue, 21 Jun 2016 01:31:56 +0000. Datasource DataSourceEc2. Up 97.56 seconds
@smoser из irc # cloud-init мне помог
смотреть в /var/lib/cloud/instance/scripts/
вы увидите один файл с именем runcmd
а другие файлы в вашем multipart именуются по их имени файла.
Скрипты в этом каталоге запускаются в отсортированном порядке локали C (как если бы по частям выполнения)
Итак, если вы измените имя скрипта, который вы добавили из filename="00-rancher_server_install"
к filename="zz-rancher_server_install"
Тогда тебе будет хорошо.