LoginSignup
2
1

More than 3 years have passed since last update.

cloud-initでpackage-update-upgrade-installの頻度を指定する

Last updated at Posted at 2021-03-09
  • Ubuntu 20.04 にて確認

参考

設定

設定前

  • 起動時に待たされる。

3.png

1度も実行させたくない場合

  • コメントアウトする
sed -i \
 -e 's/^ - package-update-upgrade-install/# - package-update-upgrade-install/' \
 /etc/cloud/cloud.cfg

以下のようになる。

/etc/cloud/cloud.cfg
cloud_final_modules:
#- package-update-upgrade-install

OS起動ごとに毎回実行させたい場合

  • /etc/cloud/cloud.cfg.d/99_custom.cfg
/etc/cloud/cloud.cfg.d/99_custom.cfg
cloud_final_modules:
 - [ package-update-upgrade-install, always ]
  • OSを再起動し、毎回package-update-upgrade-installが実行されることを確認。

upgrade.png

1度だけの実行の場合

$ cloud-init-per -h
Usage: cloud-init-per frequency name cmd [ arg1 [ arg2 [ ... ] ]
   run cmd with arguments provided.

   This utility can make it easier to use boothooks or bootcmd
   on a per "once" or "always" basis.

   If frequency is:
      * once: run only once (do not re-run for new instance-id)
      * instance: run only the first boot for a given instance-id
      * always: run every boot
/etc/cloud/cloud.cfg.d/99_custom.cfg
cloud_final_modules:
 - [ package-update-upgrade-install, once ]
  • 設定してから次回OS再起動時は実行される。2回目以降は実行されない。

2.png

実行されていないことが確認できる。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1