ansible_tower: Add custom_virtualenv attribute when applicable (#60200)

In Ansible Tower/AWX, there are three kinds of objects that can be tied
to custom python virtual environment:
  - job template
  - project
  - organization

This patch updates the three ansible modules that creates those objects
so that the 'custom_virtualenv' attribute can be set if specified.

Testing Done: via a playbook, test organization, projet then template creation
without any 'custom_virtualenv' attribute specified. Check that the
resources get created and that their python env is set to default. Then
re-do the same test but this time with the 'custom_virtualenv' attribute
specified. Ensure in AWX UI that those resources have the right
'custom_virtualenv' set.
This commit is contained in:
Mathieu Mallet
2019-08-26 15:30:32 +02:00
committed by AlanCoding
parent 85d5387f31
commit a026838f77
3 changed files with 30 additions and 2 deletions

View File

@@ -191,6 +191,13 @@ options:
description:
- Maximum time in seconds to wait for a job to finish (server-side).
type: int
custom_virtualenv:
version_added: "2.9"
description:
- Local absolute file path containing a custom Python virtualenv to use.
type: str
required: False
default: ''
state:
description:
- Desired state of the resource.
@@ -218,6 +225,7 @@ EXAMPLES = '''
tower_config_file: "~/tower_cli.cfg"
survey_enabled: yes
survey_spec: "{{ lookup('file', 'my_survey.json') }}"
custom_virtualenv: "/var/lib/awx/venv/custom-venv/"
'''
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
@@ -298,6 +306,7 @@ def main():
playbook=dict(required=True),
credential=dict(default=''),
vault_credential=dict(default=''),
custom_virtualenv=dict(type='str', required=False, default=''),
forks=dict(type='int'),
limit=dict(default=''),
verbosity=dict(type='int', choices=[0, 1, 2, 3, 4], default=0),