環境
# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=15.04 DISTRIB_CODENAME=vivid DISTRIB_DESCRIPTION="Ubuntu 15.04"
# arch x86_64
# ansible --version ansible 2.0.2.0 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides
事象
上記の環境でansible-playbookを回した場合に下記のように怒られた
[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default). This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
公式ドキュメントを読むと、1.9系からはsudoじゃなくてbecomeを使ってねとのこと。
Become (Privilege Escalation) — Ansible Documentation
対処方法
playbook内のsudoをbecomeにする
- sudo: yes + become: yes
と変更すれば、すんなり通る。
もしくはsudo無しで実行してしまう。
個人的には最初の構築はrootで行ない、
構築後の変更(deploy等)はbecomeで行うように用途を分けているのだけれど
そもそも絶対にbecome(sudo)でしか実行出来ない用途が思いつかないので
無しでいいと思ってしまった。