Ajout fichiers
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
---
|
||||
# defaults file for roles/zabbix-server
|
||||
zabbix_phpfpm_version: 8.2
|
||||
zabbix_http_port: 8080
|
||||
zabbix_server_version: 7.2
|
||||
zabbix_debian_version: 12
|
||||
zabbix_postgresql_database: zabbixbdd
|
||||
zabbix_postgresql_username: zabbix
|
||||
zabbix_postgresql_password: zabazabiz
|
||||
zabbix_server_name: zabbix-example
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for roles/zabbix-server
|
||||
@@ -0,0 +1,34 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
@@ -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 }}"
|
||||
@@ -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
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// Zabbix GUI configuration file.
|
||||
|
||||
$DB['TYPE'] = 'POSTGRESQL';
|
||||
$DB['SERVER'] = 'localhost';
|
||||
$DB['PORT'] = '0';
|
||||
$DB['DATABASE'] = '{{ zabbix_postgresql_database }}';
|
||||
$DB['USER'] = '{{ zabbix_postgresql_username }}';
|
||||
$DB['PASSWORD'] = '{{ zabbix_postgresql_password }}';
|
||||
|
||||
// Schema name. Used for PostgreSQL.
|
||||
$DB['SCHEMA'] = '';
|
||||
|
||||
// Used for TLS connection.
|
||||
$DB['ENCRYPTION'] = false;
|
||||
$DB['KEY_FILE'] = '';
|
||||
$DB['CERT_FILE'] = '';
|
||||
$DB['CA_FILE'] = '';
|
||||
$DB['VERIFY_HOST'] = false;
|
||||
$DB['CIPHER_LIST'] = '';
|
||||
|
||||
// Vault configuration. Used if database credentials are stored in Vault secrets manager.
|
||||
$DB['VAULT'] = '';
|
||||
$DB['VAULT_URL'] = '';
|
||||
$DB['VAULT_PREFIX'] = '';
|
||||
$DB['VAULT_DB_PATH'] = '';
|
||||
$DB['VAULT_TOKEN'] = '';
|
||||
$DB['VAULT_CERT_FILE'] = '';
|
||||
$DB['VAULT_KEY_FILE'] = '';
|
||||
// Uncomment to bypass local caching of credentials.
|
||||
// $DB['VAULT_CACHE'] = true;
|
||||
|
||||
// Uncomment and set to desired values to override Zabbix hostname/IP and port.
|
||||
// $ZBX_SERVER = '';
|
||||
// $ZBX_SERVER_PORT = '';
|
||||
|
||||
$ZBX_SERVER_NAME = '{{ zabbix_server_name }}';
|
||||
|
||||
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
|
||||
// Uncomment this block only if you are using Elasticsearch.
|
||||
// Elasticsearch url (can be string if same url is used for all types).
|
||||
//$HISTORY['url'] = [
|
||||
// 'uint' => 'http://localhost:9200',
|
||||
// 'text' => 'http://localhost:9200'
|
||||
//];
|
||||
// Value types stored in Elasticsearch.
|
||||
//$HISTORY['types'] = ['uint', 'text'];
|
||||
|
||||
// Used for SAML authentication.
|
||||
// Uncomment to override the default paths to SP private key, SP and IdP X.509 certificates, and to set extra settings.
|
||||
//$SSO['SP_KEY'] = 'conf/certs/sp.key';
|
||||
//$SSO['SP_CERT'] = 'conf/certs/sp.crt';
|
||||
//$SSO['IDP_CERT'] = 'conf/certs/idp.crt';
|
||||
//$SSO['SETTINGS'] = [];
|
||||
|
||||
// If set to false, support for HTTP authentication will be disabled.
|
||||
// $ALLOW_HTTP_AUTH = true;
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
localhost
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- roles/zabbix-server
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
# vars file for roles/zabbix-server
|
||||
ansible_command_timeout: 3600
|
||||
Reference in New Issue
Block a user