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
ab389d89
Commit
ab389d89
authored
Feb 17, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For consistency, add host should take a key named 'name' in addition to 'hostname'.
parent
cc9bc91a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
lib/ansible/runner/action_plugins/add_host.py
+7
-8
library/add_host
+2
-2
No files found.
lib/ansible/runner/action_plugins/add_host.py
View file @
ab389d89
...
...
@@ -40,16 +40,15 @@ class ActionModule(object):
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
dict
(
skipped
=
True
,
msg
=
'check mode not supported for this module'
))
args
=
parse_kv
(
module_args
)
if
not
'hostname'
in
args
:
raise
ae
(
"'hostname' is a required argument."
)
vv
(
"created 'add_host' ActionModule: hostname=
%
s"
%
(
args
[
'hostname'
]))
if
not
'hostname'
in
args
and
not
'name'
in
args
:
raise
ae
(
"'name' is a required argument."
)
result
=
{
'changed'
:
True
}
# Parse out any hostname:port patterns
new_hostname
=
args
[
'hostname'
]
new_hostname
=
args
.
get
(
'hostname'
,
args
.
get
(
'name'
,
None
))
vv
(
"creating host via 'add_host': hostname=
%
s"
%
new_hostname
)
if
":"
in
new_hostname
:
new_hostname
,
new_port
=
new_hostname
.
split
(
":"
)
args
[
'ansible_ssh_port'
]
=
new_port
...
...
@@ -60,7 +59,7 @@ class ActionModule(object):
# Add any variables to the new_host
for
k
in
args
.
keys
():
if
not
k
in
[
'hostname'
,
'groupname'
,
'groups'
]:
if
not
k
in
[
'
name'
,
'
hostname'
,
'groupname'
,
'groups'
]:
new_host
.
set_variable
(
k
,
args
[
k
])
...
...
@@ -81,7 +80,7 @@ class ActionModule(object):
vv
(
"added host to group via add_host module:
%
s"
%
group_name
)
result
[
'new_groups'
]
=
groupnames
.
split
(
","
)
result
[
'new_host'
]
=
args
[
'hostname'
]
result
[
'new_host'
]
=
new_hostname
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
...
...
library/add_host
View file @
ab389d89
...
...
@@ -9,9 +9,9 @@ description:
Takes variables so you can define the new hosts more fully.
version_added: 0.9
options:
host
name:
name:
description:
- The hostname/ip of the host to add to the inventory
- The hostname/ip of the host to add to the inventory
, can include a colon and a port number.
required: true
groups:
aliases: [ 'groupname' ]
...
...
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