include tower header to insights on plan fetch

* We include a special header value in the user agent when tower proxies
requests to get per-host rules.
* This extends that header logic to when we fetch plans (playbooks)
This commit is contained in:
chris meyers
2019-03-28 10:56:56 -04:00
parent 196a6ff36c
commit 926d6a6525
3 changed files with 20 additions and 2 deletions

View File

@@ -40,10 +40,20 @@ class ActionModule(ActionBase):
username = self._task.args.get('username', None)
password = self._task.args.get('password', None)
proj_path = self._task.args.get('project_path', None)
license = self._task.args.get('awx_license_type', None)
awx_version = self._task.args.get('awx_version', None)
session = requests.Session()
session.auth = requests.auth.HTTPBasicAuth(username, password)
headers = {'Content-Type': 'application/json'}
headers = {
'Content-Type': 'application/json',
'User-Agent': '{} {} ({})'.format(
'AWX' if license == 'open' else 'Red Hat Ansible Tower',
awx_version,
license
)
}
url = '{}/r/insights/v3/maintenance?ansible=true'.format(insights_url)