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
c5503ee0
Commit
c5503ee0
authored
Jun 22, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'lyrixx-ansible-inventory-groups'
parents
7c8e86c9
11e32573
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
provisioner/ansible-local/provisioner.go
provisioner/ansible-local/provisioner.go
+12
-1
website/source/docs/provisioners/ansible-local.html.markdown
website/source/docs/provisioners/ansible-local.html.markdown
+10
-0
No files found.
provisioner/ansible-local/provisioner.go
View file @
c5503ee0
...
...
@@ -49,6 +49,9 @@ type Config struct {
// The optional inventory file
InventoryFile
string
`mapstructure:"inventory_file"`
// The optional inventory groups
InventoryGroups
[]
string
`mapstructure:"inventory_groups"`
}
type
Provisioner
struct
{
...
...
@@ -158,7 +161,15 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
return
fmt
.
Errorf
(
"Error preparing inventory file: %s"
,
err
)
}
defer
os
.
Remove
(
tf
.
Name
())
if
len
(
p
.
config
.
InventoryGroups
)
!=
0
{
content
:=
""
for
_
,
group
:=
range
p
.
config
.
InventoryGroups
{
content
+=
fmt
.
Sprintf
(
"[%s]
\n
127.0.0.1
\n
"
,
group
)
}
_
,
err
=
tf
.
Write
([]
byte
(
content
))
}
else
{
_
,
err
=
tf
.
Write
([]
byte
(
"127.0.0.1"
))
}
if
err
!=
nil
{
tf
.
Close
()
return
fmt
.
Errorf
(
"Error preparing inventory file: %s"
,
err
)
...
...
website/source/docs/provisioners/ansible-local.html.markdown
View file @
c5503ee0
...
...
@@ -41,6 +41,16 @@ Optional:
*
`extra_arguments`
(array of strings) - An array of extra arguments to pass to the
ansible command. By default, this is empty.
*
`inventory_groups`
(string) - You can let Packer generate a temporary inventory
for you. It will contains only
`127.0.0.1`
. Thanks to
`inventory_groups`
,
packer will set the current machine into different groups and will
generate an inventory like:
[my_group_1]
127.
0.0.1
[my_group_2]
127.
0.0.1
*
`inventory_file`
(string) - The inventory file to be used by ansible.
This file must exist on your local system and will be uploaded to the
remote machine.
...
...
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