Skip to content

Commit

Permalink
fix: roles also allow variables, support parsing them in inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhop committed May 17, 2024
1 parent d6399a5 commit 8cbf358
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/inventory/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import (
// Role contains fields that represent a single role in the inventory.
// - ID: string idenitfying the role (generally the file path to the role)
// - Modules: a []string of module names that satisfy this role
// - variables: path to the variables file for this role, if present
type Role struct {
id string
modules []string
id string
modules []string
variables string
}

// String is a stringer to return the role ID
Expand Down Expand Up @@ -104,7 +106,8 @@ func (i *Inventory) ParseRoles(ctx context.Context, logger *slog.Logger) error {
}

role.modules = mods

case "variables":
role.variables = filepath.Join(rolePath, "variables")
default:
iLogger.LogAttrs(
ctx,
Expand Down
1 change: 1 addition & 0 deletions test/mockup/inventory/roles/common/variables
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mango_role_template_var="Hi, I'm a role variable!"

0 comments on commit 8cbf358

Please sign in to comment.