#
# Copyright (c) 2020 Bubble, Inc.  All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
- name: Write install_algo.sh template
  template:
    src: install_algo.sh.j2
    dest: /root/ansible/roles/algo/algo/install_algo.sh
    owner: root
    group: root
    mode: 0500

- name: Stop algo monitors just in case
  shell: bash -c "supervisorctl stop algo_refresh_users_monitor && supervisorctl stop wg_monitor_connections"

# Don't setup algo when in restore mode, bubble_restore_monitor.sh will set it up after the CA key has been restored
- name: Run algo playbook to install algo
  shell: bash -c "/root/ansible/roles/algo/algo/install_algo.sh 2>&1 >> /var/log/bubble/install_algo.log"
  tags: algo_related

# Algo installation clears out iptable rules. Add needed bubble rules back:
- include: algo_firewall.yml
  tags: algo_related
