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) -%}