2015-12-04 13 views
14

Thứ tự của các chỉ thị trong phần cấu hình đám mây của đối tượng dữ liệu người dùng-init của đám mây là gì. Điều này là quan trọng để tránh điều kiện loại chủng tộc.cloud-init: Lệnh thực hiện lệnh chỉ thị đám mây là gì?

Tôi biết bootcmd chạy sớm và trước runcmd, nhưng có danh sách tốt thứ tự của tất cả các phương pháp không?

Trả lời

15

Từ https://git.launchpad.net/cloud-init/tree/config/cloud.cfg (nhờ garbelini)

# The modules that run in the 'init' stage 
cloud_init_modules: 
- migrator 
- ubuntu-init-switch 
- seed_random 
- bootcmd 
- write-files 
- growpart 
- resizefs 
- set_hostname 
- update_hostname 
- update_etc_hosts 
- ca-certs 
- rsyslog 
- users-groups 
- ssh 

# The modules that run in the 'config' stage 
cloud_config_modules: 
# Emit the cloud config ready event 
# this can be used by upstart jobs for 'start on cloud-config'. 
- emit_upstart 
- disk_setup 
- mounts 
- ssh-import-id 
- locale 
- set-passwords 
- snappy 
- grub-dpkg 
- apt-pipelining 
- apt-configure 
- package-update-upgrade-install 
- fan 
- landscape 
- timezone 
- lxd 
- puppet 
- chef 
- salt-minion 
- mcollective 
- disable-ec2-metadata 
- runcmd 
- byobu 

# The modules that run in the 'final' stage 
cloud_final_modules: 
- rightscale_userdata 
- scripts-vendor 
- scripts-per-once 
- scripts-per-boot 
- scripts-per-instance 
- scripts-user 
- ssh-authkey-fingerprints 
- keys-to-console 
- phone-home 
- final-message 
- power-state-change 

Ngoài ra:

Có cấu hình sáp nhập "Trình tự như sau: - tập tin cấu hình cli ghi đè lên tập tin cấu hình môi trường mà dụ override configs mà ghi đè nguồn dữ liệu cấu hình ghi đè cấu hình cơ sở ghi đè cấu hình mặc định . " (Xem Changelog)

Trong kịch bản cá nhân tạo ra các thư mục mà các script được chạy theo thứ tự được đưa ra bởi trăn "sắp xếp()" BUILTIN

Chú ý: mặc dù điều này là chính xác tại thời điểm trả lời, nhìn vào Kho lưu trữ (tính đến tháng 9 năm 2017) được đề cập ở trên hiện có tệp mẫu cloud.cfg.tmpl có cài đặt hơi khác nhau cho các bản phân phối khác nhau

# The modules that run in the 'init' stage 
cloud_init_modules: 
- migrator 
- seed_random 
- bootcmd 
- write-files 
- growpart 
- resizefs 
{% if variant not in ["freebsd"] %} 
- disk_setup 
- mounts 
{% endif %} 
- set_hostname 
- update_hostname 
{% if variant not in ["freebsd"] %} 
- update_etc_hosts 
- ca-certs 
- rsyslog 
{% endif %} 
- users-groups 
- ssh 

# The modules that run in the 'config' stage 
cloud_config_modules: 
{% if variant in ["ubuntu", "unknown", "debian"] %} 
# Emit the cloud config ready event 
# this can be used by upstart jobs for 'start on cloud-config'. 
- emit_upstart 
- snap_config 
{% endif %} 
- ssh-import-id 
- locale 
- set-passwords 
{% if variant in ["rhel", "fedora"] %} 
- spacewalk 
- yum-add-repo 
{% endif %} 
{% if variant in ["ubuntu", "unknown", "debian"] %} 
- grub-dpkg 
- apt-pipelining 
- apt-configure 
{% endif %} 
{% if variant not in ["freebsd"] %} 
- ntp 
{% endif %} 
- timezone 
- disable-ec2-metadata 
- runcmd 
{% if variant in ["ubuntu", "unknown", "debian"] %} 
- byobu 
{% endif %} 

# The modules that run in the 'final' stage 
cloud_final_modules: 
{% if variant in ["ubuntu", "unknown", "debian"] %} 
- snappy 
{% endif %} 
- package-update-upgrade-install 
{% if variant in ["ubuntu", "unknown", "debian"] %} 
- fan 
- landscape 
- lxd 
{% endif %} 
{% if variant not in ["freebsd"] %} 
- puppet 
- chef 
- salt-minion 
- mcollective 
{% endif %} 
- rightscale_userdata 
- scripts-vendor 
- scripts-per-once 
- scripts-per-boot 
- scripts-per-instance 
- scripts-user 
- ssh-authkey-fingerprints 
- keys-to-console 
- phone-home 
- final-message 
- power-state-change 
+0

Có cách nào để buộc thay đổi thực thi không? Ví dụ, tôi cần phải chắc chắn để cài đặt dirmngr (nó bị thiếu trong distro của tôi) trước khi apt được chạy và cố gắng nhập một khóa nguồn vì nó sẽ thất bại. Sau đó, tôi sẽ tiếp tục cài đặt các gói còn lại của tôi như bình thường. – Tristan

+1

Có trường hợp nào mà lệnh thi hành không được tôn trọng không? Trong ảnh Ubuntu Cloud 16.04, 'runcmd' được đặt trong giai đoạn' config' và 'package-update-upgrade-install' được đặt trong giai đoạn' final', nhưng tôi có thể chạy 'runcmd' sau khi cài đặt gói mà không có bất kỳ lỗi nào. – dvnguyen

+1

@Tristan Tôi nhận thấy bây giờ có ba bước để cấu hình apt/dpkg, mayeb bạn có thể móc một trong số chúng? – Vorsprung

Các vấn đề liên quan