Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend startup join domain to linux #197

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions src/go/app/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ func (this Startup) PreStart(ctx context.Context, exp *types.Experiment) error {
continue
}

// Check to see if a scenario exists for this experiment and if it
// contains a "startup" app. If so, store it for later use
var startupApp ifaces.ScenarioApp
for _, app := range exp.Apps() {
if app.Name() == "startup" {
startupApp = app
}
}

switch strings.ToLower(node.Hardware().OSType()) {
case "linux", "rhel", "centos":
var (
Expand Down Expand Up @@ -138,6 +147,26 @@ func (this Startup) PreStart(ctx context.Context, exp *types.Experiment) error {
if err := tmpl.CreateFileFromTemplate("linux_interfaces.tmpl", node, ifaceFile); err != nil {
return fmt.Errorf("generating linux interfaces script: %w", err)
}

if startupApp != nil {
for _, host := range startupApp.Hosts() {
if host.Hostname() == node.General().Hostname() {

var domainFile = startupDir + "/" + node.General().Hostname() + "-domain.sh"

node.AddInject(
domainFile,
"/etc/phenix/startup/4_domain-start.sh",
"0755", "",
)

if err := tmpl.CreateFileFromTemplate("linux_domain.tmpl", host.Metadata(), domainFile); err != nil {
return fmt.Errorf("generating linux domain script: %w", err)
}
}
}
}

case "windows":
startupFile := startupDir + "/" + node.General().Hostname() + "-startup.ps1"

Expand Down Expand Up @@ -178,15 +207,12 @@ func (this Startup) PreStart(ctx context.Context, exp *types.Experiment) error {
Metadata: make(map[string]interface{}),
}

// Check to see if a scenario exists for this experiment and if it
// contains a "startup" app. If so, see if this node has a metadata entry
// If startup app exists, see if this node has a metadata entry
// in the scenario app configuration.
for _, app := range exp.Apps() {
if app.Name() == "startup" {
for _, host := range app.Hosts() {
if host.Hostname() == node.General().Hostname() {
data.Metadata = host.Metadata()
}
if startupApp != nil {
for _, host := range startupApp.Hosts() {
if host.Hostname() == node.General().Hostname() {
data.Metadata = host.Metadata()
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/go/tmpl/templates/linux_domain.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "{{ .domain_controller.password }}" | realm join --user={{ .domain_controller.username }} {{ .domain_controller.domain }}