Ansible/Vagrantでアドテク環境を最速構築
- 21. ignore_errors: yesを使う
- name: password
shell: cat /root/.mysql_secret | awk '{ print $NF }'
register: mysql_passwd
- name: check MySQL root password
shell: mysqlshow -uroot -p{{ mysql_passwd.stdout }}
register: root_check
ignore_errors: yes
- name: set MySQL root password
command: |
mysql --connect-expired-password -uroot -p{{ mysql_passwd.stdout }} -e
"set password for root@'{{ item }}' = PASSWORD('{{mysql_root_passwd}}')"
creates=/root/.my.cnf
with_items:
- localhost
when: root_check.stderr.find('deniend') != -1 or root_check.stderr.find('expired.') != -1