Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

[Provisioner] Add new role and new task for emailing instructor inventory #336

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/aws_lab_setup/provision_lab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@
gather_facts: no
roles:
- email

- name: Email inventory to instructor
hosts: localhost
connection: local
become: no
gather_facts: no
roles:
- email_instructor
4 changes: 4 additions & 0 deletions tools/aws_lab_setup/roles/email_instructor/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# sendgrid_user:
# sendgrid_pass:
# sendgrid_api_key:
email_instructor: False
19 changes: 19 additions & 0 deletions tools/aws_lab_setup/roles/email_instructor/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- name: Send email to students with inventory attached
delegate_to: localhost
sendgrid:
username: "{{ sendgrid_user | default(omit) }}"
password: "{{ sendgrid_pass | default(omit) }}"
api_key: "{{ sendgrid_api_key | default(omit) }}"
subject: "[Ansible] Instructor Inventory Details"
body: |
Attached is the Ansible inventory to be used for training.<br>
Please check your ability to connect to each of the hosts via ssh.<br>
<br>
to_addresses: "{{ instructor_email }}"
html_body: yes
from_address: "{{ instructor_email }}"
attachments:
- "instructor_inventory.txt"
when: email_instructor
tags:
- email_instructor