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
41aaad69
Commit
41aaad69
authored
Oct 11, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make add_host clear the inventory pattern cache, add some more aliases. Fixes #4442.
parent
9c9ec52b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
lib/ansible/inventory/__init__.py
+4
-0
lib/ansible/runner/action_plugins/add_host.py
+6
-2
library/inventory/add_host
+2
-2
No files found.
lib/ansible/inventory/__init__.py
View file @
41aaad69
...
...
@@ -266,6 +266,10 @@ class Inventory(object):
self
.
_pattern_hosts
[
pattern
]
=
results
return
self
.
_pattern_hosts
[
pattern
]
def
clear_pattern_cache
(
self
):
''' called exclusively by the add_host plugin to allow patterns to be recalculated '''
self
.
_pattern_hosts
=
{}
def
groups_for_host
(
self
,
host
):
results
=
[]
groups
=
self
.
get_groups
()
...
...
lib/ansible/runner/action_plugins/add_host.py
View file @
41aaad69
...
...
@@ -68,14 +68,14 @@ class ActionModule(object):
# 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
])
groupnames
=
args
.
get
(
'groupname'
,
args
.
get
(
'groups'
,
''
))
groupnames
=
args
.
get
(
'groupname'
,
args
.
get
(
'groups'
,
args
.
get
(
'group'
,
''
)
))
# add it to the group if that was specified
if
groupnames
!=
''
:
for
group_name
in
groupnames
.
split
(
","
):
...
...
@@ -88,6 +88,10 @@ class ActionModule(object):
result
[
'new_groups'
]
=
groupnames
.
split
(
","
)
result
[
'new_host'
]
=
new_name
# clear pattern caching completely since it's unpredictable what
# patterns may have referenced the group
inventory
.
clear_pattern_cache
()
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
result
)
...
...
library/inventory/add_host
View file @
41aaad69
...
...
@@ -10,12 +10,12 @@ description:
version_added: "0.9"
options:
name:
aliases: [ 'hostname' ]
aliases: [ 'hostname'
, 'host'
]
description:
- The hostname/ip of the host to add to the inventory, can include a colon and a port number.
required: true
groups:
aliases: [ 'groupname' ]
aliases: [ 'groupname'
, 'group'
]
description:
- The groups to add the hostname to, comma separated.
required: false
...
...
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