Ansible: Need to send the text message (SMS) via ansible using the “Nexmo”. Getting below error

108 views
Skip to first unread message

nishant bawane

unread,
May 23, 2017, 7:20:06 AM5/23/17
to Ansible Project

Below is the playbook which is used to send the messages to the registered numbers using nexmo. Please suggests what needs to be done to overcome this error - No which i used are registered one and same with the api inputs.

 ---
 - hosts: localhost
   tasks:
     - name: Send notification message via Nexmo
       nexmo:
      api_key: 640c8a53
      api_secret: 0ce239a6
      src: 8793161930
      dest:
        - 919168694888
      msg: 'Hello from Ansible'
      validate_certs: no
    delegate_to: localhost

Below is the playbook error -

TASK [Send notification message via Nexmo] ************************************
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed":true, "msg": "One or messages failed to send", "responses": {"919168694888": {"failed": true}}}
    to retry, use: --limit @/home/capio/ansible/playbooks/sms.retry


nishant bawane

unread,
Jun 6, 2017, 10:27:09 AM6/6/17
to Ansible Project
Is there any soln to overcome this error, please suggest the right forum to ask this question, if this is not the correct forum.

Matt Martz

unread,
Jun 6, 2017, 11:08:41 AM6/6/17
to ansible...@googlegroups.com
I've just tested this module to validate that it is working correctly, and it seems to be.

I'm not sure what specific issue you are running into.

I might suggest following the example on the getting started page for Nexmo, and using your same data:

-d api_key=640c8a53 \
-d api_secret=0ce239a6 \
-d to=919168694888 \
-d from=8793161930 \
-d text="Hello from Nexmo"

Of course, you need to replace api_key and api_secret with your key and secret.


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/79807af6-c04d-4dad-9a37-6ea71c7ab9b5%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

nishant bawane

unread,
Jun 6, 2017, 1:36:45 PM6/6/17
to Ansible Project
Hello Matt,

Thanks a lot for your input, Really Appreciated!

I tried to make the changes in my playbook as per below -


---
- hosts: localhost
  tasks:
    - uri:
        url: curl -X POST  https://rest.nexmo.com/sms/json \

    - name: Send notification message via Nexmo
      nexmo:
        api_key: b6xxxxx \
        api_secret: 57xxxxxxxxx \
        src: +918793161930 \
        dest: +919168635888 \
        msg: 'Hello from Nishant via Ansible'
        validate_certs: no
      delegate_to: localhost
~

Below is the error -

fatal: [localhost]: FAILED! => {"changed": false, "content": "", "failed": true, "msg": "Status code was not [200]: Request failed: <urlopen error unknown url type: curl -x post  https>", "redirected": false, "status": -1, "url": "curl -X POST  https://rest.nexmo.com/sms/json \\"}
        to retry, use: --limit @/home/capio/ansible/playbooks/Sms.retry


It will be great if you can please share the playbook , that you tried. I can refer that to make changes in my playbook. I am not sure exactly where i am getting the things wrong.

Please let me know if you need any more inputs from me.

Thanks again!
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

nishant bawane

unread,
Jun 14, 2017, 6:09:09 AM6/14/17
to Ansible Project
even i have tried using the twilo still not able to get the output -

- hosts: localhost
  tasks:
    - name: Send notification message via twilio
      twilio:

        msg: 'Hello from Nishant via Ansible'
        account_sid: ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        auth_token: a0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        from_number: +918793127307
        to_number: +919168612880
      delegate_to: localhost

below is the error-

fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to validate the SSL certificate for api.twilio.com:443. Make sure your managed systems have a valid CA certificate installed. If the website serving the url uses SNI you need python >= 2.7.9 on your managed machine or you can install the urllib3, pyopenssl, ndg-httpsclient, and pyasn1 python modules to perform SNI verification in python >= 2.6. You can use validate_certs=False if you do not need to confirm the servers identity but this is unsafe and not recommended. Paths checked for this platform: /etc/ssl/certs, /etc/pki/ca-trust/extracted/pem, /etc/pki/tls/certs, /usr/share/ca-certificates/cacert.org, /etc/ansible"}


On Tuesday, 23 May 2017 16:50:06 UTC+5:30, nishant bawane wrote:
Reply all
Reply to author
Forward
0 new messages