ansible は式をキャッシュできなくてだいぶつらい。
たとえば role 内で利用する変数 foo_project_root_dir があったとして複数のテンプレートファイルで `{{ foo_project_root_dir }}/hogedb/config` のような文字列を使いたいので共通の名前を付けて `{{ foo_hogeb_config_dir }}` のように書きたいわけだけど、 role 内で定義した変数は何であれユーザが上書きできてしまうので意図せぬ値に設定されるおそれがある
外から干渉されないローカル変数さえ簡単に作れないのにモジュール化が何だって?
Using Variables — Ansible Documentation
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#understanding-variable-precedence
「17. task vars (only for the task)」よりも「20. role (and include_role) params」とか「22. extra vars (for example, `-e "user=my_user"`)」とかが優先されるように読めるけど、勘弁してくれとなっています
根本的には、 role にインターフェースという概念がないゆえに斯様なことが起きる
こういう類のファイルで DRY できなかったら安心してリファクタリングや変更もできやしない
Using Variables — Ansible Documentation
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#creating-valid-variable-names
> Variable names can begin with an underscore. In many programming languages, variables that begin with an underscore are private. This is not true in Ansible. Variables that begin with an underscore are treated exactly the same as any other variable. Do not rely on this convention for privacy or security.
この際もうアンダースコアで始めるか……
よくよく考えたら ansible の実装言語であるところの Python 自体がこんな感じやんけ、エコシステム全体でこうなのか