LoginSignup
10
9

More than 5 years have passed since last update.

[Ansible] Ansibleで管理している旨をテンプレートで生成したファイルのコメントに埋め込む

Last updated at Posted at 2013-08-09

templateモジュールのドキュメントに書かれていますが、テンプレートファイル内に{{ ansible_managed }}と書いておくと、このファイルはAnsibleで管理しているよ(だから手でいじらないでね)という旨の文字列に展開されます。

# でコメントになるファイルの場合はテンプレートファイル(*.j2)内に以下のように書いておきます。

# {{ ansible_managed }}

epelで入れたAnsible 1.2.2の/etc/ansible/ansible.cfgに入っているデフォルトの設定は以下のとおりです。

# format of string $ansible_managed available within Jinja2 templates, replacing
# {file}, {host} and {uid} with template filename, host and owner respectively.
# The resulting string is passed through strftime(3) so it may contain any
# time-formatting specifiers.
#
# Example: ansible_managed = DONT TOUCH {file}: call {uid} at {host} for changes
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
10
9
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
10
9