---
###############
# BEACH RESORT TEMPLATE WITH SMS ONBOARDING
###############
#
# This template will create a sample configuration for a hypothetical beach
# resort that wishes to use SMS onboarding to provide free Wi-Fi to guests.
#
# SMS Messages are sent via email based on the carrier chosen on the captive
# portal during onboarding. More feature-rich SMS functionality can be gained
# by enabling a SMS gateway and using a 3rd party service, such as Twilio.
# 
# It is suggested to use a DKIM Domain in System::Options to prevent the system emails
# from being blocked as Spam and to allow sending of emails through trusted SMTP
# servers.
#
###############

#IMPORTANT: Please change these values to to match the target system
<%

wan_interface ||= 'igb0'
lan_interface ||= 'igb3'

%>


###############
# Template begins
###############

# Generate Policies
Policy:
- name: Management
- name: Free
  _delete: true

# Subnet Filter to block traffic between VLANs/Subnets
SubnetsFilter:
- name: Block Subnets
  policies:
  - Free
  - Management

# Enable LLDP on LAN and WAN Interfaces
LadvdOption:
- name: default
  active: true
  auto_enable_protocols: true
  listen_only: false
  interfaces:
  - <%= lan_interface %>
  - <%= wan_interface %>

# Create Pre-Auth/Guest and Post-Auth VLANs and apply to LAN interface
Vlan:
- name: Guests
  interface: <%= lan_interface %>
  tag: 1100
  autoincrement_ratio: 8
  autoincrement_mode: address

# Apply IP addresses to VLANs
Address:
- name: Guests
  vlan: Guests
  span: 1
  autoincrement: 64
  primary: true
  cidr: 10.0.0.1/30

# Create DHCP Pools for subnets
DhcpPool:
- name: Guests
  start_ip: 10.0.0.2
  end_ip: 10.0.0.254
  start_reserved: 0
  end_reserved: 0
  router_host_nth: 0

# Add SMS Account Group for Captive Portal shortcut
AccountGroup:
- name: SMS
  policy: Free
  priority: 4

# Create Captive Portal
CaptivePortal:
- name: default
  portal_name: default
  background_automatic_login: mac
  portal_automatic_login: mac_reauth
  password_reset_method: secret_question
  role_attribute: none
  wan_targets:
  - name: Certificate Validation Hosts
  policies:
  - Free

# Create Traffic Shaping Rules
BandwidthQueue:
- name: Infrastructure
  upload_bw: 100
  upload_bw_unit: "%"
  download_bw: 100
  download_bw_unit: "%"
  priority: 0
  rt_upload_bw_unit: Mbps
  rt_download_bw_unit: Mbps
  burst_upload_bw_unit: Mbps
  burst_download_bw_unit: Mbps
  sharing: group
  disable_auto_ip_queues: true
  policies:
  - Management
- name: 3x1 Mbps with burst
  upload_bw: 1
  upload_bw_unit: Mbps
  download_bw: 3
  download_bw_unit: Mbps
  priority: 0
  rt_upload_bw_unit: Mbps
  rt_download_bw_unit: Mbps
  burst_upload_bw: 2
  burst_upload_bw_unit: Mbps
  burst_download_bw: 10
  burst_download_bw_unit: Mbps
  burst_ms: 5000
  sharing: ip
  policies:
  - Free

# Delete inactive accounts after 1 week
DatabasePurger:
- name: Inactive Accounts
  tables:
  - accounts
  timestamp_column: logged_in_at
  retain_records_with_usage_remaining: true
  age_number: 1
  age_string: weeks