Chapter 31

プレイブックをチェック : lint

y_mrok
y_mrok
2021.12.05に更新
このチャプターの目次

説明

この章の説明はこのリンクをクリックしてください。

演習問題

Q1. 自分自身の演習環境に ansible-lint をインストールしてください。

解答

インストールコマンド

pip3 install ansible-lint
ansible-lint --version

インストール時の実行ログ

y_mrok@ctrl:~$ pip3 install ansible-lint
Collecting ansible-lint
  Downloading ansible_lint-5.3.0-py3-none-any.whl (114 kB)
     |████████████████████████████████| 114 kB 4.7 MB/s 
Collecting tenacity
  Downloading tenacity-8.0.1-py3-none-any.whl (24 kB)
Collecting enrich>=1.2.6
  Downloading enrich-1.2.6-py3-none-any.whl (8.6 kB)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from ansible-lint) (5.3.1)
Requirement already satisfied: packaging in ./.local/lib/python3.8/site-packages (from ansible-lint) (21.0)
Collecting ruamel.yaml<1,>=0.15.37; python_version >= "3.7"
  Downloading ruamel.yaml-0.17.17-py3-none-any.whl (109 kB)
     |████████████████████████████████| 109 kB 47.9 MB/s 
Collecting rich>=9.5.1
  Downloading rich-10.15.2-py3-none-any.whl (214 kB)
     |████████████████████████████████| 214 kB 10.6 MB/s 
Collecting wcmatch>=7.0
  Downloading wcmatch-8.3-py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 2.6 MB/s 
Requirement already satisfied: pyparsing>=2.0.2 in ./.local/lib/python3.8/site-packages (from packaging->ansible-lint) (2.4.7)
Collecting ruamel.yaml.clib>=0.1.2; platform_python_implementation == "CPython" and python_version < "3.10"
  Downloading ruamel.yaml.clib-0.2.6-cp38-cp38-manylinux1_x86_64.whl (570 kB)
     |████████████████████████████████| 570 kB 12.6 MB/s 
Collecting commonmark<0.10.0,>=0.9.0
  Downloading commonmark-0.9.1-py2.py3-none-any.whl (51 kB)
     |████████████████████████████████| 51 kB 4.5 MB/s 
Collecting pygments<3.0.0,>=2.6.0
  Downloading Pygments-2.10.0-py3-none-any.whl (1.0 MB)
     |████████████████████████████████| 1.0 MB 19.6 MB/s 
Requirement already satisfied: colorama<0.5.0,>=0.4.0 in /usr/lib/python3/dist-packages (from rich>=9.5.1->ansible-lint) (0.4.3)
Collecting bracex>=2.1.1
  Downloading bracex-2.2.1-py3-none-any.whl (12 kB)
Installing collected packages: tenacity, commonmark, pygments, rich, enrich, ruamel.yaml.clib, ruamel.yaml, bracex, wcmatch, ansible-lint
Successfully installed ansible-lint-5.3.0 bracex-2.2.1 commonmark-0.9.1 enrich-1.2.6 pygments-2.10.0 rich-10.15.2 ruamel.yaml-0.17.17 ruamel.yaml.clib-0.2.6 tenacity-8.0.1 wcmatch-8.3
y_mrok@ctrl:~$ ansible-lint --version
ansible-lint 5.3.0 using ansible 2.12.0
y_mrok@ctrl:~$

Q2. 今まで作成したプレイブックを ansible-lint コマンドでチェックしてください。チェックした結果、指摘事項があればプレイブックを修正し、再度チェックしてください。