Enable Javascript

Please enable Javascript to view website properly

Toll Free 1800 889 7020

Looking for an Expert Development Team? Take 2 weeks Free Trial! Try Now

Tutorial : Sending SMS through Ansible

Ansible is an open-source automation tool used to perform IT works in an easy and sophisticated method. It makes it easier to perform tedious tasks that would require massive manual implementation in Software development services. People use Ansible as an application deployment tool.

Sometimes there can be a situation when we are unable to carry the entire setup in our laptops to check the progress of deployment and end up coming to notice the breakdown in the process. What if we can receive a notification SMS on our cellphones regarding any misshapen or interruption during the process? It would become easy to get notified even if we were away from our computer and application deployment with ansible went wrong.

There are different notification modules used in Ansible:

  • Nexmo
  • Twilio
  • Catapult

NEXMO:

The Nexmo module helps to send notification SMS via the Nexmo API.

Below is the code to be written using nexmo module inside the playbook.

nexmo module

The variables used in the above coding have the following meanings:

  • api_key: Nexmo API key required for sending sms.
  • api_secret: Nexmo API secret.
  • src: Nexmo number we want to send the notification sms from.
  • dest: Phone number(s) we want to send the notification sms to.
  • msg: Message that we want to send. Messages longer than 160 characters will be slit into multiple messages.

A backwards compatible interface is not guaranteed by this module.

TWILIO:

The Twilio module helps to send notification SMS through the Twilio API.

Below is the code to be written using the Twilio module inside the playbook.

nexmo module

The variables used in the above code have the following meanings:

  • account_sid: the sender’s Twilio account token extracted from the Twilio account page.
  • auth_token: the sender’s Twilio authentication token.
  • from_number: the user’s Twilio number who wants to send the notification sms.
  • to_number: the user’s phone number(s) to whom the notification message is to be sent.
  • msg: the body of the text message that is to be sent.

The advantage of this module is that it is non-idempotent because it uses an external API to send notification messages.

The major drawback of using this module is that this one also requires an external dependency to work like any other notification module. The sender needs to create a Twilio account with either a purchased or verified phone number.

This module does not guarantee a backward compatible interface.

CATAPULT:

The Catapult module helps to send SMS or MMS through the catapult bandwidth API.

Below is the code to be written using the Catapult module in the playbook.

catapult module

The variables used in the above code have the following meanings:

  • src: the catapult phone number from which the message is to be sent.
  • dest: the user’s phone number(s) the notification sms is to be sent to.
  • msg: the text sms that the sender wants to send as a notification.
  • media: the mms that the sender wants to send as a notification.
  • user_id: the sender’s id from the API account page.
  • api_token: the sender’s Api token from the API account page.
  • api_secret: the sender’s Api secret from the API account page.

Even if the media URL is wrong, it will return changed. Even if the destination number is invalid, it will return changed.

These are the three different ways to send notification SMS via Ansible. The most widely used out of the three is Twilio.

Software Development Team
Need Software Development Team?
captcha
🙌

Thank you!
We will contact soon.

Oops! Something went wrong.

Recent Blogs

Categories

NSS Note
Trusted by Global Clients