From 6c2cecfe91203d9ee4dd7bcfabf8e5e1407f3dd2 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 21 Dec 2021 22:47:24 +0100 Subject: [PATCH] Pfadanpassungen, Ermittle php-Version, munin-Task --- defaults/main.yml | 5 +++-- handlers/main.yml | 6 +++++- tasks/common.yml | 29 ++++++++++++++++++++--------- tasks/main.yml | 8 ++++++++ tasks/munin.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ tasks/php.yml | 4 ++-- 6 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 tasks/munin.yml diff --git a/defaults/main.yml b/defaults/main.yml index c6af67a..7bc08e2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,9 +1,11 @@ --- +local_munin_path: /data/munin mysql_socket: /var/run/mysqld/mysqld.sock nextcloud_admin_user: systemausfall.org nextcloud_admin_pw: admin nextcloud_db_password: "{{ lookup('password', '/tmp/{{ instance.domain }}_db_pwd length=42 chars=ascii_letters,digits') }}" +nextcloud_munin_user_password: "{{ lookup('password', '/tmp/{{ instance.domain }}_munin_pwd length=42 chars=ascii_letters,digits') }}" nextcloud_dl_url: https://download.nextcloud.com/server/releases nextcloud_root: /data/nextcloud nextcloud_install_path: "{{ nextcloud_root }}/{{ instance.domain }}" @@ -19,5 +21,4 @@ nextcloud_smtp_auth_type: LOGIN nextcloud_smtp_host: sl-postbote.kahlo nextcloud_smtp_port: 25 -php_version: "7.4" -redis_config_file: /etc/redis/redis.conf +redis_config_file: /etc/redis/redis.conf \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml index 1ec7331..d2b2a55 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -17,6 +17,10 @@ - name: restart phpfpm service: - name: "php{{ php_version }}-fpm" + name: "php{{ php_version.stdout }}-fpm" state: restarted +- name: restart munin-node + service: + name: munin-node + state: restarted \ No newline at end of file diff --git a/tasks/common.yml b/tasks/common.yml index df701cf..3b8d460 100644 --- a/tasks/common.yml +++ b/tasks/common.yml @@ -1,5 +1,5 @@ --- -- name: "common: Apache-Module laden" +- name: "common | Apache-Module laden" apache2_module: state: present name: "{{ item }}" @@ -9,25 +9,36 @@ - setenvif notify: restart apache -- name: "common: Apache-Vorlage für Seitenkonfiguration kopieren" +- name: "common | Apache-Vorlage für Seitenkonfiguration kopieren" copy: - src: roles/nextcloud/files/apache_site.conf + src: ../roles/nextcloud/files/apache_site.conf dest: /etc/apache2/sites-available/nextcloud.conf -- name: "common: Apache-Seitenkonfiguration aktivieren" +- name: "common | Apache-Seitenkonfiguration aktivieren" file: src: /etc/apache2/sites-available/nextcloud.conf dest: /etc/apache2/sites-enabled/nextcloud.conf state: link notify: reload apache -- name: "common: Kopiere PHP-CLI-Konfiguration" +- name: "common | Kopiere PHP-CLI-Konfiguration" copy: - src: roles/nextcloud/files/30-sao.ini - dest: "/etc/php/{{ php_version }}/cli/conf.d/30-sao.ini" + src: ../roles/nextcloud/files/30-sao.ini + dest: "/etc/php/{{ php_version.stdout }}/cli/conf.d/30-sao.ini" -- name: "common: Kopiere Update-Skript" +- name: "common | Kopiere Update-Skript" template: - src: roles/nextcloud/templates/nextcloud-updater.j2 + src: ../roles/nextcloud/templates/nextcloud-updater.j2 dest: "{{ local_scripts_dir }}/nextcloud-updater" mode: 0755 + +- name: "common | Erstelle munin-Verzeichnis" + file: + path: "{{ local_munin_path }}" + state: directory + +- name: "common | Kopiere munin-Daten" + get_url: + url: https://raw.githubusercontent.com/munin-monitoring/contrib/master/plugins/nextcloud/nextcloud_ + dest: "{{ local_munin_path }}/nextcloud_" + mode: 0755 \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 6f4cbf3..0330060 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,12 +1,16 @@ --- - import_tasks: version.yml tags: version + - import_tasks: gateway.yml tags: gateway + - import_tasks: database.yml tags: database + - import_tasks: php.yml tags: php + - import_tasks: apache.yml tags: apache @@ -17,5 +21,9 @@ - import_tasks: nextcloud_configuration.yml tags: configuration + - import_tasks: fixes.yml tags: fixes +# Das Plugin braucht noch Anpassungen +#- import_tasks: munin.yml +# tags: munin \ No newline at end of file diff --git a/tasks/munin.yml b/tasks/munin.yml new file mode 100644 index 0000000..0a65ce3 --- /dev/null +++ b/tasks/munin.yml @@ -0,0 +1,45 @@ +--- +- name: "munin | Verlinke Plugin" + file: + src: "{{ local_munin_path }}/nextcloud_" + dest: "/etc/munin/plugins/nextcloud_{{ instance.domain }}" + state: link + notify: restart munin-node + +- name: "userinfo" + command: + cmd: 'php occ user:info munin' + chdir: "{{ nextcloud_root }}/{{ instance.domain }}" + become: true + become_user: "{{ instance.user }}" + ignore_errors: true + changed_when: false + register: occ_user + +- name: "munin | Erstelle Nutzer" + command: + cmd: 'php occ user:add --display-name="munin" --password-from-env munin' + chdir: "{{ nextcloud_root }}/{{ instance.domain }}" + environment: + OC_PASS: "{{ nextcloud_munin_user_password }}" + become: true + become_user: "{{ instance.user }}" + register: occ_user_created + when: occ_user.stdout == "user not found" + +- name: "munin | Kopiere Konfiguration" + blockinfile: + path: /etc/munin/plugin-conf.d/nextcloud + create: true + mode: 0600 + marker_begin: "{{ instance.domain }}" + block: | + [{{ instance.domain }}] + env.username munin + env.password {{ nextcloud_munin_user_password }} + env.api_path /ocs/v2.php/apps/serverinfo/api/v1/info + env.scheme https + env.timeout 2s + env.updates_warning 1 + when: occ_user_created.changed + notify: restart munin-node \ No newline at end of file diff --git a/tasks/php.yml b/tasks/php.yml index 0415fa6..6bce969 100644 --- a/tasks/php.yml +++ b/tasks/php.yml @@ -11,8 +11,8 @@ - name: "php: {{ instance.domain }}: FPM-Pool einrichten" template: src: php_fpm_pool.j2 - dest: "/etc/php/{{ php_version }}/fpm/pool.d/{{ instance.user }}.conf" + dest: "/etc/php/{{ php_version.stdout }}/fpm/pool.d/{{ instance.user }}.conf" owner: root group: root mode: 0644 - notify: restart phpfpm + notify: restart phpfpm \ No newline at end of file