Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job notification data omits new host summary fields (rescued, ignored) #4394

Closed
jladdjr opened this issue Jul 30, 2019 · 3 comments
Closed

Comments

@jladdjr
Copy link
Contributor

jladdjr commented Jul 30, 2019

ISSUE TYPE
  • Bug Report
ENVIRONMENT
  • AWX version: devel
  • Ansible
SUMMARY

The Job model's notification_data method omits the new ansible host summary fields added here.

awx/awx/main/models/jobs.py

Lines 655 to 661 in c7bb0f1

all_hosts[h.host_name] = dict(failed=h.failed,
changed=h.changed,
dark=h.dark,
failures=h.failures,
ok=h.ok,
processed=h.processed,
skipped=h.skipped)

STEPS TO REPRODUCE
  1. Create a job template
  2. Create an email notification template
  3. Configure the JT to trigger the e-mail notification on job success
  4. Run the job
  5. Once the job completes, look at the body of the e-mail notification that was sent

These steps can be accomplished with akit using the following commands:

jt = v2.job_templates.create(); host = jt.ds.inventory.add_host()
nt = v2.notification_templates.create(notification_type='email')
jt.add_notification_template(nt, 'notification_templates_success')
job = jt.launch().wait_until_completed()
EXPECTED RESULTS

The e-mail notification will include a JSON dictionary with a number of fields describing the job run. The hosts section will list results for each host involved in the playbook run. Each host's results should include the rescued and ignored fields.

ACTUAL RESULTS

rescued and ignored fields are missing:

Screenshot 2019-08-19 12 35 57

ADDITIONAL INFORMATION

The new host summary fields (rescued, ignored) were added in Ansible 2.8 and adopted by awx here (and included in Tower 3.5)

@ryanpetrello
Copy link
Contributor

ryanpetrello commented Aug 19, 2019

@jladdjr can you add some instructions here on how to reproduce/observe this bug?

@jladdjr
Copy link
Contributor Author

jladdjr commented Aug 19, 2019

@rebeccahhh (@ryanpetrello) - provided some additional context. Let me know if you need any other info!

@elyezer
Copy link
Member

elyezer commented Sep 5, 2019

I verified this by doing the following:

  1. Started a HTTP server and made it listen to connections
  2. Created a Webhook notification and configured it to post to the HTTP server started on 1
  3. Created a Job template and associated with the notification created on 2
  4. Launched the job template and wait until it completed
  5. Check if the POST request was made to the HTTP server and that the rescued and ignored fields were present (see the JSON data received below)
{
    "created_by": "admin",
    "credential": "Demo Credential",
    "extra_vars": "{}",
    "finished": "2019-09-05T13:19:11.784510+00:00",
    "friendly_name": "Job",
    "hosts": {
        "localhost": {
            "changed": 0,
            "dark": 0,
            "failed": false,
            "failures": 0,
            "ignored": 0,
            "ok": 2,
            "processed": 1,
            "rescued": 0,
            "skipped": 0
        }
    },
    "id": 15,
    "inventory": "Demo Inventory",
    "limit": "",
    "name": "Demo Job Template",
    "playbook": "hello_world.yml",
    "project": "Demo Project",
    "started": "2019-09-05T13:19:04.441732+00:00",
    "status": "successful",
    "traceback": "",
    "url": "https://towerhost/#/jobs/playbook/15"
}

With all the above we consider this done

@elyezer elyezer closed this as completed Sep 5, 2019
ryanpetrello added a commit to ryanpetrello/awx that referenced this issue Aug 5, 2020
Send content-type with mattermost notifications, fixes ansible#7264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants