---
###############
# SKI RESORT TEMPLATE WITH EMAIL ONBOARDING
###############
#
# This template will create a sample configuration for a hypothetical ski
# resort that wishes to use email adddress onboarding to provide free 1-day
# Wi-Fi to guests.
#
# 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:
Policy:
- name: Management
- name: Free
  default: true
- name: Default
  _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

# Create free shared credential group for captive portal shortcut
SharedCredentialGroup:
- name: Free
  policy: Free
  priority: 5
  credential: free
  min_mac_login_period: 0
  usage_minutes: 1440
  unlimited_usage_mb_up: true
  unlimited_usage_mb_down: true
  max_simultaneous_sessions: 2
  starts_at: !ruby/object:ActiveSupport::TimeWithZone
    utc: 2024-02-08 08:00:00.000000000 Z
    zone: &1 !ruby/object:ActiveSupport::TimeZone
      name: America/Los_Angeles
    time: 2024-02-08 00:00:00.000000000 Z
  ends_at: !ruby/object:ActiveSupport::TimeWithZone
    utc: 2024-02-15 08:00:00.000000000 Z
    zone: *1
    time: 2024-02-15 00:00:00.000000000 Z
  state: active
  mon: true
  tues: true
  wed: true
  thurs: true
  fri: true
  sat: true
  sun: true
  recurring_method: none
  automatic_login: true

# Create Survey Question to capture email address
SurveyQuestion:
- question: Enter Email Address
  question_type: email
  required: true
  position: 1

# Create Captive Portal
CaptivePortal:
- name: default
  portal_name: default
  background_automatic_login: mac
  portal_automatic_login: mac_reauth
  require_tos_agreement: inline
  password_reset_method: secret_question
  role_attribute: none
  shared_credential_groups:
  - Free
  survey_questions:
  - Enter Email Address
  wan_targets:
  - Certificate Validation Hosts
  policies:
  - Free

LandingPortal:
- name: default
  portal_name: default
  unlimited_session_minutes: true
  idle_minutes: 20
  session_grace_minutes: 15
  portal_automatic_login: mac_cookie
  background_automatic_login: disabled

# 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 expired accounts after 1 week
DatabasePurger:
- name: Expired Accounts
  tables:
  - accounts
  timestamp_column: usage_expiration
  age_number: 1
  age_string: weeks