You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.3 KiB
79 lines
2.3 KiB
5 years ago
|
---
|
||
|
|
||
|
- name: Install needed packages
|
||
|
yum:
|
||
|
name:
|
||
|
- perl-DBD-MySQL
|
||
|
- MySQL-python
|
||
|
- mariadb
|
||
|
- perl-Apache-Session-Browseable
|
||
|
|
||
|
- import_tasks: ../includes/get_rand_pass.yml
|
||
|
vars:
|
||
|
- pass_file: "/etc/lemonldap-ng/ansible_dbpass"
|
||
|
when: llng_db_pass is not defined
|
||
|
- set_fact: llng_db_pass={{ rand_pass }}
|
||
|
when:
|
||
|
- llng_db_pass is not defined
|
||
|
- llng_manager or llng_portal
|
||
|
|
||
|
- import_tasks: ../includes/get_rand_pass.yml
|
||
|
vars:
|
||
|
- pass_file: "/etc/lemonldap-ng/ansible_handler_dbpass"
|
||
|
when: llng_handler_db_pass is not defined
|
||
|
- set_fact: llng_handler_db_pass={{ rand_pass }}
|
||
|
when: llng_handler_db_pass is not defined
|
||
|
|
||
|
- name: Create the database
|
||
|
mysql_db:
|
||
|
name: "{{ llng_db_name }}"
|
||
|
login_host: "{{ llng_db_server | default(mysql_server) }}"
|
||
|
login_user: sqladmin
|
||
|
login_password: "{{ mysql_admin_pass }}"
|
||
|
encoding: utf8mb4
|
||
|
collation: utf8mb4_general_ci
|
||
|
state: present
|
||
|
|
||
|
- name: Copy mysql schema
|
||
|
copy: src=mysql_schema.sql dest=/etc/lemonldap-ng/mysql_schema.sql
|
||
|
register: llng_schema
|
||
|
|
||
|
- name: Inject SQL structure
|
||
|
mysql_db:
|
||
|
name: "{{ llng_db_name }}"
|
||
|
state: import
|
||
|
target: /etc/lemonldap-ng/mysql_schema.sql
|
||
|
login_host: "{{ llng_db_server }}"
|
||
|
login_user: sqladmin
|
||
|
login_password: "{{ mysql_admin_pass }}"
|
||
|
when: llng_schema.changed
|
||
|
|
||
|
- name: Create the main user
|
||
|
mysql_user:
|
||
|
name: "{{ llng_db_user }}"
|
||
|
password: "{{ llng_db_pass }}"
|
||
|
priv: "{{ llng_db_name }}.*:ALL"
|
||
|
host: "{{ ( llng_db_server == 'localhost' ) | ternary('localhost', item ) }}"
|
||
|
login_host: "{{ llng_db_server }}"
|
||
|
login_user: sqladmin
|
||
|
login_password: "{{ mysql_admin_pass }}"
|
||
|
state: present
|
||
|
append_privs: True
|
||
|
when: llng_portal == True or llng_manager == True
|
||
|
with_items: "{{ ansible_all_ipv4_addresses }}"
|
||
|
|
||
|
- name: Create the handler user
|
||
|
mysql_user:
|
||
|
name: "{{ llng_handler_db_user }}"
|
||
|
password: "{{ llng_handler_db_pass }}"
|
||
|
priv: "{{ llng_db_name }}.sessions:SELECT,INSERT,DELETE,UPDATE/{{ llng_db_name }}.lmConfig:SELECT"
|
||
|
host: "{{ ( llng_db_server == 'localhost' ) | ternary('localhost', item ) }}"
|
||
|
login_host: "{{ llng_db_server }}"
|
||
|
login_user: sqladmin
|
||
|
login_password: "{{ mysql_admin_pass }}"
|
||
|
state: present
|
||
|
append_privs: True
|
||
|
when: llng_handler == True
|
||
|
with_items: "{{ ansible_all_ipv4_addresses }}"
|
||
|
|