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

@ -9,9 +9,7 @@ lstu_monit_name: lstu
lstu_service: lstu.service lstu_service: lstu.service
lstu_theme: default lstu_theme: default
lstu_cookie_secret: "zibuadoinckyg" lstu_cookie_secret: "zibuadoinckyg"
lstu: lstu_contact: 'support@systemausfall.org'
path: /var/www/lstu
contact: 'admin[at]systemausfall.org'
minion_service: lstu-minion minion_service: lstu-minion
minion_workers: 1 minion_workers: 1

View file

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

View file

@ -37,6 +37,15 @@
chdir: "{{ lstu.path }}" chdir: "{{ lstu.path }}"
when: configuration.changed 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" - name: "lstu | set ownership"
ansible.builtin.file: ansible.builtin.file:
path: "{{ lstu.path }}" path: "{{ lstu.path }}"
@ -44,41 +53,6 @@
group: "{{ lstu_user }}" group: "{{ lstu_user }}"
recurse: true 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" - name: "lstu | Kopiere systemd-Unit"
ansible.builtin.template: ansible.builtin.template:
src: lstu.service.j2 src: lstu.service.j2

33
templates/lstu.conf Executable file
View file

@ -0,0 +1,33 @@
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab:
{
hypnotoad => {
listen => ['http://0.0.0.0:8080'],
proxy => 1,
},
contact => '{{ lstu_contact }}',
secret => ['lstu_cookie_secret'],
hashed_adminpwd => 'f85cf20922bf5000f38c0ef9832396c53afb17aeab51979c26940bc8fdf0ecc7',
really_delete_urls => 1,
theme => 'milligram',
disable_api => 1,
dbtype => 'mysql',
mysqldb => {
database => '{{ lstu_db }}',
host => '{{ database_host }}',
user => '{{ lstu_db_user }}',
pwd => '{{ lstu_db_password }}',
},
minion => {
enabled => 1,
mysqldb => {
database => '{{ minion_db }}',
host => '{{ database_host }}',
user => '{{ minion_db_user }}',
pwd => '{{ minion_db_password }}',
},
},
};