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
52aea868
Commit
52aea868
authored
Oct 04, 2013
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow for updating host vars in add_host
parent
1688139c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
lib/ansible/runner/action_plugins/add_host.py
+12
-7
No files found.
lib/ansible/runner/action_plugins/add_host.py
View file @
52aea868
...
...
@@ -56,20 +56,25 @@ class ActionModule(object):
new_name
,
new_port
=
new_name
.
split
(
":"
)
args
[
'ansible_ssh_port'
]
=
new_port
# create host and get inventory
new_host
=
Host
(
new_name
)
# redefine inventory and get group "all"
inventory
=
self
.
runner
.
inventory
allgroup
=
inventory
.
get_group
(
'all'
)
# check if host in cache, add if not
if
new_name
in
inventory
.
_hosts_cache
:
new_host
=
inventory
.
_hosts_cache
[
new_name
]
else
:
new_host
=
Host
(
new_name
)
# only groups can be added directly to inventory
inventory
.
_hosts_cache
[
new_name
]
=
new_host
allgroup
.
add_host
(
new_host
)
# Add any variables to the new_host
for
k
in
args
.
keys
():
if
not
k
in
[
'name'
,
'hostname'
,
'groupname'
,
'groups'
]:
new_host
.
set_variable
(
k
,
args
[
k
])
# add the new host to the 'all' group
allgroup
=
inventory
.
get_group
(
'all'
)
allgroup
.
add_host
(
new_host
)
groupnames
=
args
.
get
(
'groupname'
,
args
.
get
(
'groups'
,
''
))
# add it to the group if that was specified
if
groupnames
!=
''
:
...
...
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