|
| 1 | +--- |
| 2 | + |
| 3 | +- name: Check Database Credentials |
| 4 | + ansible.builtin.assert: |
| 5 | + that: |
| 6 | + - icingaweb2_db['user'] is defined |
| 7 | + - icingaweb2_db['password'] is defined |
| 8 | + fail_msg: "No database credentials defined. Please set icingaweb2_db.<user|password> or a privileged user with icingaweb2_priv_db_<user|password>" |
| 9 | + when: icingaweb2_priv_db_password is undefined and icingaweb2_priv_db_user is undefined |
| 10 | + |
| 11 | +- name: Set db user with admin privileges |
| 12 | + ansible.builtin.set_fact: |
| 13 | + _priv_db_user: "{{ icingaweb2_priv_db_user }}" |
| 14 | + _priv_db_pass: "{{ icingaweb2_priv_db_password }}" |
| 15 | + when: icingaweb2_priv_db_password is defined and icingaweb2_priv_db_user is defined |
| 16 | + |
| 17 | +- name: Build mysql command |
| 18 | + ansible.builtin.set_fact: |
| 19 | + _tmp_mysqlcmd: >- |
| 20 | + mysql {% if icingaweb2_db['host'] | default('localhost') != 'localhost' %} -h "{{ icingaweb2_db['host'] }}" {%- endif %} |
| 21 | + {% if icingaweb2_db['port'] is defined %} -P "{{ icingaweb2_db['port'] }}" {%- endif %} |
| 22 | + {% if icingaweb2_db['ssl_mode'] is defined %} --ssl-mode "{{ icingaweb2_db['ssl_mode'] }}" {%- endif %} |
| 23 | + {% if icingaweb2_db['ssl_ca'] is defined %} --ssl-ca "{{ icingaweb2_db['ssl_ca'] }}" {%- endif %} |
| 24 | + {% if icingaweb2_db['ssl_cert'] is defined %} --ssl-cert "{{ icingaweb2_db['ssl_cert'] }}" {%- endif %} |
| 25 | + {% if icingaweb2_db['ssl_key'] is defined %} --ssl-key "{{ icingaweb2_db['ssl_key'] }}" {%- endif %} |
| 26 | + {% if icingaweb2_db['ssl_cipher'] is defined %} --ssl-cipher "{{ icingaweb2_db['ssl_cipher'] }}" {%- endif %} |
| 27 | + {% if icingaweb2_db['ssl_extra_options'] is defined %} {{ icingaweb2_db['ssl_extra_options'] }} {%- endif %} |
| 28 | + -u "{{ icingaweb2_priv_db_user | default(icingaweb2_db['user']) }}" |
| 29 | + -p"{{ icingaweb2_priv_db_password | default(icingaweb2_db['password']) }}" |
| 30 | + "{{ icingaweb2_db['name'] }}" |
0 commit comments