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
0bd92d81
Commit
0bd92d81
authored
Jun 19, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3262 from j2sol/add-host-name
make name the parameter, with hostname as alias
parents
5b1babbd
10748961
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
lib/ansible/runner/action_plugins/add_host.py
+6
-6
library/inventory/add_host
+3
-2
No files found.
lib/ansible/runner/action_plugins/add_host.py
View file @
0bd92d81
...
@@ -49,15 +49,15 @@ class ActionModule(object):
...
@@ -49,15 +49,15 @@ class ActionModule(object):
result
=
{
'changed'
:
True
}
result
=
{
'changed'
:
True
}
# Parse out any hostname:port patterns
# Parse out any hostname:port patterns
new_
hostname
=
args
.
get
(
'hostname'
,
args
.
get
(
'
name'
,
None
))
new_
name
=
args
.
get
(
'name'
,
args
.
get
(
'host
name'
,
None
))
vv
(
"creating host via 'add_host': hostname=
%
s"
%
new_
host
name
)
vv
(
"creating host via 'add_host': hostname=
%
s"
%
new_name
)
if
":"
in
new_
host
name
:
if
":"
in
new_name
:
new_
hostname
,
new_port
=
new_host
name
.
split
(
":"
)
new_
name
,
new_port
=
new_
name
.
split
(
":"
)
args
[
'ansible_ssh_port'
]
=
new_port
args
[
'ansible_ssh_port'
]
=
new_port
# create host and get inventory
# create host and get inventory
new_host
=
Host
(
new_
host
name
)
new_host
=
Host
(
new_name
)
inventory
=
self
.
runner
.
inventory
inventory
=
self
.
runner
.
inventory
# Add any variables to the new_host
# Add any variables to the new_host
...
@@ -83,7 +83,7 @@ class ActionModule(object):
...
@@ -83,7 +83,7 @@ class ActionModule(object):
vv
(
"added host to group via add_host module:
%
s"
%
group_name
)
vv
(
"added host to group via add_host module:
%
s"
%
group_name
)
result
[
'new_groups'
]
=
groupnames
.
split
(
","
)
result
[
'new_groups'
]
=
groupnames
.
split
(
","
)
result
[
'new_host'
]
=
new_
host
name
result
[
'new_host'
]
=
new_name
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
...
...
library/inventory/add_host
View file @
0bd92d81
...
@@ -10,6 +10,7 @@ description:
...
@@ -10,6 +10,7 @@ description:
version_added: "0.9"
version_added: "0.9"
options:
options:
name:
name:
aliases: [ 'hostname' ]
description:
description:
- The hostname/ip of the host to add to the inventory, can include a colon and a port number.
- The hostname/ip of the host to add to the inventory, can include a colon and a port number.
required: true
required: true
...
@@ -23,10 +24,10 @@ author: Seth Vidal
...
@@ -23,10 +24,10 @@ author: Seth Vidal
EXAMPLES
=
'''
EXAMPLES
=
'''
# add host to group 'just_created' with variable foo=42
# add host to group 'just_created' with variable foo=42
- add_host:
host
name=${ip_from_ec2} groups=just_created foo=42
- add_host: name=${ip_from_ec2} groups=just_created foo=42
# add a host with a non-standard port local to your machines
# add a host with a non-standard port local to your machines
- add_host:
host
name='${new_ip}:${new_port}'
- add_host: name='${new_ip}:${new_port}'
# add a host alias that we reach through a tunnel
# add a host alias that we reach through a tunnel
- add_host: hostname=${new_ip}
- add_host: hostname=${new_ip}
...
...
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