LoginSignup
0
0

More than 1 year has passed since last update.

【ルール説明・basic】deprecated-bare-vars

Posted at

こちらの記事はAnsible lint Advent Calendar 2022 カレンダー2 1日目の記事になります。

今回はルールdeprecated-bare-varsについて説明します。

deprecated-bare-vars

deprecated-bare-vars はタスクで変数を利用する際に適切な形式で指定されているか検証します。bareとは英語で覆いがない、むき出しになったと言う意味です。Ansible では変数は"{{ }}"で囲うのが標準です。

問題のあるコード

---
- ansible.builtin.debug:
    msg: "{{ item }}"
  with_items: foo # <-- 変数が旧式の形式で指定されている

修正されたコードその1

fooが変数でない場合は文字列として扱う

---
- ansible.builtin.debug:
    msg: "{{ item }}"
  with_items:
    - foo

修正されたコードその2

fooが変数の場合は"{{ }}"で囲う

- ansible.builtin.debug:
    msg: "{{ item }}"
  with_items: "{{ foo }}"

参考サイト

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