mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 22:16:00 -03:30
Remove explicit eula acceptance
This commit is contained in:
@@ -24,7 +24,7 @@ from awx.api.generics import APIView
|
|||||||
from awx.conf.registry import settings_registry
|
from awx.conf.registry import settings_registry
|
||||||
from awx.main.analytics import all_collectors
|
from awx.main.analytics import all_collectors
|
||||||
from awx.main.ha import is_ha_environment
|
from awx.main.ha import is_ha_environment
|
||||||
from awx.main.utils import get_awx_version, get_custom_venv_choices, to_python_boolean
|
from awx.main.utils import get_awx_version, get_custom_venv_choices
|
||||||
from awx.main.utils.licensing import validate_entitlement_manifest
|
from awx.main.utils.licensing import validate_entitlement_manifest
|
||||||
from awx.api.versioning import reverse, drf_reverse
|
from awx.api.versioning import reverse, drf_reverse
|
||||||
from awx.main.constants import PRIVILEGE_ESCALATION_METHODS
|
from awx.main.constants import PRIVILEGE_ESCALATION_METHODS
|
||||||
@@ -313,16 +313,6 @@ class ApiV2ConfigView(APIView):
|
|||||||
def post(self, request):
|
def post(self, request):
|
||||||
if not isinstance(request.data, dict):
|
if not isinstance(request.data, dict):
|
||||||
return Response({"error": _("Invalid subscription data")}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({"error": _("Invalid subscription data")}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
if "eula_accepted" not in request.data:
|
|
||||||
return Response({"error": _("Missing 'eula_accepted' property")}, status=status.HTTP_400_BAD_REQUEST)
|
|
||||||
try:
|
|
||||||
eula_accepted = to_python_boolean(request.data["eula_accepted"])
|
|
||||||
except ValueError:
|
|
||||||
return Response({"error": _("'eula_accepted' value is invalid")}, status=status.HTTP_400_BAD_REQUEST)
|
|
||||||
|
|
||||||
if not eula_accepted:
|
|
||||||
return Response({"error": _("'eula_accepted' must be True")}, status=status.HTTP_400_BAD_REQUEST)
|
|
||||||
request.data.pop("eula_accepted")
|
|
||||||
try:
|
try:
|
||||||
data_actual = json.dumps(request.data)
|
data_actual = json.dumps(request.data)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ options:
|
|||||||
- file path to a Red Hat subscription manifest (a .zip file)
|
- file path to a Red Hat subscription manifest (a .zip file)
|
||||||
required: True
|
required: True
|
||||||
type: str
|
type: str
|
||||||
eula_accepted:
|
|
||||||
description:
|
|
||||||
- Whether or not the EULA is accepted.
|
|
||||||
required: True
|
|
||||||
type: bool
|
|
||||||
force:
|
force:
|
||||||
description:
|
description:
|
||||||
- By default, the license manifest will only be applied if Tower is currently
|
- By default, the license manifest will only be applied if Tower is currently
|
||||||
@@ -46,7 +41,6 @@ EXAMPLES = '''
|
|||||||
- name: Set the license using a file
|
- name: Set the license using a file
|
||||||
tower_license:
|
tower_license:
|
||||||
manifest: "/tmp/my_manifest.zip"
|
manifest: "/tmp/my_manifest.zip"
|
||||||
eula_accepted: True
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
@@ -58,16 +52,12 @@ def main():
|
|||||||
module = TowerAPIModule(
|
module = TowerAPIModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
manifest=dict(type='str', required=True),
|
manifest=dict(type='str', required=True),
|
||||||
eula_accepted=dict(type='bool', required=True),
|
|
||||||
force=dict(type='bool', required=False),
|
force=dict(type='bool', required=False),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
json_output = {'changed': False}
|
json_output = {'changed': False}
|
||||||
|
|
||||||
if not module.params.get('eula_accepted'):
|
|
||||||
module.fail_json(msg='You must accept the EULA by passing in the param eula_accepted as True')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
manifest = base64.b64encode(open(module.params.get('manifest'), 'rb').read())
|
manifest = base64.b64encode(open(module.params.get('manifest'), 'rb').read())
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
@@ -94,7 +84,7 @@ def main():
|
|||||||
# Do the actual install, if we need to
|
# Do the actual install, if we need to
|
||||||
if perform_install:
|
if perform_install:
|
||||||
json_output['changed'] = True
|
json_output['changed'] = True
|
||||||
module.post_endpoint('config', data={'eula_accepted': True, 'manifest': manifest.decode()})
|
module.post_endpoint('config', data={'manifest': manifest.decode()})
|
||||||
|
|
||||||
module.exit_json(**json_output)
|
module.exit_json(**json_output)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user