Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
b365e046
Commit
b365e046
authored
Feb 17, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow add_host to add hosts to multiple groups, groups is now an alias for groupname.
parent
cde233f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
19 deletions
+22
-19
CHANGELOG.md
+2
-0
lib/ansible/runner/action_plugins/add_host.py
+12
-11
library/add_host
+8
-8
No files found.
CHANGELOG.md
View file @
b365e046
...
...
@@ -45,6 +45,8 @@ Ansible Changes By Release
*
fixed ~ expansion for fileglob
*
can set ansible_ssh_user and ansible_ssh_pass in inventory variables
*
lookup plugin macros like $FILE and $ENV now work without returning arrays in variable definitions/playbooks
*
add_host module can set ports and other inventory variables
*
add_host module can add modules to multiple groups (groups=a,b,c), groups now alias for groupname
1.
0 "Eruption" -- Feb 1 2013
...
...
lib/ansible/runner/action_plugins/add_host.py
View file @
b365e046
...
...
@@ -60,7 +60,7 @@ class ActionModule(object):
# Add any variables to the new_host
for
k
in
args
.
keys
():
if
k
!=
'hostname'
and
k
!=
'groupname'
:
if
not
k
in
[
'hostname'
,
'groupname'
,
'groups'
]
:
new_host
.
set_variable
(
k
,
args
[
k
])
...
...
@@ -68,17 +68,18 @@ class ActionModule(object):
allgroup
=
inventory
.
get_group
(
'all'
)
allgroup
.
add_host
(
new_host
)
result
[
'changed'
]
=
True
groupnames
=
args
.
get
(
'groupname'
,
args
.
get
(
'groups'
,
''
))
# add it to the group if that was specified
if
'groupname'
in
args
:
if
not
inventory
.
get_group
(
args
[
'groupname'
]
):
new_group
=
Group
(
args
[
'groupname'
])
inventory
.
add_group
(
new_group
)
ngobj
=
inventory
.
get_group
(
args
[
'groupname'
]
)
ngobj
.
add_host
(
new_host
)
vv
(
"
created 'add_host' ActionModule: groupname=
%
s"
%
(
args
[
'groupname'
])
)
result
[
'new_group
'
]
=
args
[
'groupname'
]
if
groupnames
!=
''
:
for
group_name
in
groupnames
.
split
(
","
):
if
not
inventory
.
get_group
(
group_name
):
new_group
=
Group
(
group_name
)
inventory
.
add_group
(
new_group
)
grp
=
inventory
.
get_group
(
group_name
)
grp
.
add_host
(
new_host
)
vv
(
"
added host to group via add_host module:
%
s"
%
group_name
)
result
[
'new_group
s'
]
=
groupnames
.
split
(
","
)
result
[
'new_host'
]
=
args
[
'hostname'
]
...
...
library/add_host
View file @
b365e046
...
...
@@ -13,14 +13,15 @@ options:
description:
- The hostname/ip of the host to add to the inventory
required: true
groupname:
groups:
aliases: [ 'groupname' ]
description:
- The group
name to add the hostname to
.
- The group
s to add the hostname to, comma seperated
.
required: false
author: Seth Vidal
examples:
- description: add host to group 'just_created'
code: add_host hostname=${ip_from_ec2create} groupname=just_created
- description add a host with a non-standard port local to your machines
code: add_host hostname='${new_ip}:${new_port}' ansible_ssh_port='${new_port}' ansible_ssh_host='${new_ip}' groupname=cloud_hosts
'''
\ No newline at end of file
- description: add host to group 'just_created' with variable foo=42
code: add_host hostname=${ip_from_ec2create} groups=just_created foo=42
- description: add a host with a non-standard port local to your machines
code: add_host hostname='${new_ip}:${new_port}'
'''
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