From 8f3f1a48a651aa72c9072a7035410e1bc07539ec Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Wed, 4 Oct 2023 18:18:16 +0530 Subject: [PATCH] refactor(treewide): use `mariadb` commands and service instead of `mysql` Signed-off-by: Akhil Narang --- bench/commands/install.py | 7 ++++--- bench/commands/setup.py | 2 +- bench/playbooks/roles/mariadb/README.md | 4 ++-- bench/playbooks/roles/mariadb/handlers/main.yml | 4 ++-- bench/playbooks/roles/mariadb/tasks/main.yml | 6 +++--- .../roles/mariadb/tasks/mysql_secure_installation.yml | 10 +++++----- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/bench/commands/install.py b/bench/commands/install.py index e86e94296..31ad59b66 100644 --- a/bench/commands/install.py +++ b/bench/commands/install.py @@ -25,9 +25,10 @@ def install_prerequisites(): @click.command( "mariadb", help="Install and setup MariaDB of specified version and root password" ) -@click.option("--mysql_root_password", "--mysql-root-password", default="") +@click.option("--mysql_root_password", "--mysql-root-password", + "--mariadb_root_password", "--mariadb-root-password", default="") @click.option("--version", default="10.3") -def install_maridb(mysql_root_password, version): +def install_mariadb(mysql_root_password, version): if mysql_root_password: extra_vars.update( { @@ -111,7 +112,7 @@ def install_failtoban(**kwargs): install.add_command(install_prerequisites) -install.add_command(install_maridb) +install.add_command(install_mariadb) install.add_command(install_wkhtmltopdf) install.add_command(install_nodejs) install.add_command(install_psutil) diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 999f8dbd3..9b13c269a 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -358,7 +358,7 @@ def sync_domains(domain=None, site=None): @click.command("role", help="Install dependencies via ansible roles") @click.argument("role") @click.option("--admin_emails", default="") -@click.option("--mysql_root_password") +@click.option("--mysql_root_password", "--mariadb_root_password") @click.option("--container", is_flag=True, default=False) def setup_roles(role, **kwargs): extra_vars = {"production": True} diff --git a/bench/playbooks/roles/mariadb/README.md b/bench/playbooks/roles/mariadb/README.md index 72e423821..ad869194d 100644 --- a/bench/playbooks/roles/mariadb/README.md +++ b/bench/playbooks/roles/mariadb/README.md @@ -13,7 +13,7 @@ Debain 9 ## Post install -Run `mysql_secure_installation` +Run `mariadb-secure-installation` ## Requirements @@ -39,7 +39,7 @@ Configuration filename: mysql_conf_file: settings.cnf ``` -### Experimental unattended mysql_secure_installation +### Experimental unattended mariadb-secure-installation ``` ansible-playbook release.yml --extra-vars "mysql_secure_installation=true mysql_root_password=your_very_secret_password" diff --git a/bench/playbooks/roles/mariadb/handlers/main.yml b/bench/playbooks/roles/mariadb/handlers/main.yml index 3755d8ceb..6f737d913 100644 --- a/bench/playbooks/roles/mariadb/handlers/main.yml +++ b/bench/playbooks/roles/mariadb/handlers/main.yml @@ -1,3 +1,3 @@ --- -- name: restart mysql - service: name=mysql state=restarted +- name: restart mariadb + service: name=mariadb state=restarted diff --git a/bench/playbooks/roles/mariadb/tasks/main.yml b/bench/playbooks/roles/mariadb/tasks/main.yml index 8079583df..b4e145ad1 100644 --- a/bench/playbooks/roles/mariadb/tasks/main.yml +++ b/bench/playbooks/roles/mariadb/tasks/main.yml @@ -16,7 +16,7 @@ group: root mode: 0644 when: mysql_conf_tpl != 'change_me' and ansible_distribution != 'Debian' - notify: restart mysql + notify: restart mariadb - include_tasks: debian.yml when: ansible_distribution == 'Debian' @@ -29,7 +29,7 @@ group: root mode: 0644 when: mysql_conf_tpl != 'change_me' and ansible_distribution == 'Debian' - notify: restart mysql + notify: restart mariadb - name: Add additional conf for MariaDB 10.2 in mariadb.conf.d blockinfile: @@ -59,7 +59,7 @@ - name: Start and enable service service: - name: mysql + name: mariadb state: started enabled: yes diff --git a/bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml b/bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml index 4265375e0..032918740 100644 --- a/bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml +++ b/bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml @@ -19,28 +19,28 @@ - ::1 - name: Reload privilege tables - command: 'mysql -ne "{{ item }}"' + command: 'mariadb -ne "{{ item }}"' with_items: - FLUSH PRIVILEGES changed_when: False when: run_travis is not defined - name: Remove anonymous users - command: 'mysql -ne "{{ item }}"' + command: 'mariadb -ne "{{ item }}"' with_items: - DELETE FROM mysql.user WHERE User='' changed_when: False when: run_travis is not defined - name: Disallow root login remotely - command: 'mysql -ne "{{ item }}"' + command: 'mariadb -ne "{{ item }}"' with_items: - DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1') changed_when: False when: run_travis is not defined - name: Remove test database and access to it - command: 'mysql -ne "{{ item }}"' + command: 'mariadb -ne "{{ item }}"' with_items: - DROP DATABASE IF EXISTS test - DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%' @@ -48,7 +48,7 @@ when: run_travis is not defined - name: Reload privilege tables - command: 'mysql -ne "{{ item }}"' + command: 'mariadb -ne "{{ item }}"' with_items: - FLUSH PRIVILEGES changed_when: False