From 078b97b1388fd5ed62528c457c86100ee033e94d Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 16 Apr 2024 23:29:23 +0200 Subject: [PATCH] added geoip state --- states/geoip/defaults.yaml | 8 ++++++++ states/geoip/init.sls | 4 ++++ states/geoip/install.sls | 13 +++++++++++++ states/geoip/map.jinja | 3 +++ 4 files changed, 28 insertions(+) create mode 100644 states/geoip/defaults.yaml create mode 100644 states/geoip/init.sls create mode 100644 states/geoip/install.sls create mode 100644 states/geoip/map.jinja diff --git a/states/geoip/defaults.yaml b/states/geoip/defaults.yaml new file mode 100644 index 0000000..6bf6d5a --- /dev/null +++ b/states/geoip/defaults.yaml @@ -0,0 +1,8 @@ +--- +geoip: + basepath: /usr/share/GeoIP + version: 2023.03.26 + url: https://git.paulbsd.com/paulbsd/GeoLite.mmdb/releases/download + dbs: + - GeoLite2-City.mmdb + - GeoLite2-ASN.mmdb diff --git a/states/geoip/init.sls b/states/geoip/init.sls new file mode 100644 index 0000000..aa21732 --- /dev/null +++ b/states/geoip/init.sls @@ -0,0 +1,4 @@ +--- +{%- from "geoip/map.jinja" import geoip with context %} +include: + - .install diff --git a/states/geoip/install.sls b/states/geoip/install.sls new file mode 100644 index 0000000..ec2385d --- /dev/null +++ b/states/geoip/install.sls @@ -0,0 +1,13 @@ +--- +{%- from "geoip/map.jinja" import geoip with context %} +{% for dbname in geoip.dbs %} +geoip-geoip-{{ dbname }}: + file.managed: + - name: {{ geoip.basepath }}/geoip/{{ dbname }} + - source: {{ geoip.url }}/{{ geoip.version }}/{{ dbname }} + - skip_verify: True + - makedirs: True + - user: root + - group: root + - mode: "0644" +{% endfor %} diff --git a/states/geoip/map.jinja b/states/geoip/map.jinja new file mode 100644 index 0000000..15d9ce9 --- /dev/null +++ b/states/geoip/map.jinja @@ -0,0 +1,3 @@ +{%- import_yaml "geoip/defaults.yaml" as defaults -%} + +{%- set geoip = salt['pillar.get']('geoip', default=defaults.geoip, merge=True) -%}