Remove refresh_inventory flag for callbacks; make it the default behavior instead.

This commit is contained in:
Chris Church
2014-07-08 15:44:02 -04:00
parent 0e7fcb239e
commit 48906416ac
2 changed files with 6 additions and 15 deletions

View File

@@ -18,16 +18,9 @@ The response will return status 202 if the request is valid, 403 for an
invalid host config key, or 400 if the host cannot be determined from the invalid host config key, or 400 if the host cannot be determined from the
address making the request. address making the request.
_(New in Ansible Tower 2.0.0)_ By default, the host must already be present in _(New in Ansible Tower 2.0.0)_ If the associated inventory has the
inventory for the callback to succeed. The `refresh_inventory` parameter can `update_on_launch` flag set and if the `update_cache_timeout` has expired, the
be passed to the callback to trigger an inventory sync prior to searching for callback will perform an inventory sync to find a matching host.
the host and running the job. The associated inventory must have the
`update_on_launch` flag set and will only refresh if the `update_cache_timeout`
has expired.
For example, using curl:
curl --data-urlencode "host_config_key=HOST_CONFIG_KEY&refresh_inventory=1" http://server/api/v1/job_templates/N/callback/
A GET request may be used to verify that the correct host will be selected. A GET request may be used to verify that the correct host will be selected.
This request must authenticate as a valid user with permission to edit the This request must authenticate as a valid user with permission to edit the

View File

@@ -1401,12 +1401,10 @@ class JobTemplateCallback(GenericAPIView):
job_template = self.get_object() job_template = self.get_object()
# Attempt to find matching hosts based on remote address. # Attempt to find matching hosts based on remote address.
matching_hosts = self.find_matching_hosts() matching_hosts = self.find_matching_hosts()
# If refresh_inventory flag is provided and the host is not found, # If the host is not found, update the inventory before trying to
# update the inventory before trying to match the host. # match again.
refresh_inventory = request.DATA.get('refresh_inventory', '')
refresh_inventory = bool(refresh_inventory and refresh_inventory[0].lower() in ('t', 'y', '1'))
inventory_sources_already_updated = [] inventory_sources_already_updated = []
if refresh_inventory and len(matching_hosts) != 1: if len(matching_hosts) != 1:
inventory_sources = job_template.inventory.inventory_sources.filter(active=True, update_on_launch=True) inventory_sources = job_template.inventory.inventory_sources.filter(active=True, update_on_launch=True)
inventory_update_pks = set() inventory_update_pks = set()
for inventory_source in inventory_sources: for inventory_source in inventory_sources: