From b03a5682983a72188e44dba8bd9844a92aacfb9f Mon Sep 17 00:00:00 2001 From: LinuxSquare Date: Sun, 1 Dec 2024 20:38:05 +0100 Subject: [PATCH] fix test statements --- mysql/secure.ansible.yml | 10 +++++----- mysql/service.ansible.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) 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