mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #10206 from tchellomello/update_ee_via_operator
Commits settings.DEFAULT_EXECUTION_ENVIRONMENTS updates into the database SUMMARY Fixes: ansible/awx-operator#256 cc: @shanemcd Cannot update execution environment version in place by updating the AWX spec via awx-operator. For example, consider the scenario below: spec: tower_ee_images: - image: registry.tatu.home/ansible/awx-ee:0.1.0 name: My Custom Execution Environment The expectation would be once you modify the AWX spec to the version below, the EE should reflect this change once the awx-operator finishes its reconciliation. After: spec: tower_ee_images: - image: registry.tatu.home/ansible/awx-ee:0.2.0 name: My Custom Execution Environment -- deployment got updated - args: - receptor - --config - /etc/receptor.conf image: registry.tatu.home/ansible/awx-ee:0.2.0 imagePullPolicy: IfNotPresent name: awx-devel-ee-ee Besides the awx-operator updated the YAML deployment as expected, the change did not hit the database. awx=# select * from main_executionenvironment; id | created | modified | description | image | managed_by_tower | created_by_id | credential_id | modified_by_id | organization_id | name | pull ----+---------------+---------------+-------------+----------------+------------------+---------------+---------------+----------------+-----------------+----------------+------ 1 | 2021-05-11 15.| 2021-05-11 15.| | registry.tatu..| t | 1 | | 1 | | My Custom Exec.| |.:24:02.674302.|.:24:02.674327.| |.home/ansible/a.| | | | | |.ution Environm.| |.+00 |.+00 | |.wx-ee:0.1.0 | | | | | |.ent | (1 row) ISSUE TYPE Bugfix Pull Request COMPONENT NAME API AWX VERSION devel ADDITIONAL INFORMATION Quick proof of concept >>> settings.DEFAULT_EXECUTION_ENVIRONMENTS [{'name': 'My Custom Execution Environment', 'image': 'registry.tatu.home/ansible/awx-ee:0.2.0'}] >>> [a.name for a in ExecutionEnvironment.objects.all()] ['My Custom Execution Environment'] >>> [a.image for a in ExecutionEnvironment.objects.all()] ['registry.tatu.home/ansible/awx-ee:0.2.0'] *** updating to new but keeping name >>> _, created = ExecutionEnvironment.objects.update_or_create(name='My Custom Execution Environment', defaults={'image': 'registry.tatu.home/ansible/awx-ee:0.3.0', 'managed_by_tower': True}) >>> [a.name for a in ExecutionEnvironment.objects.all()] ['My Custom Execution Environment'] >>> [a.image for a in ExecutionEnvironment.objects.all()] ['registry.tatu.home/ansible/awx-ee:0.3.0'] *** adding a new name >>> _, created = ExecutionEnvironment.objects.update_or_create(name='My Custom Execution Environment2', defaults={'image': 'registry.tatu.home/ansible/awx-ee:0.3.0', 'managed_by_tower': True}) >>> [a.name for a in ExecutionEnvironment.objects.all()] ['My Custom Execution Environment2', 'My Custom Execution Environment'] >>> [a.image for a in ExecutionEnvironment.objects.all()] ['registry.tatu.home/ansible/awx-ee:0.3.0', 'registry.tatu.home/ansible/awx-ee:0.3.0'] Reviewed-by: Christian Adams <rooftopcellist@gmail.com> Reviewed-by: Shane McDonald <me@shanemcd.com>
This commit is contained in:
commit
7eaf1db3e0
@ -69,7 +69,7 @@ class Command(BaseCommand):
|
||||
changed = True
|
||||
|
||||
for ee in reversed(settings.DEFAULT_EXECUTION_ENVIRONMENTS):
|
||||
_, created = ExecutionEnvironment.objects.get_or_create(name=ee['name'], defaults={'image': ee['image'], 'managed_by_tower': True})
|
||||
_, created = ExecutionEnvironment.objects.update_or_create(name=ee['name'], defaults={'image': ee['image'], 'managed_by_tower': True})
|
||||
|
||||
if created:
|
||||
changed = True
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user