|
21 | 21 | - sni |
22 | 22 |
|
23 | 23 | - name: Module x509 | Manage Schema |
| 24 | + when: vars['icingaweb2_modules'][_module]['database']['import_schema'] | default(false) |
| 25 | + vars: |
| 26 | + _module: "{{ item.key }}" |
24 | 27 | block: |
25 | 28 | - name: Module x509 | Prepare _db informations |
26 | 29 | ansible.builtin.set_fact: |
27 | 30 | _db: |
28 | | - host: "{{ icingaweb2_modules[_module].database.host | default('localhost') }}" |
29 | | - port: "{{ icingaweb2_modules[_module].database.port | default('3306') }}" |
30 | | - user: "{{ icingaweb2_modules[_module].database.user | default('x509') }}" |
31 | | - password: "{{ icingaweb2_modules[_module].database.password | default(omit) }}" |
32 | | - name: "{{ icingaweb2_modules[_module].database.name | default('x509') }}" |
33 | | - ssl_mode: "{{ icingaweb2_modules[_module].database.ssl_mode | default(omit) }}" |
34 | | - ssl_ca: "{{ icingaweb2_modules[_module].database.ssl_ca | default(omit) }}" |
35 | | - ssl_cert: "{{ icingaweb2_modules[_module].database.ssl_cert | default(omit) }}" |
36 | | - ssl_key: "{{ icingaweb2_modules[_module].database.ssl_key | default(omit) }}" |
37 | | - ssl_cipher: "{{ icingaweb2_modules[_module].database.ssl_cipher | default(omit) }}" |
38 | | - ssl_extra_options: "{{ icingaweb2_modules[_module].database.ssl_extra_options | default(omit) }}" |
39 | | - schema_path: /usr/share/icingaweb2/modules/x509/schema/mysql.schema.sql |
| 31 | + host: "{{ vars['icingaweb2_modules'][_module]['database']['host'] | default('localhost') }}" |
| 32 | + port: "{{ vars['icingaweb2_modules'][_module]['database']['port'] | default('3306') }}" |
| 33 | + user: "{{ vars['icingaweb2_modules'][_module]['database']['user'] | default('x509') }}" |
| 34 | + password: "{{ vars['icingaweb2_modules'][_module]['database']['password'] | default(omit) }}" |
| 35 | + name: "{{ vars['icingaweb2_modules'][_module]['database']['name'] | default('x509') }}" |
| 36 | + ssl_mode: "{{ vars['icingaweb2_modules'][_module]['database']['ssl_mode'] | default(omit) }}" |
| 37 | + ssl_ca: "{{ vars['icingaweb2_modules'][_module]['database']['ssl_ca'] | default(omit) }}" |
| 38 | + ssl_cert: "{{ vars['icingaweb2_modules'][_module]['database']['ssl_cert'] | default(omit) }}" |
| 39 | + ssl_key: "{{ vars['icingaweb2_modules'][_module]['database']['ssl_key'] | default(omit) }}" |
| 40 | + ssl_cipher: "{{ vars['icingaweb2_modules'][_module]['database']['ssl_cipher'] | default(omit) }}" |
| 41 | + ssl_extra_options: "{{ vars['icingaweb2_modules'][_module]['database']['ssl_extra_options'] | default(omit) }}" |
| 42 | + schema_path_mysql: /usr/share/icingaweb2/modules/x509/schema/mysql.schema.sql |
| 43 | + schema_path_pgsql: /usr/share/icingaweb2/modules/x509/schema/pgsql.schema.sql |
40 | 44 | select_query: "select * from x509_certificate" |
41 | | - when: icingaweb2_modules[_module].database.type | default('mysql') == 'mysql' |
| 45 | + type: "{{ vars['icingaweb2_modules'][_module]['database']['type'] | default(omit) }}" |
| 46 | + |
| 47 | + - ansible.builtin.fail: |
| 48 | + fail_msg: No database type was provided |
| 49 | + when: vars['icingaweb2_modules'][_module]['database']['type'] is not defined |
42 | 50 |
|
43 | 51 | - ansible.builtin.fail: |
44 | | - fail_msg: "The Database type select is not supported, {{ icingaweb2_modules[_module].database.type }} [Supported=mysql]" |
45 | | - when: vars['icingaweb2_modules'][_module]['database']['type'] is defined and icingaweb2_modules[_module].database.type != 'mysql' |
| 52 | + fail_msg: "Invalid database type was provided. [Supported: mysql, pgsql]" |
| 53 | + when: _db.type not in ['mysql', 'pgsql'] |
46 | 54 |
|
47 | | - - name: Module x509 | Import Schema |
| 55 | + - name: Module x509 | Import MySQL Schema |
48 | 56 | ansible.builtin.include_tasks: ../manage_mysql_imports.yml |
| 57 | + when: _db.type == 'mysql' |
| 58 | + |
| 59 | + - name: Module x509 | Import PostgresQL Schema |
| 60 | + ansible.builtin.include_tasks: ../manage_pgsql_imports.yml |
| 61 | + when: _db.type == 'pgsql' |
49 | 62 |
|
50 | 63 | - name: Module x509 | empty _db var |
51 | 64 | ansible.builtin.set_fact: |
52 | 65 | _db: {} |
53 | | - when: icingaweb2_modules[_module].database.import_schema | default(false) |
54 | | - vars: |
55 | | - _module: "{{ item.key }}" |
56 | 66 |
|
57 | 67 | - name: Module x509 | Import Certificates |
58 | 68 | ansible.builtin.shell: > |
59 | 69 | icingacli {{ _module }} import --file {{ _file }} |
60 | | - loop: "{{ icingaweb2_modules[_module].certificate_files }}" |
| 70 | + loop: "{{ vars['icingaweb2_modules'][_module]['certificate_files'] }}" |
61 | 71 | loop_control: |
62 | 72 | loop_var: _file |
63 | 73 | vars: |
64 | 74 | _module: "{{ item.key }}" |
65 | | - when: icingaweb2_modules[_module].certificate_files is defined |
| 75 | + when: vars['icingaweb2_modules'][_module]['certificate_files'] is defined |
66 | 76 | changed_when: false |
0 commit comments