W3cubDocs

/Ansible

community.general.twilio – Sends a text message to a mobile phone through Twilio.

Note

This plugin is part of the community.general collection (version 3.8.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.twilio.

Synopsis

  • Sends a text message to a phone number through the Twilio messaging API.

Parameters

Parameter Choices/Defaults Comments
account_sid
string / required
user's Twilio account token found on the account page
auth_token
string / required
user's Twilio authentication token
from_number
string / required
the Twilio number to send the text message from, format +15551112222
media_url
string
a URL with a picture, video or sound clip to send with an MMS (multimedia message) instead of a plain SMS
msg
string / required
the body of the text message
to_numbers
list / elements=string / required
one or more phone numbers to send the text message to, format +15551112222

aliases: to_number

Notes

Note

  • This module is non-idempotent because it sends an email through the external API. It is idempotent only in the case that the module fails.
  • Like the other notification modules, this one requires an external dependency to work. In this case, you’ll need a Twilio account with a purchased or verified phone number to send the text message.

Examples

# send an SMS about the build status to (555) 303 5681
# note: replace account_sid and auth_token values with your credentials
# and you have to have the 'from_number' on your Twilio account
- name: Send a text message to a mobile phone through Twilio
  community.general.twilio:
    msg: All servers with webserver role are now configured.
    account_sid: ACXXXXXXXXXXXXXXXXX
    auth_token: ACXXXXXXXXXXXXXXXXX
    from_number: +15552014545
    to_number: +15553035681
  delegate_to: localhost

# send an SMS to multiple phone numbers about the deployment
# note: replace account_sid and auth_token values with your credentials
# and you have to have the 'from_number' on your Twilio account
- name: Send a text message to a mobile phone through Twilio
  community.general.twilio:
    msg: This server configuration is now complete.
    account_sid: ACXXXXXXXXXXXXXXXXX
    auth_token: ACXXXXXXXXXXXXXXXXX
    from_number: +15553258899
    to_numbers:
      - +15551113232
      - +12025551235
      - +19735559010
  delegate_to: localhost

# send an MMS to a single recipient with an update on the deployment
# and an image of the results
# note: replace account_sid and auth_token values with your credentials
# and you have to have the 'from_number' on your Twilio account
- name: Send a text message to a mobile phone through Twilio
  community.general.twilio:
    msg: Deployment complete!
    account_sid: ACXXXXXXXXXXXXXXXXX
    auth_token: ACXXXXXXXXXXXXXXXXX
    from_number: +15552014545
    to_number: +15553035681
    media_url: https://demo.twilio.com/logo.png
  delegate_to: localhost

Authors

  • Matt Makai (@makaimc)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/twilio_module.html