mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 06:17:36 -02:30
Revert EE selectable work in favor of rewriting later
This commit is contained in:
@@ -27,9 +27,9 @@ from awx.main.utils.mem_inventory import MemInventory, dict_to_mem_data
|
|||||||
from awx.main.utils.safe_yaml import sanitize_jinja
|
from awx.main.utils.safe_yaml import sanitize_jinja
|
||||||
|
|
||||||
# other AWX imports
|
# other AWX imports
|
||||||
from awx.main.models.execution_environments import ExecutionEnvironment
|
|
||||||
from awx.main.models.rbac import batch_role_ancestor_rebuilding
|
from awx.main.models.rbac import batch_role_ancestor_rebuilding
|
||||||
from awx.main.utils import ignore_inventory_computed_fields, get_licenser
|
from awx.main.utils import ignore_inventory_computed_fields, get_licenser
|
||||||
|
from awx.main.utils.execution_environments import get_default_execution_environment
|
||||||
from awx.main.signals import disable_activity_stream
|
from awx.main.signals import disable_activity_stream
|
||||||
from awx.main.constants import STANDARD_INVENTORY_UPDATE_ENV
|
from awx.main.constants import STANDARD_INVENTORY_UPDATE_ENV
|
||||||
from awx.main.utils.pglock import advisory_lock
|
from awx.main.utils.pglock import advisory_lock
|
||||||
@@ -67,17 +67,16 @@ class AnsibleInventoryLoader(object):
|
|||||||
/usr/bin/ansible/ansible-inventory -i hosts --list
|
/usr/bin/ansible/ansible-inventory -i hosts --list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, source, execution_environment, verbosity=0):
|
def __init__(self, source, verbosity=0):
|
||||||
self.source = source
|
self.source = source
|
||||||
self.verbosity = verbosity
|
self.verbosity = verbosity
|
||||||
self.execution_environment = execution_environment
|
|
||||||
|
|
||||||
def get_base_args(self):
|
def get_base_args(self):
|
||||||
bargs = ['podman', 'run', '--user=root', '--quiet']
|
bargs = ['podman', 'run', '--user=root', '--quiet']
|
||||||
bargs.extend(['-v', '{0}:{0}:Z'.format(self.source)])
|
bargs.extend(['-v', '{0}:{0}:Z'.format(self.source)])
|
||||||
for key, value in STANDARD_INVENTORY_UPDATE_ENV.items():
|
for key, value in STANDARD_INVENTORY_UPDATE_ENV.items():
|
||||||
bargs.extend(['-e', '{0}={1}'.format(key, value)])
|
bargs.extend(['-e', '{0}={1}'.format(key, value)])
|
||||||
ee = self.execution_environment
|
ee = get_default_execution_environment()
|
||||||
|
|
||||||
if settings.IS_K8S:
|
if settings.IS_K8S:
|
||||||
logger.warning('This command is not able to run on kubernetes-based deployment. This action should be done using the API.')
|
logger.warning('This command is not able to run on kubernetes-based deployment. This action should be done using the API.')
|
||||||
@@ -164,13 +163,6 @@ class Command(BaseCommand):
|
|||||||
metavar='v',
|
metavar='v',
|
||||||
help='value of host variable specified by --enabled-var that indicates host is enabled/online.',
|
help='value of host variable specified by --enabled-var that indicates host is enabled/online.',
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
'--execution-environment',
|
|
||||||
dest='execution_environment',
|
|
||||||
type=str,
|
|
||||||
default='Default execution environment',
|
|
||||||
help='name of the execution environment to use'
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--group-filter',
|
'--group-filter',
|
||||||
dest='group_filter',
|
dest='group_filter',
|
||||||
@@ -859,7 +851,7 @@ class Command(BaseCommand):
|
|||||||
logger.info('Updating inventory %d: %s' % (inventory.pk, inventory.name))
|
logger.info('Updating inventory %d: %s' % (inventory.pk, inventory.name))
|
||||||
|
|
||||||
# Create ad-hoc inventory source and inventory update objects
|
# Create ad-hoc inventory source and inventory update objects
|
||||||
ee = ExecutionEnvironment.objects.get(name=options.get('execution_environment'))
|
ee = get_default_execution_environment()
|
||||||
with ignore_inventory_computed_fields():
|
with ignore_inventory_computed_fields():
|
||||||
source = Command.get_source_absolute_path(raw_source)
|
source = Command.get_source_absolute_path(raw_source)
|
||||||
|
|
||||||
@@ -872,11 +864,13 @@ class Command(BaseCommand):
|
|||||||
execution_environment=ee,
|
execution_environment=ee,
|
||||||
)
|
)
|
||||||
inventory_update = inventory_source.create_inventory_update(
|
inventory_update = inventory_source.create_inventory_update(
|
||||||
_eager_fields=dict(status='running', job_args=json.dumps(sys.argv), job_env=dict(os.environ.items()), job_cwd=os.getcwd(), execution_environment=ee)
|
_eager_fields=dict(
|
||||||
|
status='running', job_args=json.dumps(sys.argv), job_env=dict(os.environ.items()), job_cwd=os.getcwd(), execution_environment=ee
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = AnsibleInventoryLoader(source=source,execution_environment=ee, verbosity=verbosity).load()
|
data = AnsibleInventoryLoader(source=source, verbosity=verbosity).load()
|
||||||
logger.debug('Finished loading from source: %s', source)
|
logger.debug('Finished loading from source: %s', source)
|
||||||
|
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
|||||||
Reference in New Issue
Block a user