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
6dca95b3
Commit
6dca95b3
authored
Mar 19, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now add_host loads hostvars
parent
fd47c4d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
lib/ansible/runner/action_plugins/add_host.py
+11
-7
No files found.
lib/ansible/runner/action_plugins/add_host.py
View file @
6dca95b3
...
@@ -55,7 +55,7 @@ class ActionModule(object):
...
@@ -55,7 +55,7 @@ class ActionModule(object):
if
":"
in
new_name
:
if
":"
in
new_name
:
new_name
,
new_port
=
new_name
.
split
(
":"
)
new_name
,
new_port
=
new_name
.
split
(
":"
)
args
[
'ansible_ssh_port'
]
=
new_port
args
[
'ansible_ssh_port'
]
=
new_port
# redefine inventory and get group "all"
# redefine inventory and get group "all"
inventory
=
self
.
runner
.
inventory
inventory
=
self
.
runner
.
inventory
allgroup
=
inventory
.
get_group
(
'all'
)
allgroup
=
inventory
.
get_group
(
'all'
)
...
@@ -72,10 +72,10 @@ class ActionModule(object):
...
@@ -72,10 +72,10 @@ class ActionModule(object):
# Add any variables to the new_host
# Add any variables to the new_host
for
k
in
args
.
keys
():
for
k
in
args
.
keys
():
if
not
k
in
[
'name'
,
'hostname'
,
'groupname'
,
'groups'
]:
if
not
k
in
[
'name'
,
'hostname'
,
'groupname'
,
'groups'
]:
new_host
.
set_variable
(
k
,
args
[
k
])
new_host
.
set_variable
(
k
,
args
[
k
])
groupnames
=
args
.
get
(
'groupname'
,
args
.
get
(
'groups'
,
args
.
get
(
'group'
,
''
)))
groupnames
=
args
.
get
(
'groupname'
,
args
.
get
(
'groups'
,
args
.
get
(
'group'
,
''
)))
# add it to the group if that was specified
# add it to the group if that was specified
if
groupnames
:
if
groupnames
:
for
group_name
in
groupnames
.
split
(
","
):
for
group_name
in
groupnames
.
split
(
","
):
...
@@ -95,13 +95,17 @@ class ActionModule(object):
...
@@ -95,13 +95,17 @@ 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
(
","
)
# actually load host vars
new_host
.
vars
=
inventory
.
get_host_variables
(
new_name
,
update_cached
=
True
,
vault_password
=
inventory
.
_vault_password
)
result
[
'new_host'
]
=
new_name
result
[
'new_host'
]
=
new_name
# clear pattern caching completely since it's unpredictable what
# clear pattern caching completely since it's unpredictable what
# patterns may have referenced the group
# patterns may have referenced the group
inventory
.
clear_pattern_cache
()
inventory
.
clear_pattern_cache
()
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
...
...
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