{"canonical_url":"https://engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/","content_markdown":"# Ansibleチェックモードを実態に即した検証に\n\nAnsibleのcommandモジュールが--checkでコマンドを省略しながら成功を返すため、ホストから得ていない値で判断していた6個の検査を修正し、プラットフォーム全体のチェックモードが実態を伝えるようにした。\n\n9月 2026\n\n**状況.** 本番への試行実行は、変更の効果を安全に知る方法のはずだった。2026年9月、実際のホストについて誤った検証で失敗し、安全なサンドボックスを緩めるフラグを勧めた。ホストを読んだのでなく、返されていない値を読み、結論を出していた。\n\n**課題.** 判断に使うすべての検査をチェックモードでも正直にし、できないものは黙るのでなく、その事実を知らせる必要があった。\n\n**行動.** 文書化されながら忘れやすい性質が原因だった。commandはチェックモードで実行されず、空の結果でなく、出力が空の成功を登録する。条件式は未測定の値で、そのロジックの向くほうへ判断してしまう。登録済み検査をすべて調べると6件あり、監督プロセスへ尋ねず全設定を許すとしたもの、ファイアウォール停止中なのに作業なしとしたものなど、別々の誤報をしていた。それぞれを2形態のいずれかにした。未変更の既存状態を読む検査はチェックモードでも実行し、実行不能なら省略して何を検証しなかったか明示する。ログの沈黙は合格と同じに読まれるためだった。\n\n**結果.** 試行は測るか、測らなかったと言うかになり、以前の第3の状態はなくなった。同時に開発指針へ、チェックモードは嘘をつかず、見えない検査はそれを知らせ、見えないことから判定を推定してはならないと記した。\n\n---\n\n- 役割: インフラ自動化エンジニア\n- カテゴリー: [DevOps](https://platform.engineer.company/ja/categories/devops/), [インフラ](https://platform.engineer.company/ja/categories/infrastructure/), [自動化・CI/CD](https://platform.engineer.company/ja/categories/automation/), [信頼性・バックアップ](https://platform.engineer.company/ja/categories/reliability/), [Linux・サーバー](https://platform.engineer.company/ja/categories/linux/), [テスト・品質保証](https://platform.engineer.company/ja/categories/testing/)\n- サービス: [コードによるインフラ管理](https://platform.engineer.company/ja/services/infrastructure-as-code/), [DevOps・CI/CD自動化](https://platform.engineer.company/ja/services/devops-cicd/), [サイト信頼性・監視](https://platform.engineer.company/ja/services/site-reliability/)\n\n\u003chttps://engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/\u003e\n","date_modified":"2026-11-09T21:50:25Z","description":"試行は測るか、測らなかったと言うかになり、以前の第3の状態はなくなった。同時に開発指針へ、チェックモードは嘘をつかず、見えない検査はそれを知らせ、見えないことから判定を推定してはならないと記した。","formats":{"gemtext":"https://platform.engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/index.gmi","gopher":"https://platform.engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/gophermap","html":"https://platform.engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/","json":"https://platform.engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/index.json","markdown":"https://platform.engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/index.md","pdf":"https://platform.engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/index.pdf"},"kind":"page","language":"ja","title":"Ansibleチェックモードを実態に即した検証に","url":"https://platform.engineer.company/ja/portfolio/made-ansible-check-mode-tell-the-truth/","version":1}