From 8dbf7e2d9e11e395a23fb1a3a5c87b380199380d Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Fri, 7 Jan 2022 11:03:11 +0100 Subject: [PATCH] mise au point rajout tache creation bdd --- README.md | 6 ++++++ defaults/main.yml | 1 + tasks/db.yml | 15 +++++++++++++++ tasks/main.yml | 7 ++++++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tasks/db.yml diff --git a/README.md b/README.md index 81ee224..7fe7c74 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ apache_user: {{ apache_server_name | regex_search( '([^.]+)' ) }} }} apache_allowoverride: all apache_update_conf: true - wether we override existing config file apache_ssl_root_email: email used for letsencrypt certificate +apache_use_database: false +apache_db_name: no default +apache_db_user: no default +apache_db_password: no default +apache_db_login_user: from root/.my.cnf +apache_db_login_password: from my.cnf Example Playbook ---------------- diff --git a/defaults/main.yml b/defaults/main.yml index a99c977..ee2a69d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,3 +17,4 @@ apache_use_stats: true apache_use_zabbix: true apache_user: "{{ apache_server_name | regex_search( '([^.]+)' ) }}" apache_update_conf: true +apache_use_database: false diff --git a/tasks/db.yml b/tasks/db.yml new file mode 100644 index 0000000..88efbf0 --- /dev/null +++ b/tasks/db.yml @@ -0,0 +1,15 @@ +--- + +- name: create database + community.mysql.mysql_db: + login_user: root + name: "{{ apache_db_name }}" + state: present + +- name: create db user + community.mysql.mysql_user: + name: "{{ apache_db_user }}" + password: "{{ apache_db_password }}" + update_password: on_create + priv: "{{ apache_db_name }}.*:ALL" + state: present diff --git a/tasks/main.yml b/tasks/main.yml index 2243aa8..0791d86 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -75,4 +75,9 @@ - name: zabbix setup import_tasks: zabbix.yml when: apache_use_zabbix|bool - tags: zabbix, ssl \ No newline at end of file + tags: zabbix, ssl + +- name: db setup + import_tasks: db.yml + when: apache_use_database + tags: db \ No newline at end of file