Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
787477fc
Commit
787477fc
authored
Jun 15, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'danzilio-default_facts'
parents
3bae1d24
6cda4fa5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
provisioner/puppet-masterless/provisioner.go
provisioner/puppet-masterless/provisioner.go
+6
-0
provisioner/puppet-masterless/provisioner_test.go
provisioner/puppet-masterless/provisioner_test.go
+44
-0
website/source/docs/provisioners/puppet-masterless.html.markdown
.../source/docs/provisioners/puppet-masterless.html.markdown
+14
-0
No files found.
provisioner/puppet-masterless/provisioner.go
View file @
787477fc
...
...
@@ -96,6 +96,12 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
p
.
config
.
WorkingDir
=
p
.
config
.
StagingDir
}
if
p
.
config
.
Facter
==
nil
{
p
.
config
.
Facter
=
make
(
map
[
string
]
string
)
}
p
.
config
.
Facter
[
"packer_build_name"
]
=
p
.
config
.
PackerBuildName
p
.
config
.
Facter
[
"packer_builder_type"
]
=
p
.
config
.
PackerBuilderType
// Validation
var
errs
*
packer
.
MultiError
if
p
.
config
.
HieraConfigPath
!=
""
{
...
...
provisioner/puppet-masterless/provisioner_test.go
View file @
787477fc
...
...
@@ -133,3 +133,47 @@ func TestProvisionerPrepare_modulePaths(t *testing.T) {
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
func
TestProvisionerPrepare_facterFacts
(
t
*
testing
.
T
)
{
config
:=
testConfig
()
delete
(
config
,
"facter"
)
p
:=
new
(
Provisioner
)
err
:=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
// Test with malformed fact
config
[
"facter"
]
=
"fact=stringified"
p
=
new
(
Provisioner
)
err
=
p
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should be an error"
)
}
// Test with a good one
td
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"error: %s"
,
err
)
}
defer
os
.
RemoveAll
(
td
)
facts
:=
make
(
map
[
string
]
string
)
facts
[
"fact_name"
]
=
"fact_value"
config
[
"facter"
]
=
facts
p
=
new
(
Provisioner
)
err
=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
// Make sure the default facts are present
delete
(
config
,
"facter"
)
p
=
new
(
Provisioner
)
err
=
p
.
Prepare
(
config
)
if
p
.
config
.
Facter
==
nil
{
t
.
Fatalf
(
"err: Default facts are not set in the Puppet provisioner!"
)
}
}
website/source/docs/provisioners/puppet-masterless.html.markdown
View file @
787477fc
...
...
@@ -113,3 +113,17 @@ can contain various template variables, defined below:
*
`ModulePath`
- The paths to the module directories.
*
`Sudo`
- A boolean of whether to
`sudo`
the command or not, depending on
the value of the
`prevent_sudo`
configuration.
## Default Facts
In addition to being able to specify custom Facter facts using the
`facter`
configuration, the provisioner automatically defines certain commonly useful
facts:
*
`packer_build_name`
is set to the name of the build that Packer is running.
This is most useful when Packer is making multiple builds and you want to
distinguish them in your Hiera hierarchy.
*
`packer_builder_type`
is the type of the builder that was used to create the
machine that Puppet is running on. This is useful if you want to run only
certain parts of your Puppet code on systems built with certain builders.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment