installing and configuring db

master
parent eb4c336583
commit 6c9fbf5983
  1. 6
      group_vars/all/vars.yml
  2. 2
      my.cnf
  3. 44
      tasks/shopware.yml

@ -1 +1,5 @@
username: YOUR_USERNAME
username: rpolito
shopware_root_username: root
shopware_root_pass: rootpass
shopware_db_username: shopware
shopware_db_pass: shopware_pw

@ -21,6 +21,6 @@
# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
#[client]
[client]
user=root
password=rootpass

@ -26,49 +26,29 @@
- name: update mariadb root user
mysql_user:
login_unix_socket: /var/run/mysqld/mysqld.sock
#login_host: "{{shopware_db_username}}"
login_user: "root"
login_password: "rootpass"
name: "{{shopware_db_username}}"
password: "{{shopware_db_pass}}"
login_user: "{{shopware_root_username}}"
login_password: "{{shopware_root_pass}}"
name: "{{shopware_root_username}}"
password: "{{shopware_root_pass}}"
check_implicit_admin: yes
state: present
- name: Restart service httpd, in all cases
ansible.builtin.service:
name: mariadb
state: restarted
- name: Make sure service is started and enabled
systemd:
name: mariadb
state: started
enabled: yes
- name: Delete all anonymous SQL user accounts
mysql_user:
user: ""
host_all: yes
state: absent
- name: Remove the SQL test database
mysql_db:
community.mysql.mysql_db:
db: "test"
state: absent
- name: Change root user password on first run
mysql_user:
login_user: root
login_password: ''
name: root
password: "{{ shopware_db_pass }}"
priv: "*.*:ALL,GRANT"
host: "{{ item }}"
with_items:
- "{{ ansible_hostname }}"
- "127.0.0.1"
- "::1"
- "localhost"
- name: Make sure user exists
shell:
cmd: "mysql -uroot -p{{ shopware_db_pass }} -e\"CREATE USER IF NOT EXISTS '{{ shopware_db_username }}'@'localhost' IDENTIFIED BY '{{ shopware_db_pass }}' REQUIRE SSL;\" -N -B"
register: result
config_file: /etc/mysql/my.cnf
- name: Create Database
become: yes
@ -80,6 +60,8 @@
- name: Create user with password, all database privileges and 'WITH GRANT OPTION' shopware database
become: yes
community.mysql.mysql_user:
login_user: "{{shopware_root_username}}"
login_password: "{{shopware_root_pass}}"
state: present
name: "{{shopware_db_username}}"
password: "{{shopware_db_pass}}"

Loading…
Cancel
Save