Erzeuge Konfiguraton aus Template

This commit is contained in:
phil 2022-12-20 20:28:09 +01:00
parent 33110fa482
commit 2949f0b548
4 changed files with 43 additions and 39 deletions

View file

@ -15,7 +15,6 @@
password: "{{ item.password }}"
host: "{{ inventory_hostname }}"
priv: "{{ item.database }}.*:ALL"
update_password: on_create
state: present
login_unix_socket: "{{ mysql_socket }}"
login_user: root

View file

@ -37,6 +37,15 @@
chdir: "{{ lstu.path }}"
when: configuration.changed
- name: "lstu | Kopiere Konfiguration"
ansible.builtin.template:
src: lstu.conf
dest: "{{ lstu.path }}"
mode: 0640
owner: "{{ lstu_user }}"
group: "{{ lstu_user }}"
notify: restart lstu
- name: "lstu | set ownership"
ansible.builtin.file:
path: "{{ lstu.path }}"
@ -44,41 +53,6 @@
group: "{{ lstu_user }}"
recurse: true
- name: "lstu | edit config"
ansible.builtin.lineinfile:
path="{{ lstu.path }}/lstu.conf"
regexp="{{ item.regexp }}"
line="{{ item.line }}"
state=present
backup=no
backrefs=no
loop:
- { regexp: '^\s*#contact.*$', line: " contact => '{{ lstu.contact }}'," }
- { regexp: '^\s*#dbtype.*$', line: " dbtype => 'mysql'," }
- { regexp: '^\s*listen\s*=>.*$', line: " listen => ['http://0.0.0.0:8080']," }
- { regexp: '^\s*#proxy\s*=>.*$', line: " proxy => 1," }
- { regexp: '^\s*#really_delete_urls\s*=>.*$', line: " really_delete_urls => 1," }
- { regexp: '^\s*#secret\s*=>.*$', line: " secret => ['{{ lstu_cookie_secret }}']," }
- { regexp: '^\s*#adminpwd\s*=>.*$', line: " adminpwd => '{{ lstu.admin_passwd }}'," }
tags: lstu_conf
- name: "lstu | edit config (db)"
ansible.builtin.blockinfile:
path: "{{ lstu.path }}/lstu.conf"
insertbefore: '^\s*#mysqldb.*$'
block: |
mysqldb => {
database => '{{ lstu_db }}',
host => '{{ database_host }}',
# optional, default is 3306
#port => 3306,
user => '{{ lstu_db_user }}',
pwd => '{{ lstu_db_password }}',
# optional, default is 5 (set to 0 to disable persistent connections)
#max_connections => 5,
},
- name: "lstu | Kopiere systemd-Unit"
ansible.builtin.template:
src: lstu.service.j2