Ajout fichiers

This commit is contained in:
Nicolas Lang
2025-04-07 08:26:32 +00:00
parent 3468f899bd
commit 8cf9fbec36
10 changed files with 1378 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
---
- name: "Création BDD"
community.postgresql.postgresql_db:
name: "{{ zabbix_postgresql_database }}"
- name: "Création utilisateur DB"
community.postgresql.postgresql_user:
db: "{{ zabbix_postgresql_database }}"
name: "{{ zabbix_postgresql_username }}"
password: "{{ zabbix_postgresql_password }}"
- name: "Autorisations sur schema public"
community.postgresql.postgresql_privs:
database: "{{ zabbix_postgresql_database }}"
state: present
privs: SELECT,INSERT,UPDATE,DELETE
objs: ALL_IN_SCHEMA
role: "{{ zabbix_postgresql_username }}"
schema: public
- name: "Autorisations sur schema public"
community.postgresql.postgresql_privs:
db: "{{ zabbix_postgresql_database }}"
state: present
privs: ALL
role: "{{ zabbix_postgresql_username }}"
type: schema
objs: public
- name: "Autorisations sur BDD"
community.postgresql.postgresql_privs:
db: "{{ zabbix_postgresql_database }}"
privs: ALL
objs: "{{ zabbix_postgresql_database }}"
role: "{{ zabbix_postgresql_username }}"
type: database
- name: "Changement owner"
community.postgresql.postgresql_owner:
obj_type: "database"
new_owner: "{{ zabbix_postgresql_username }}"
db: "{{ zabbix_postgresql_database }}"
+92
View File
@@ -0,0 +1,92 @@
---
# tasks file for roles/zabbix-server
- name: "Téléchargement fichier .deb"
ansible.builtin.get_url:
url: "https://repo.zabbix.com/zabbix/{{ zabbix_server_version }}/release/debian/pool/main/z/zabbix-release/zabbix-release_latest+debian{{ zabbix_debian_version }}_all.deb"
dest: "/root/debian{{ zabbix_debian_version }}_all.deb"
- name: "Installation fichier DPKG"
ansible.builtin.apt:
deb: "/root/debian{{ zabbix_debian_version }}_all.deb"
- name: "Mise à jour repository APT et install packages"
ansible.builtin.apt:
update_cache: yes
pkg:
- nginx
- zabbix-server-pgsql
- zabbix-frontend-php
- "php{{ zabbix_phpfpm_version }}-pgsql"
- zabbix-nginx-conf
- zabbix-sql-scripts
- zabbix-agent
- postgresql
- sudo
- python3-psycopg2
- name: "Déplacement fichier de script SQL vers emplacement pour utilisateur postgres"
ansible.builtin.copy:
src: /usr/share/zabbix/sql-scripts/postgresql/server.sql.gz
dest: /tmp/server.sql.gz
mode: 0777
owner: postgres
remote_src: true
- name: "Décompression fichier"
ansible.builtin.raw: gzip -d -f /tmp/server.sql.gz
- name: "Configuration BDD"
become: yes
become_user: postgres
import_tasks: bdd.yml
- name: "Import schéma initial"
ansible.builtin.shell: "cat /tmp/server.sql | sudo -u zabbix psql {{ zabbix_postgresql_database }}"
- name: "Configuration zabbix_server.conf via template"
ansible.builtin.template:
src: /root/ansible/roles/zabbix-server/templates/zabbix_server.conf.j2
dest: /etc/zabbix/zabbix_server.conf
- name: "Retrait présence infos de config"
ansible.builtin.lineinfile:
path: /etc/zabbix/nginx.conf
regexp: "{{ item }}"
state: absent
with_items:
- "^listen.*"
- "^server_name.*"
- "#\\s*listen.*"
- "#\\s*server_name.*"
- name: "Configuration nginx.conf de zabbix"
ansible.builtin.lineinfile:
path: /etc/zabbix/nginx.conf
insertafter: "^server {"
line: "{{ item }}"
state: present
firstmatch: true
with_items:
- "listen {{ zabbix_http_port }};"
- "server_name {{ zabbix_server_name }};"
register: regextest
- name: "Copie fichier template"
ansible.builtin.template:
src: /root/ansible/roles/zabbix-server/templates/zabbix.conf.php.j2
dest: /usr/share/zabbix/ui/zabbix.conf.php
owner: www-data
group: www-data
mode: 0660
- name: "Activation services nginx et php fpm"
ansible.builtin.systemd:
name: "{{ item }}"
state: restarted
enabled: true
with_items:
- nginx
- "php{{ zabbix_phpfpm_version }}-fpm"
- zabbix-server
- zabbix-agent