Skip to content
Snippets Groups Projects
init.sls 2.36 KiB
Newer Older
  • Learn to ignore specific revisions
  • MyIgel's avatar
    MyIgel committed
    {% import 'restic/init.sls' as restic %}
    
    
    skorpy's avatar
    skorpy committed
    include:
      - ferm
      - common.python
    
    
    skorpy's avatar
    skorpy committed
    salt-pip-influxdb:
      pip.installed:
        - name: influxdb
    
    skorpy's avatar
    skorpy committed
    python-influxdb:
      pkg.installed:
        - pkgs:
          - python3-influxdb
    
    
    skorpy's avatar
    skorpy committed
    python2-influxdb:
      pkg.purged:
        - pkgs:
          - python-influxdb
    
    
    skorpy's avatar
    skorpy committed
    influxdb:
      pkgrepo.managed:
        - humanname: influxdb
    
        - name: deb https://repos.influxdata.com/{{ grains['os_family'] | lower }} {{ grains['oscodename'] }} stable
        - key_url: https://repos.influxdata.com/influxdata-archive_compat.key
    
    skorpy's avatar
    skorpy committed
        - file: /etc/apt/sources.list.d/influxdb.list
        - clean_file: True
      pkg.installed:
        - pkgs:
          - influxdb
        - require:
          - pkgrepo: influxdb
    
    /etc/influxdb/influxdb.conf:
      file.managed:
        - source: salt://influxdb/files/influxdb.conf
        - require:
          - pkg: influxdb
    
    /etc/ferm/conf.d/40-influxdb.conf:
      file.managed:
    
    skorpy's avatar
    skorpy committed
        - source: salt://influxdb/files/ferm.conf.j2
        - template: jinja
    
    skorpy's avatar
    skorpy committed
        - require:
          - file: /etc/ferm/conf.d
    
    
    skorpy's avatar
    skorpy committed
    /var/lib/influxdb:
    
    skorpy's avatar
    skorpy committed
      file.directory:
        - user: influxdb
        - group: influxdb
        - require:
          - pkg: influxdb
    
    /etc/systemd/system/influxdb.service:
      file.managed:
        - source: salt://influxdb/files/influxdb.service
        - require:
          - pkg: influxdb
          - file: /var/lib/influxdb
    
    influxdb.service:
      service.running:
        - enable: True
        - require:
          - file: /etc/systemd/system/influxdb.service
          - file: /var/lib/influxdb
    
    skorpy's avatar
    skorpy committed
        - watch:
          - file: /etc/influxdb/influxdb.conf
    
    
    skorpy's avatar
    skorpy committed
    
    {% for name, user in salt['pillar.get']('influxdb:users').items() %}
    influxdb_user_{{ name }}:
      influxdb_user.present:
        - name: {{ name }}
        - passwd: {{ user['password'] }}
        - admin: {{ user.get('admin', False) }}
    
    skorpy's avatar
    skorpy committed
        {%- if 'grants' in user %}
    
    skorpy's avatar
    skorpy committed
        - grants:
            {{ user.get('grants', {}) | yaml }}
    
    skorpy's avatar
    skorpy committed
        {%- endif %}
        - require:
          - service: influxdb.service
          - pkg: python-influxdb
    {% endfor %}
    
    {% for name in salt['pillar.get']('influxdb:databases') %}
    influxdb_database_{{ name }}:
      influxdb_database.present:
        - name: {{ name }}
        - require:
          - service: influxdb.service
          - pkg: python-influxdb
    {% endfor %}
    
    MyIgel's avatar
    MyIgel committed
    
    {# We should use the explicit backup here but the host has a small disk #}
    {{ restic.path('influxdb', '/var/lib/influxdb/') }}
    {#{ restic.cmd('influxdb', 'influxd backup -portable /var/lib/influxdb/backup') }#}
    {#{ restic.path('influxdb', '/var/lib/influxdb/backup') }#}