DebianのAnsibleにMySQLを入れる

DebianにAnsibleを使って単に apt: pkg=mysql-server state=latest とかすると、 root でログインできなくなる。

debconf を使うと初期パスワードが設定できるのでそれを使ってからインストールする。

- name: MySQL | Set debconf vars
  raw: echo mysql-server mysql-server/root_password password $mysql_root_password | /usr/bin/debconf-set-selections
- name: MySQL | Set debconf vars
  raw: echo mysql-server mysql-server/root_password_again password $mysql_root_password | /usr/bin/debconf-set-selections

英語で探すとすぐ出てきたけど日本語ではあんまりなかったので。