
- hosts: remote-config-hosts
  tasks:

  pre_tasks:
    - name: Create config directory
      file: name=/data/remote-config state=directory

    - name: Create config file if missing
      copy: content="[]" dest=/data/remote-config/config.json force=false

  roles:
    - role: deploy-service
      service_name: remote-config
      service_port: 3000
      service_docker:
        image: mopsalarm/go-remote-config

        command: >
          --datadog-apikey="{{ datadog_api_key }}"
          --admin-password="{{ remote_config_password }}"

        volumes:
          - /data/remote-config:/rules

        env:
          SERVICE_3000_NAME: remote-config

        ports:
          - "3000:3000"


- hosts: remote-config-hosts
  tasks:

  pre_tasks:
    - name: Create config directory
      file: name=/data/remote-config state=directory

    - name: Create config file if missing
      copy: content="[]" dest=/data/remote-config/config.json force=false

    - name: Create cron-job to create a backup of the config
      tags: cronjob
      cron:
        name: backup_remote_config
        special_time: daily
        job: cat /data/remote-config/config.json | gzip -9 > /data/remote-config/config-"$(date -I)".json.gz

  roles:
    - role: deploy-service
      service_name: remote-config
      service_port: 3000
      service_docker:
        image: mopsalarm/go-remote-config

        command: >
          --datadog-apikey="{{ datadog_api_key }}"
          --admin-password="{{ remote_config_password }}"

        volumes:
          - /data/remote-config:/rules

        env:
          SERVICE_3000_NAME: remote-config

        ports:
          - "3000:3000"

Add cronjob to backup remote config.
Add cronjob to backup remote config.
