Skip to content

Commit

Permalink
refactor(treewide): use mariadb commands and service instead of `my…
Browse files Browse the repository at this point in the history
…sql`

Signed-off-by: Akhil Narang <[email protected]>
  • Loading branch information
akhilnarang committed Oct 10, 2023
1 parent 57937a3 commit 9a9252e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
7 changes: 4 additions & 3 deletions bench/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "--mysql-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(
{
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bench/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions bench/playbooks/roles/mariadb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Debain 9

## Post install

Run `mysql_secure_installation`
Run `mariadb-secure-installation`

## Requirements

Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions bench/playbooks/roles/mariadb/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
- name: restart mysql
service: name=mysql state=restarted
- name: restart mariadb
service: name=mariadb state=restarted
6 changes: 3 additions & 3 deletions bench/playbooks/roles/mariadb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand Down Expand Up @@ -59,7 +59,7 @@

- name: Start and enable service
service:
name: mysql
name: mariadb
state: started
enabled: yes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@
- ::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\\_%'
changed_when: False
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
Expand Down

0 comments on commit 9a9252e

Please sign in to comment.