Interstellar

Post-Creation Automation

Adding Provisioners for Setup

The volatile gases erupting from fresh fissures on Epsilon Eridani b had turned the air into a hazy cauldron, forcing the team to don full environmental suits even within the pressurized zones of Alpha Base. Emergency beacons pulsed rhythmically, syncing with the colony’s expanding grid of habitats and outposts, each one a testament to their modular prowess. But raw provisioning wasn’t enough—the life-support systems required intricate post-setup: calibrating oxygen recyclers, initializing bio-filters, tasks too nuanced for the provider alone. In the mobile command rover, shielded against the toxic plumes, Pilot Jax Harlan took the helm for the session, his rugged features set in determination as he interfaced with the drone control panel.

“Modules have us scaling fast, but creating a habitat is just step one,” Jax said, his voice gravelly over the comms. “We need automation for what comes after: booting up systems, running scripts, configuring software. Provisioners handle that—blocks in resources or modules that execute commands post-creation, like installing apps on a new device or priming our life-support against these gas attacks.”

Captain Elara Voss adjusted her helmet’s visor, scanning external cams for encroaching vents. “The anomalies are relentless. Provisioners will automate setups we can’t hardcode. Jax, walk us through adding them for the life-support systems.”

Engineer Mira Sol nodded, her suit’s implants linking to the shared config. “They’re a last resort—prefer provider features if possible—but ideal for one-off scripts.”

Dr. Kai Ren monitored toxin levels, his data pad warning of spikes. “Calibrate filters based on real-time gases; provisioners can run sensor-tied scripts.”

Lena Thorpe, suited up and eager, flexed her gloved fingers. “Like hooks in code? Run after build?”

“You got it,” Jax replied, projecting a module enhancement. “Provisioners attach to resources: ‘local-exec’ for commands on your machine, ‘remote-exec’ for the created resource via SSH/WinRM. They trigger on create (default) or destroy with ‘when = destroy’.”

He updated the habitat module:

// modules/habitat/main.tf
resource "alien_env_habitat" "this" {
  // ... existing args

  provisioner "local-exec" {
    command = "echo 'Habitat ${var.name} created at ${var.location}' >> deployment_log.txt"
  }

  provisioner "remote-exec" {
    inline = [
      "sudo systemctl start life_support.service",
      "calibrate_oxygen --level ${data.alien_env_planetary_scan.current_env.oxygen_density}",
      "initialize_filters --gas_profile '${join(",", data.alien_env_planetary_scan.current_env.toxin_list)}'"
    ]

    connection {
      type     = "ssh"
      user     = "admin"
      private_key = file("~/.ssh/odyssey_key")
      host     = self.connection_host  // References resource attribute
    }
  }

  provisioner "local-exec" {
    when    = destroy
    command = "echo 'Habitat ${self.name} destroyed' >> deployment_log.txt"
  }
}

“‘local-exec’ runs locally—here, logging,” Jax explained. “Simple ‘command’ or ‘script’ path. ‘remote-exec’ connects to the habitat’s endpoint post-creation, running ‘inline’ commands or scripts. ‘connection’ block sets access—SSH in our case, using resource attrs like ‘self.connection_host’.”

Kai interjected: “Inline array for multi-line. Pass dynamic data from data sources or vars.”

Mira added: “If it fails, the resource taints for re-creation on next apply. Use ‘on_failure = continue’ to proceed anyway.”

The team integrated: Lena added a local-exec for notifications; Mira remote-exec’d security scans; Elara and Kai scripted bio-integrations, tying to scans. As gases billowed, a new habitat came online seamlessly, provisioners auto-calibrating life-support without manual intervention.

Jax logged the success. “Automation complete. Tomorrow, we manage distinct zones with workspaces—as the planet fractures into varied hells.”

The rover rumbled onward, vents hissing threats, but their code now breathed life into machines with post-creation precision.