0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntuでcloud-initを無効化する方法【Ansible対応】

0
Last updated at Posted at 2024-04-22

この記事で解決できること

Ubuntuサーバで不要なcloud-initを無効化し、起動時間の短縮とシステムのシンプル化を実現できます。ターミナルでの手動手順とAnsible Playbookの両方を紹介します。

Ubuntuサーバではcloud-initがデフォルトで有効です。しかし、Ansibleなど別のツールで構成管理をしているオンプレミス環境では、cloud-initは不要です。不要サービスの無効化はセキュリティとパフォーマンスの両面で有効です。

無効化の方法を選ぶ

cloud-init公式ドキュメントによると、無効化には2つの方法があります。

方法 概要 特徴
ファイル作成 /etc/cloud/cloud-init.disabled を作成 シンプルで他の設定と衝突しにくい
カーネル引数 cloud-init=disabled を渡す ブートローダーの設定変更が必要

ファイル作成による方法が手軽で安全なため、こちらを推奨します。

ファイル作成でcloud-initを無効化する

ターミナルで実行する場合

sudo touch /etc/cloud/cloud-init.disabled

Ansibleで実行する場合

- name: Create /etc/cloud/cloud-init.disabled
  ansible.builtin.file:
    path: /etc/cloud/cloud-init.disabled
    state: touch
    access_time: preserve
    modification_time: preserve
  become: true

まとめ

  • /etc/cloud/cloud-init.disabled を作成するだけでcloud-initを無効化できる
  • カーネル引数を変更する方法もあるが、ファイル作成のほうがシンプルで安全
  • Ansibleの ansible.builtin.file モジュールで冪等に管理できる
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?