diff --git a/mysql/secure.ansible.yml b/mysql/secure.ansible.yml index 452c9cc..8f42505 100644 --- a/mysql/secure.ansible.yml +++ b/mysql/secure.ansible.yml @@ -1,9 +1,9 @@ - hosts: localhost tasks: - name: Test if mysql has been secured - shell: | - test -f /var/lib/mysql/.secured - register: MYSQL_SECURED + stat: + path: /var/lib/mysql/.secured + register: MYSQL_SECURED_RESULT ignore_errors: true - name: mysql_secure_installation mysql_secure_installation: @@ -16,7 +16,7 @@ remove_anonymous_user: true disallow_root_login_remotely: true remove_test_db: true - when: not MYSQL_SECURED + when: not MYSQL_SECURED_RESULT.stat.exists - name: Create .secured lock file file: state: file @@ -25,4 +25,4 @@ group: root mode: '0600' attr: "+i" - when: not MYSQL_SECURED + when: not MYSQL_SECURED_RESULT.stat.exists diff --git a/mysql/service.ansible.yml b/mysql/service.ansible.yml index f91fb4f..740b09f 100644 --- a/mysql/service.ansible.yml +++ b/mysql/service.ansible.yml @@ -1,14 +1,14 @@ - hosts: localhost tasks: - name: Test if directory exists - shell: | - test -d /var/lib/mysql/mysql - register: MYSQL_DIRECTORY_EXISTS + stat: + path: /var/lib/mysql/mysql + register: MYSQL_DIRECTORY_RESULT ignore_errors: true - name: MariaDB setup shell: | /etc/init.d/mariadb setup - when: not MYSQL_DIRECTORY_EXISTS + when: not MYSQL_DIRECTORY_RESULT.stat.exists - name: Enable mariadb service service: name: mariadb