From 69f31c53164496ad02d59f811978ac6713dd64a4 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 27 Sep 2020 22:16:06 +0200 Subject: [PATCH] initial state for zabbix server --- states/zabbix_server/config.sls | 7 +++++++ states/zabbix_server/defaults.yaml | 10 ++++++++++ states/zabbix_server/init.sls | 7 +++++++ states/zabbix_server/install.sls | 6 ++++++ states/zabbix_server/map.jinja | 5 +++++ states/zabbix_server/service.sls | 6 ++++++ states/zabbix_server/templates/zabbix_server.conf.j2 | 4 ++++ 7 files changed, 45 insertions(+) create mode 100644 states/zabbix_server/config.sls create mode 100644 states/zabbix_server/defaults.yaml create mode 100644 states/zabbix_server/init.sls create mode 100644 states/zabbix_server/install.sls create mode 100644 states/zabbix_server/map.jinja create mode 100644 states/zabbix_server/service.sls create mode 100644 states/zabbix_server/templates/zabbix_server.conf.j2 diff --git a/states/zabbix_server/config.sls b/states/zabbix_server/config.sls new file mode 100644 index 0000000..da936cc --- /dev/null +++ b/states/zabbix_server/config.sls @@ -0,0 +1,7 @@ +--- +{%- from "zabbix_server/map.jinja" import zabbix_server with context %} +zabbix_server-config: + file.managed: + - name: /etc/zabbix/zabbix_server.conf + - source: salt://zabbix_server/templates/zabbix_server.conf.j2 + - template: jinja diff --git a/states/zabbix_server/defaults.yaml b/states/zabbix_server/defaults.yaml new file mode 100644 index 0000000..8266b1e --- /dev/null +++ b/states/zabbix_server/defaults.yaml @@ -0,0 +1,10 @@ +--- +zabbix_Ăserver: + pkgs: + - zabbix-frontend-php + - zabbix-server-pgsql + config: + DBHost: zabbix + DBName: zabbix + DBUser: zabbix + DBPassword: zabbix diff --git a/states/zabbix_server/init.sls b/states/zabbix_server/init.sls new file mode 100644 index 0000000..8f80995 --- /dev/null +++ b/states/zabbix_server/init.sls @@ -0,0 +1,7 @@ +--- +include: + - postgresql + - php + - .install + - .config + - .service diff --git a/states/zabbix_server/install.sls b/states/zabbix_server/install.sls new file mode 100644 index 0000000..4286266 --- /dev/null +++ b/states/zabbix_server/install.sls @@ -0,0 +1,6 @@ +--- +{%- from "zabbix_server/map.jinja" import zabbix_server with context %} + +zabbix_server_pkgs: + pkg.latest: + - pkgs: {{ zabbix_server.pkgs }} diff --git a/states/zabbix_server/map.jinja b/states/zabbix_server/map.jinja new file mode 100644 index 0000000..cf41913 --- /dev/null +++ b/states/zabbix_server/map.jinja @@ -0,0 +1,5 @@ +{%- import_yaml "zabbix_server/defaults.yaml" as default_settings -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, default='zabbix_server') -%} + +{%- set zabbix_server = salt['pillar.get']('zabbix_server', default=defaults, merge=True) -%} diff --git a/states/zabbix_server/service.sls b/states/zabbix_server/service.sls new file mode 100644 index 0000000..2d6b9bd --- /dev/null +++ b/states/zabbix_server/service.sls @@ -0,0 +1,6 @@ +--- +{%- from "zabbix_server/map.jinja" import zabbix_server with context %} +zabbix_server-service: + service.running: + - name: zabbix-server + - enabled: true diff --git a/states/zabbix_server/templates/zabbix_server.conf.j2 b/states/zabbix_server/templates/zabbix_server.conf.j2 new file mode 100644 index 0000000..334ceec --- /dev/null +++ b/states/zabbix_server/templates/zabbix_server.conf.j2 @@ -0,0 +1,4 @@ +{%- from "zabbix_server/map.jinja" import zabbix_server with context %} +{% for k, v in zabbix_server.config.items() %} +{{ k }}={{ v }} +{% endfor %}