diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml index 0327d2a..3467b4d 100644 --- a/roles/mariadb/tasks/main.yml +++ b/roles/mariadb/tasks/main.yml @@ -4,6 +4,7 @@ pacman: name: - mariadb + - python-pymysql when: ansible_distribution == 'Archlinux' - name: Install mariadb (Debian) @@ -11,6 +12,7 @@ apt: name: - mariadb + - python3-pymysql when: ansible_distribution == 'Debian' - name: Initialize mariadb @@ -21,10 +23,24 @@ notify: Start mysqld service - name: Secure the installation - # TODO: This won't work because it is interactive. - # https://stackoverflow.com/questions/25136498/ansible-answers-to-mysql-secure-installation#25140114 become: true - command: mysql_secure_installation + block: + - name: Set root password + mysql_user: user=root password="" host=localhost + no_log: yes + - name: Remove anonymous user for ansible_fqdn + mysql_user: user="" host={{ ansible_fqdn }} state=absent + - name: Remove anonymous user for localhost + mysql_user: user="" state=absent + - name: Remove remote root access + mysql_user: user=root password="" host={{ item }} + no_log: yes + with_items: + - "::1" + - "127.0.0.1" + - localhost + - name: Remove test database + mysql_db: db=test state=absent when: "'table already exists!' not in result.stdout" - name: Stop mysqld service