ansible-sdk icon indicating copy to clipboard operation
ansible-sdk copied to clipboard

How to pass extra-vars while running the example_mesh_job.py file to run the playbook through executor receptor node.

Open itsvipul94 opened this issue 1 year ago • 1 comments

I have managed to run the desired playbook through example_mesh_job.py script successfully,

The good: the playbook is being run through the executor node as required (playbook execution is happening on receptor node and not the local sdk server)

The Bad: But , when I try to pass the extra-variables as required for running the playbook that has variables in the example_mesh_job.py, the extra-variables are not getting initialized inside the target playbook.

Issue: As I dug deeper, I FOUND that the mesh.py file that example_mesh_job.py calls does not accept extra-variables as an argument which is not the case with the example_subprocess_job.py

Content of the mesh.py


class AnsibleMeshJobExecutor(AnsibleJobExecutorBase):
    def __init__(self):
        self._running_job_info: dict[AnsibleJobStatus, _MeshJobInfo] = {}

    def _get_runner_args(self, job_def: AnsibleJobDef, options: AnsibleMeshJobOptions):
        args = {
            'private_data_dir': job_def.data_dir,
            'playbook': job_def.playbook,
        }

Content of subprocess.py ***********************************************************************************

class AnsibleSubprocessJobExecutor(AnsibleJobExecutorBase):
    """
    Basic Subprocess Job Executor
    """
    def _get_runner_args(self, job_def: AnsibleJobDef, options: AnsibleSubprocessJobOptions) -> dict[str, t.Any]:
        args = {
            'private_data_dir': job_def.data_dir,
            'playbook': job_def.playbook,
            'artifacts_handler': None,
            'envvars': job_def.env_vars,
            'extravars': job_def.extra_vars,
            'verbosity': job_def.verbosity,
            'limit': job_def.limit,
            'ident': job_def.ident,
            'forks': job_def.forks,
            'module': job_def.module,
            'module_args': job_def.module_args,
            'host_pattern': job_def.host_pattern,
            'timeout': job_def.timeout,
            'roles_path': job_def.roles_path,
        }

To me it appears that currently the mesh job is somehow not supporting passing extra-vars to the target playbook.

can someone help here?

itsvipul94 avatar Oct 13 '24 05:10 itsvipul94