LoginSignup
0
0

More than 1 year has passed since last update.

Ansible lintのタグ

Last updated at Posted at 2022-12-02

こちらの記事はAnsible lint Advent Calendar 2022 3日目の記事になります。

Ansible lintのルールには2つの大分類があります。タグProfileです。今回はタグについて説明します。

タグ一覧

ansible-lint --list-tagsで表示されます。

  • command-shell
  • core
  • deprecations
  • experimental
  • formatting
  • idempotency
  • idiom
  • metadata
  • opt-in
  • risk
  • security
  • syntax
  • unpredictability
  • unskippable
  • yaml
ansible-lint --list-tags

# List of tags and rules they cover
command-shell:  # Specific to use of command and shell modules
  - command-instead-of-module
  - command-instead-of-shell
  - deprecated-command-syntax
  - inline-env-var
  - no-changed-when
  - risky-shell-pipe
core:  # Related to internal implementation of the linter
  - internal-error
  - load-failure
  - parser-error
  - syntax-check
  - warning
  - schema
deprecations:  # Indicate use of features that are removed from Ansible
  - deprecated-bare-vars
  - deprecated-command-syntax
  - deprecated-local-action
  - deprecated-module
  - no-jinja-when
  - role-name
experimental:  # Newly introduced rules, by default triggering only warnings
  - warning
  - avoid-implicit
  - galaxy
  - ignore-errors
  - key-order
  - no-free-form
  - no-log-password
  - no-prompting
  - only-builtins
  - risky-file-permissions
  - run-once
  - schema
  - var-naming
formatting:  # Related to code-style
  - yaml
  - fqcn
  - jinja
  - key-order
  - no-tabs
  - playbook-extension
  - risky-octal
idempotency:  # Possible indication that consequent runs would produce different results
  - latest
  - no-changed-when
  - package-latest
idiom:  # Anti-pattern detected, likely to cause undesired behavior
  - command-instead-of-module
  - command-instead-of-shell
  - empty-string-compare
  - inline-env-var
  - literal-compare
  - loop-var-prefix
  - name
  - no-handler
  - no-relative-paths
  - run-once
  - var-naming
metadata:  # Invalid metadata, likely related to galaxy, collections or roles
  - galaxy
  - meta-incorrect
  - meta-no-info
  - meta-no-tags
  - meta-video-links
  - role-name
opt-in:  # Rules that are not used unless manually added to `enable_list`
  - empty-string-compare
  - galaxy
  - no-log-password
  - no-prompting
  - no-same-owner
  - only-builtins
risk:
  - no-free-form
security:  # Rules related o potentially security issues, like exposing credentials
  - no-log-password
syntax:
  - no-free-form
unpredictability:  # Warn about code that might not work in a predictable way
  - avoid-implicit
  - ignore-errors
  - partial-become
  - risky-file-permissions
unskippable:  # Indicate a fatal error that cannot be ignored or disabled
  - load-failure
yaml:  # External linter which will also produce its own rule codes
  - yaml

command-shell

ansible.builtin.shellモジュールおよびansible.builtin.commandモジュールが利用される際にベストプラクティスに準じて処理が記述されているか検査します。

core

Ansible lintの内部的な処理に利用されるルールです。

deprecations

PlaybookやRoleの書き方が古い形式だったりAnsible coreもしくはAnsible communityで非推奨のModuleが利用されていないか等を検査します。

experimental

導入時期が比較的新しいルールです。これらのルールで違反が見つかった場合は初期設定ではエラーではなくwarningを出力します。

formatting

Ansible lintが基準と考えるコーディング規約に沿って記述されているか検査します。

idempotency

PlaybookやRoleを実行した際に冪等性が保証されないような記述があるか検査します。

idiom

意図しない動作や副作用が起こるような記述があるか検査します。

metadata

galaxy collectionとroleのメタデータファイルの記述に違反がないかチェックします。

opt-in

初期設定では無効になっているルールです。Ansible lintの設定ファイルでenable_listで設定すると有効になります。

risk

主にansible.builtin.commandモジュールやansible.builtin.rawモジュールで副作用が起きそうな記述がないか検査します。

security

Ansible実行時にパスワード等の秘匿情報がログに出力されないか検査します。Ansibleのログについては「Ansible 出力のロギング — Ansible Documentation」を参照してみてください。

syntax

説明なし

unpredictability

記述された処理が意図した通りに実行されない可能性がある場合に警告を出します。

unskippable

Ansible lintがファイルを検査できない時に出力されれます。検査できない主な原因は

  • ファイルのエンコーディングエラー(Ansible lintはUTF-8のみ扱える)
  • Ansibleがサポートする形式のファイルではない
  • YAMLファイルではない
  • ファイルにAnsible vaultで解読できない記述が含まれている

などが考えらます。

yaml

Playbookやrole等がyamllintで設定した形式で記述されているか検査します。

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