# Salt Minion floscript

house minion

framer minionudpstack be active first setup
    # Begin the pre-flight checks
    frame setup
        enter
            do salt raet cleanup
            do salt raet road stack setup per inode ".salt.road.manor"
            do salt raet manor lane setup
            do salt raet process manager setup
        go loadmodules

    # Load the minion mods
    frame loadmodules
        do salt load modules at enter
        go setupmatcher

    frame setupmatcher
        do salt raet setup matcher at enter
        go setupbeacon

    frame setupbeacon
        do salt raet setup beacon at enter
        go spawnreactor
        go startengines
        go start

    frame spawnreactor
        let me if .salt.etc.reactor
        enter
            do salt raet reactor fork
        go startengines
        go start

    frame startengines
        let me if .salt.etc.engines
        enter
            do salt raet setup engines
        go start

    # OK, let's start the minion up
    frame start
        # Start the inbound framer
        bid start inbound
        # Start the bootstrap framer
        bid start bootstrap
        # Start the eventing framer
        bid start eventing
        # Start the functionmanage framer
        bid start functionmanager
        # Start the outbound framer
        bid start outbound
        # Start the scheduler
        bid start scheduler

        # Cleanup on exit
        exit
            do salt raet road stack closer per inode ".salt.road.manor."
            do salt raet lane stack closer per inode ".salt.lane.manor."

# Framer for handling inbound traffic
framer inbound be inactive first start
    frame start
        do salt raet road stack service rx
        do salt raet lane stack service rx

framer bootstrap be inactive first setup

    frame setup
        enter
            do salt raet road clustered per inode ".salt.road.manor."
            do salt raet road usher minion setup per inode ".salt.road.manor."
        go clustermaster
        go multimaster

    frame clustermaster
        let if salt.road.manor.cluster.clustered
        print Setting Up Master Cluster ....
        go join

    frame multimaster
        print Setting Up Master or MultiMaster
        go join

    frame join
        print Joining...
        enter
            do salt raet road stack joiner per inode ".salt.road.manor."
        recur
            do salt raet road stack joined per inode ".salt.road.manor."
            do salt raet road stack rejected per inode ".salt.road.manor."

        go next if joined in .salt.road.manor.status
        go abort if rejected in .salt.road.manor.status

    frame joined
        print Joined
        go next if elapsed >= 0.5

    frame allow
        print Allowing...
        enter
            do salt raet road stack allower per inode ".salt.road.manor."
        recur
            do salt raet road stack allowed per inode ".salt.road.manor."

        go next if allowed in .salt.road.manor.status

    frame allowed
        print Allowed
        go next if elapsed >= 0.5

    frame clustering
        print Cluster Setup ...
        do salt raet road cluster load setup
        go next

    frame pillar
        print Pillaring
        enter
            do salt load pillar
        go loading

    frame loading
        print Loading
        enter
            do salt load modules
        go latestart

    frame latestart
        # Start late frames that need the pillar/modules to be available
        # Start the master events loop
        bid start masterevents
        # Start Beacon
        bid start beacon
        go router

    frame router
        # start the manager framer
        bid start manager #start alive presence from minion side
        do salt raet router minion
        go pillar if .salt.var.pillar_refresh
        go loading if .salt.var.module_refresh

    frame abort
        bid stop all

framer eventing be inactive first event
    frame event
        do salt raet eventer
        do salt raet stats eventer minion

framer functionmanager be inactive first setup
    frame setup
        go shell
        go nix
    frame shell
        let me if .salt.etc.shell_jobber
        do salt raet shell jobber
        do salt raet shell jobber check
    frame nix
        do salt raet nix jobber

framer manager be inactive first start at 10.0
    frame start
        do salt raet road stack manager per inode ".salt.road.manor"

framer beacon be inactive first start
    frame start
        do salt raet beacon

framer masterevents be inactive first start
    frame start
        do salt raet master events

# Framer for handling outbound traffic
framer outbound be inactive first start
    frame start
        do salt raet lane stack service tx
        do salt raet road stack service tx


framer scheduler be inactive first start
    frame start
        do salt schedule
