Ansible1.9以降はsudo,suは非推奨でbecome推奨


上記記事がとてもわかり易かった。
確かにsudoで別ユーザで実行することもできるけどデフォルトはroot権限で実行だからね。

インターネット上に溢れるPlaybookではsudoディレクティブを使っている物をたくさん見かけたので疑問だったが疑問が解消した。
ちなみに、古いPlaybookをそのまま使用する際も修正をしなくても動くという記載が公式ドキュメントにあった。(まあ非推奨ってだけだしね)

For those from Pre 1.9 , sudo and su still work!

For those using old playbooks will not need to be changed, even though they are deprecated, sudo and su directives, variables and options will continue to work. It is recommended to move to become as they may be retired at one point. You cannot mix directives on the same object (become and sudo) though, Ansible will complain if you try to.

Become will default to using the old sudo/su configs and variables if they exist, but will override them if you specify any of the new ones.

http://docs.ansible.com/ansible/become.html#for-those-from-pre-1-9-sudo-and-su-still-work

簡単に意訳してみると
1.9より古いプレイブックで使われているsudoとsuはまだ動作するよ!
古いプレイブックで使われているsudoとsuディレクティブは変更する必要はない。
ただ変更することをオススメする。
あなたがbecomeとsudoを同時に使用した場合ansibleは文句を言うだろう。

becomeはデフォルトでsudo/suの設定、変数を使用するけど新しく設定した場合はそれを上書きするよ。

初めてのAnsible

初めてのAnsible

Amazon