ansible / lightbulb

Lightbulb has been deprecated and replaced by Ansible Workshops
https://ansible.github.io/workshops/
MIT License
479 stars 307 forks source link

Sendgrid fails to send mail #70

Open thisdavejohnson opened 8 years ago

thisdavejohnson commented 8 years ago

TASK [training_infra : Email Hosts file] *************************************** task path: /root/lightbulb/aws_lab_setup/roles/training_infra/tasks/main.yml:21 An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: string indices must be integers, not str failed: [localhost -> localhost] (item={u'username': u'thisdavejohnson', u'email': u'thisdavejohnson@redhat.com'}) => {"failed": true, "item": {"email": "thisdavejohnson@redhat.com", "username": "thisdavejohnson"}, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_QZnZ7a/ansible_module_sendgrid.py\", line 254, in <module>\n main()\n File \"/tmp/ansible_QZnZ7a/ansible_module_sendgrid.py\", line 246, in main\n module.fail_json(msg=\"unable to send email through SendGrid API: %s\" % info['message'])\nTypeError: string indices must be integers, not str\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}

thisdavejohnson commented 8 years ago

This is with Ansible 2.1.0 and the latest checkout of lightbulb.

thisdavejohnson commented 8 years ago

This also fails with the same error on Ansible 2.0.0.2.

jsmartin commented 8 years ago

@thisdavejohnson I'm wondering if our playbooks are assuming we are using @defionscode 's fork of the sendgrid module: https://github.com/ansible/ansible-modules-extras/pull/1275

jsmartin commented 8 years ago

Oh yes, it is obviously, I see the forked module already in the role. Maybe sendgrid has had an API change?

samdoran commented 8 years ago

@thisdavejohnson Digging in to this since I'm doing a training engagement this week.

I am able to duplicate the original error (reported in Slack):

TASK [training_infra : Email Hosts file] ***************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'module' object has no attribute 'SendGridClient'

This happens with the latest (>=3.0) sendgrid module. Seems something changed there that needs to be updated.

Regarding the issue reported here, I'm unable to duplicate the error.

I'll have to try running it from a CentOS 7 control machine and see if that allows me to duplicate the problem.

smapjb commented 8 years ago

I hit the problem on stock RHEL 7.2 - I downgraded sendgrid (upon reading this) and now it works ok

sudo pip install sendgrid==2.1.1

thisdavejohnson commented 8 years ago

I still have this problem with:

auden-rovellequartz commented 8 years ago

I have this issue (Running on Apache/2.4.7 (Ubuntu), Python 2.7.6)

samdoran commented 8 years ago

@thisdavejohnson @auden-rovellequartz

I was able to successfully send email from CentOS 7.2 and Ubuntu 14.04.

Can you please try using branch wip-refactor-provisioner? Make sure to check out the README since several things have changed and you might need to change your extra_vars.yml slightly.

auden-rovellequartz commented 8 years ago

what version of Python are you using?

On Tue, Oct 25, 2016 at 9:07 AM, Sam Doran notifications@github.com wrote:

@thisdavejohnson https://github.com/thisdavejohnson @auden-rovellequartz https://github.com/auden-rovellequartz

I was able to successfully send email from CentOS 7.2 and Ubuntu 14.04.

Can you please try using branch wip-refactor-provisioner? Make sure to check out the README since several things have changed and you might need to change your extra_vars.yml slightly.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ansible/lightbulb/issues/70#issuecomment-256044909, or mute the thread https://github.com/notifications/unsubscribe-auth/AMr3I0FUaXZUcqnkSbyQlDXolwmnkoiwks5q3g02gaJpZM4IzRgj .

samdoran commented 8 years ago

CentOS 7.2: Python 2.7.5 Ubuntu 14.04: Python 2.7.6

samdoran commented 8 years ago

Is this still an issue with Ansible 2.2? I just tested with the built in sendgrid module on 2.2 and it works, but I'm a bad tester since I can't duplicate this.

tima commented 7 years ago

I discovered using Ansible v2.2 that the sendgrid client library has made a number of breaking changes in the past calendar year.

https://github.com/sendgrid/sendgrid-python/issues/217

The module in v2.2 only works with versions of the library prior to v3.0. The latest is 3.6.3. If anyone does a pip install sendgrid they're going to get a library that will give them a stacktrace dump when they use the sender module. Annoying.

Users need to use pip install sendgrid==2.2.1 to get a version that will work with what ships in v2.2.

tima commented 7 years ago

Posted this as an issue here: https://github.com/ansible/ansible/issues/19314

tima commented 7 years ago

Bollocks! I just saw in the docs where the sendgrid version is flagged. Still it should be better handled than it is.