[ansible-project] Re: Sending output from a completed job via the mail module

2019-09-05 Thread Cade Lambert
tower_id would be the job id for the job in which the template was run, so 
you need to pull that job id from somewhere.  So basically, yeah, you'd 
have to create a new playbook to kick off the playbook you want to email 
the results on.  Unfortunately, I'm short on time currently but here's the 
outline of what I'd do.  It might not be the slickest way but it'd work.

1. API request to run template:  
https://docs.ansible.com/ansible-tower/3.5.0/html/towerapi/api_ref.html#/Job_Templates/Job_Templates_job_templates_launch_create
- register the results into a job_run

2. Use the results from job_run to get the job id. Throw it into a debug 
task if you need to see the output of job_run.  Usually it's something like 
job_run.results.id

3. API request to get the output from the job, using the job id: 
https://docs.ansible.com/ansible-tower/3.5.0/html/towerapi/api_ref.html#/Jobs/Jobs_jobs_read_0
- register the results into job_results

4. Use the mail module to email the contents of job_results

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/710fad28-a00e-4c9d-8ded-0b60ace6bde1%40googlegroups.com.


[ansible-project] Re: Sending output from a completed job via the mail module

2019-09-05 Thread harry devine
I'll admit, this playbook is running in Ansible Tower, which is where I'm 
getting tower_id from.  I know that I could reach out to Red Hat for Tower 
questions, but in the past I've had them reject my support requests for 
these types of questions.  They say that they don't support with any 
playbook code/authoring, which is why I was reaching out here.

I tried the URI module and got the same error.  Basically, I want to email 
the stdout of a playbook, so do I need to spawn a new playbook to do that?

Thanks,
Harry

On Thursday, September 5, 2019 at 12:22:16 PM UTC-4, Cade Lambert wrote:
>
> Couple of things:
>
> 1. Ansible has a uri module for API calls, it'll do the same thing but 
> best practice is to use a module if there's one available.
> 2. Where are you getting tower_id from?  It looks like it's undefined.
> 3. Are you kicking the template off with an API call too?  That'd be the 
> best way, then register the results and parse out the job ID from those 
> results.
>
> Something like
> - API call to initiate template and register results into variable1
> - API call to get the job output, using the variable to parse the job ID, 
> then register those results to variable2
> - Mail module to email the contents of variable2
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e37d3ecb-629c-4753-8435-d21fa8c7ac13%40googlegroups.com.


[ansible-project] Re: Sending output from a completed job via the mail module

2019-09-05 Thread Cade Lambert
Couple of things:

1. Ansible has a uri module for API calls, it'll do the same thing but best 
practice is to use a module if there's one available.
2. Where are you getting tower_id from?  It looks like it's undefined.
3. Are you kicking the template off with an API call too?  That'd be the 
best way, then register the results and parse out the job ID from those 
results.

Something like
- API call to initiate template and register results into variable1
- API call to get the job output, using the variable to parse the job ID, 
then register those results to variable2
- Mail module to email the contents of variable2

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/663a4c04-4f6c-46a0-879c-7b8b45b8af86%40googlegroups.com.