Here's a sample playbook to use with ansible-openwisp2 
<https://github.com/openwisp/ansible-openwisp2>, follow the instructions in 
this link first, then add the following to your playbook.yml:

- hosts: openwisp
  become: true
  become_user: root
  roles:
    - openwisp.openwisp2
  vars:
    openwisp2_language_code: en-en
    openwisp2_time_zone: Europe/Rome
    openwisp2_nginx_http2: true
    openwisp2_nginx_ipv6: true
    openwisp2_default_from_email: [email protected]
    openwisp2_default_cert_validity: 7300
    openwisp2_default_ca_validity: 7300
    openwisp2_default_from_email: no-reply@<yourdomain>
    openwisp2_extra_python_packages:
        - https://github.com/openwisp/openwisp-monitoring/tarball/master
    openwisp2_extra_urls:
        - "url(r'', include('openwisp_monitoring.urls'))"
    openwisp2_extra_django_settings:
        EMAIL_HOST: '<SMTP_SERVER>'
        EMAIL_PORT: 25
        EMAIL_HOST_USER: [email protected]
    openwisp2_extra_django_settings_instructions:
      - |
        # monitoring settings
        from datetime import timedelta

        CELERY_BEAT_SCHEDULE = {
            'run_checks': {
                'task': 'openwisp_monitoring.check.tasks.run_checks',
                'schedule': timedelta(minutes=5),
                'args': None,
                'relative': True
            }
        }

        CELERY_TASK_ACKS_LATE = True
        CELERY_WORKER_PREFETCH_MULTIPLIER = 1

        for app in ['openwisp_monitoring.notifications',
                  'openwisp_monitoring.check',
                  'openwisp_monitoring.device',
                  'openwisp_monitoring.monitoring']:
            
INSTALLED_APPS.insert(INSTALLED_APPS.index('openwisp_controller.geo',) + 1, 
app)

        TEMPLATES[0]['OPTIONS']['loaders'].insert(0, 'apptemplates.Loader')
        if 'djcelery_email' not in INSTALLED_APPS:
            INSTALLED_APPS.append('djcelery_email')
            EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
            CELERY_BROKER_URL = 'redis://127.0.0.1:6379/3'

        OPENWISP_MONITORING_HEALTH_STATUS_LABELS = {
            'unknown': 'unknown',
            'ok': 'online',
            'problem': 'problem',
            'critical': 'offline'
        }
        INFLUXDB_USER = "root"
        INFLUXDB_PASSWORD = "root"
  pre_tasks:
    # openwisp-monitoring
    - name: Add influxdb key
      apt_key:
        url: https://repos.influxdata.com/influxdb.key
        state: present
      tags: [monitoring]
    - name: Add influxdb repo
      apt_repository:
        repo: "deb https://repos.influxdata.com/{{ 
ansible_distribution.lower() }}/ {{ ansible_distribution_release  }} stable"
        state: present
      tags: [monitoring]
    - name: Install influxdb and fping (update apt cache first)
      apt:
        name: "{{ item }}"
        update_cache: yes
      with_items:
        - influxdb
        - fping
      tags: [monitoring]
    - name: ensure influxdb is started and enabled
      service:
        name: influxdb
        state: started
        enabled: yes
      tags: [monitoring]
  tasks:
    # monitoring
    - name: supervisor celerybeat
      template:
        src: templates/celerybeat.j2
        dest: "{{ supervisor_path | format('celerybeat') }}"
      notify: reload supervisor
      tags: [openwisp2, monitoring]


in templates/celerybeat.j2 put:

[program:celerybeat]
user={{ www_user }}
directory={{ openwisp2_path }}
command={{ openwisp2_path }}/env/bin/celery -A openwisp2 beat -l info
autostart=true
autorestart=true
stopsignal=INT
redirect_stderr=true
stdout_logfile={{ openwisp2_path }}/log/celerybeat.log
stdout_logfile_maxbytes=30MB
stdout_logfile_backups=5

In production systems I suggest to use PostgreSQL (you can use the ansible 
role ANXS.postgresql) and Letsencrypt (instructions for configuring 
letsencrypt are included in the README of ansible-openwisp2).

I hope this helps.

Best regards
Federico

-- 
You received this message because you are subscribed to the Google Groups 
"OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/openwisp/e08b87c5-91a8-45e1-9292-80efa70cbf93%40googlegroups.com.

Reply via email to