Sometimes there’s a need to reset a GSM module on a Yeastar GSM gateway. For example, SIM cards of one of our providers get into faulty state every few weeks, and only a reset helps.
The GSM module can either be rebooted via Web GUI, or from the Asterisk console. But the Asterisk console can only work on the same host where the asterisk daemon runs, so you need to make an SSH connection into the Yeastar box to do that. Also it’s impossible to save a public SSH key in a Yeastar box, so only password authentication works.
Ansible is a powerful toolset for managing remote hosts, and it appears to be perfectly suitable for managing the GSM gateways.
Ansible 2.x is available for Debian 8 from jessie-backports repository. There are some important differences from version 1.7 that is installed from default repositories, and in particular,
After installing Ansible, uncomment
host_key_checking = False in
/etc/ansible/ansible.cfg , so that the SSH client stops verifying the remote host SSH signatures. Otherwise the host signatures should be listed in your
The following lines in
/etc/ansible/hosts list your GSM gateways:
[yeastar] gsm01 ansible_host=192.168.99.66 ansible_ssh_pass=kljckhjeswvdfesv gsm02 ansible_host=192.168.99.67 ansible_ssh_pass=dmnckjfvrever gsm03 ansible_host=192.168.99.68 ansible_ssh_pass=dcmnkljdfhfe [yeastar:vars] ansible_user=root ansible_port=8022
If you use the same root password on all devices, the password variable can be moved to the group variables.
Ansible uses SFTP for ad-hoc commands, and SFTP is not available on Yestar gateways. But the raw module works just fine, and resetting a GSM module can now be done with a simple command from your management server:
ansible gsm03 -m raw -a '/bin/asterisk -rx "gsm power reset 2"'