LoginSignup
0
0

More than 1 year has passed since last update.

【ルール説明・basic】literal-compare

Posted at

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

今回はルール literal-compare について説明します。

literal-compare

literal-comparewhen句で条件を指定する時に必要以上に複雑な記述がされていないか検証します。

問題のあるコード

---
- name: Example playbook
  hosts: all
  tasks:
    - name: Print environment variable to stdout
      ansible.builtin.command: echo $MY_ENV_VAR
      when: ansible_os_family == True # <- 条件の記述が複雑になっている

修正されたコード

---
- name: Example playbook
  hosts: all
  tasks:
    - name: Print environment variable to stdout
      ansible.builtin.command: echo $MY_ENV_VAR
      when: ansible_os_family # <- 条件は簡潔に記述する

参考サイト

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