Skip to content

Commit

Permalink
add: Add name field to the qa-ctl playbook configuration #2306
Browse files Browse the repository at this point in the history
  • Loading branch information
jmv74211 committed Dec 9, 2021
1 parent eb3813d commit 59115ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,13 @@ def get_deployment_configuration(self, instances):

return deployment_configuration

def get_tasks_configuration(self, instances, playbooks, playbook_path='local'):
def get_tasks_configuration(self, instances, playbook_info, playbook_type='local'):
"""Generate the qa-ctl configuration required for running ansible tasks.
Args:
instances (list(ConfigInstance)): List of config-instances to deploy.
playbooks (list(str)): List of playbooks path to run.
playbook_path (str): Playbook path configuration [local or remote_url].
playbook_info (dict): Playbook dictionary info. {playbook_name: playbook_path}
playbook_type (str): Playbook path configuration [local or remote_url].
Returns:
dict: Configuration block corresponding to the ansible tasks to run with qa-ctl.
Expand All @@ -632,8 +632,9 @@ def get_tasks_configuration(self, instances, playbooks, playbook_path='local'):
host_info = QACTLConfigGenerator.BOX_INFO[instance_box]
host_info['host'] = instance.ip

playbooks_dict = [{'local_path': playbook} if playbook_path == 'local' else
{'remote_url': playbook} for playbook in playbooks]
playbooks_dict = [{'name': playbook_name, 'local_path': playbook_path} if playbook_type == 'local' else
{'name': playbook_name, 'remote_url': playbook_path} for playbook_name, playbook_path
in playbook_info.items()]

tasks_configuration['tasks'][f"task_{index + 1}"] = {
'host_info': host_info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ def __process_tasks_data(self):

# Create runner objects. One for each playbook using the same inventory for each host
for index, playbook in enumerate(playbooks_path):
task_id = f"{task_data['playbooks'][index]['name']} task from playbook {playbook}" if 'name' in \
task_data['playbooks'][index] else f"Running playbook {playbook}"

self.ansible_runners.append(AnsibleRunner(inventory_path, playbook,
output=self.qa_ctl_configuration.ansible_output,
task_id=f"{task_id} - playbook_{index + 1}"))
task_id=task_id))

QATasksLauncher.LOGGER.debug('Tasks module data has been processed successfully')

Expand Down

0 comments on commit 59115ee

Please sign in to comment.