-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
groups: implementation of named groups
- Loading branch information
Showing
6 changed files
with
179 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* demonstrates using modules containing named groups */ | ||
param "jsonfile" { | ||
default = "test.json" | ||
} | ||
|
||
file.content "jsonfile" { | ||
destination = "{{param `jsonfile`}}" | ||
content = "{}" | ||
} | ||
|
||
module "groupedModule.hcl" "test1" { | ||
params = { | ||
jsonfile = "{{param `jsonfile`}}" | ||
name = "test1" | ||
value = "test1-val" | ||
} | ||
|
||
depends = ["file.content.jsonfile"] | ||
} | ||
|
||
module "groupedModule.hcl" "test2" { | ||
params = { | ||
jsonfile = "{{param `jsonfile`}}" | ||
name = "test2" | ||
value = "test2-val" | ||
} | ||
|
||
depends = ["file.content.jsonfile"] | ||
} | ||
|
||
module "groupedModule.hcl" "test3" { | ||
params = { | ||
jsonfile = "{{param `jsonfile`}}" | ||
name = "test3" | ||
value = "test3-val" | ||
} | ||
|
||
depends = ["file.content.jsonfile"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* this module allows you to set a field on the root object of a json file. | ||
Because this relies on updating a file in place using a temporary file, it | ||
uses a group to ensure it is not run multiple times in parallel. */ | ||
|
||
param "jsonfile" { | ||
default = "test.json" | ||
} | ||
|
||
param "name" { | ||
default = "field" | ||
} | ||
|
||
param "value" { | ||
default = "value" | ||
} | ||
|
||
task "update" { | ||
check = "cat {{param `jsonfile`}} | jq -r -e '.{{param `name`}}'" | ||
apply = "cat {{param `jsonfile`}} | jq '. + {\"{{param `name`}}\": \"{{param `value`}}\"}' > /tmp/{{param `jsonfile`}} && mv /tmp/{{param `jsonfile`}} {{param `jsonfile`}}" | ||
group = "groupedModule" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
task "install-tree" { | ||
check = "dpkg -s tree >/dev/null 2>&1" | ||
apply = "apt-get install -y tree" | ||
group = "apt" | ||
} | ||
|
||
task "install-jq" { | ||
check = "dpkg -s jq >/dev/null 2>&1" | ||
apply = "apt-get install -y jq" | ||
group = "apt" | ||
} | ||
|
||
task "install-build-essential" { | ||
check = "dpkg -s build-essential >/dev/null 2>&1" | ||
apply = "apt-get install -y build-essential" | ||
group = "apt" | ||
} |