ansible-role-lstu/tasks/lstu.yml
2022-12-10 15:02:35 +01:00

114 lines
3.5 KiB
YAML

- name: "lstu | Ermittle aktuellen Tag"
ansible.builtin.shell:
cmd: curl -s "{{ lstu_api_url }}" | jq '.[]' | jq -r '.name' | head -1
warn: false
changed_when: false
register: latest_tag
- name: "lstu | Erstelle Verzeichnisse"
ansible.builtin.file:
path: "{{ lstu.path }}"
state: directory
owner: "{{ lstu_user }}"
group: "{{ lstu_user }}"
mode: 0755
recurse: true
- name: "lstu | Klone Git"
ansible.builtin.git:
repo: "{{ lstu_git_url }}"
dest: "{{ lstu.path }}"
force: true
version: "{{ latest_tag.stdout }}"
- name: "lstu | Kopiere Konfiguration"
ansible.builtin.copy:
src: "{{ lstu.path }}/lstu.conf.template"
dest: "{{ lstu.path }}/lstu.conf"
mode: 0640
remote_src: true
force: false
register: configuration
- name: "lstu | Installiere Abhängigkeiten"
ansible.builtin.shell:
#cmd: carton install --deployment --without=test --without=sqlite --without=postgresql --without=ldap --without=htpasswd --without=cache
cmd: carton install --without=test --without=sqlite --without=postgresql --without=ldap --without=htpasswd --without=cache
chdir: "{{ lstu.path }}"
when: configuration.changed
- name: "lstu | set ownership"
ansible.builtin.file:
path: "{{ lstu.path }}"
owner: "{{ lstu_user }}"
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
dest: "/etc/systemd/system/{{ lstu_service }}"
mode: 0644
notify: restart lstu
- name: "lstu | Prüfe Theme-Verzeichnis"
ansible.builtin.stat:
path: "{{ lstu.path }}/themes/{{ lstu_theme }}"
register: theme
# - name: "lstu | Kopiere Update-Skript"
# ansible.builtin.template:
# src: lstu-updater.j2
# dest: "/usr/local/bin/lstu-updater"
# mode: 0755
# - name: "lstu | Cron für Auto-Updates"
# ansible.builtin.cron:
# name: lstu Aktualisierungen
# hour: "3"
# minute: "3"
# job: "chronic /usr/local/bin/lstu-updater"
- name: "lstu | Monit-Überwachung"
ansible.builtin.template:
src: monit.j2
dest: /etc/monit/conf-available/lstu
mode: 0644
notify: reload monit