Ansible. part 1.
Example of using Ansible for checking online calls from many of servers from command line:
Ansible check online calls from few servers through ssh:
docs: https://docs.ansible.com/ansible/latest/installation_guide/intro_configuration.html
Control node :
apt update -y
apt install ansible -y
Create /etc/ansible/hosts file
all: hosts: 123.123.123.123: 123.123.123.124: 123.123.123.125: 123.123.123.126:
Check connecting to hosts:
ansible all -m ping
You may see error like this:
“msg”: “Failed to connect to the host via ssh:
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\n
Someone could be eavesdropping on you right now (man-in-the-middle attack)!\r\n
It is also possible that a host key has just been changed.\r\n
The fingerprint for the ECDSA key sent by the remote host is\nSHA256:sdfsdfsdfsdfsdfsdfsdfsdf.\r\n
Please contact your system administrator.\r\n
Add correct host key in /root/.ssh/known_hosts to get rid of this message.\r\n
Offending ECDSA key in /root/.ssh/known_hosts:6\r\n remove with:\r\n
ssh-keygen -f \”/root/.ssh/known_hosts\” -R \”123.123.123.123\”\r\n
ECDSA host key for 123.123.123.123 has changed and you have requested strict checking.\r\n
Host key verification failed.”,
“unreachable”: true
to fix it you may to run on control node:
ssh-keygen -f "/root/.ssh/known_hosts" -R "123.123.123.123"
To check count of calls from from hosts
ansible all -a "asterisk -rx \"core show calls\""
if everything works fine, you will see:
123.123.123.123| CHANGED | rc=0 >> 328 active calls 691163 calls processed
123.123.123.124 | CHANGED | rc=0 >> 167 active calls 346948 calls processed
123.123.123.125 | CHANGED | rc=0 >> 382 active calls 371352 calls processed
123.123.123.126 | CHANGED | rc=0 >> 356 active calls 691689 calls processed
if you want to use complex command you may use this:
ansible all -m shell -a "asterisk -rx \"core show calls\" | grep 'active' && asterisk -rx \"fax show sessions\" | grep 'FAX session' "
123.123.123.123 | CHANGED | rc=0 >> 388 active calls 117 FAX sessions
123.123.123.124 | CHANGED | rc=0 >> 188 active calls 59 FAX sessions
123.123.123.125 | CHANGED | rc=0 >> 393 active calls 123 FAX sessions
123.123.123.126 | CHANGED | rc=0 >> 381 active calls 119 FAX sessions
OPENSIPS 3.2 modules HTTPD and MI_HTTP
There is problem when you try to using httpd and mi_http modules with opensips 3.2 and centos 7.9.2009 even you have installed opensips from repository. To avoid it: remove libhttpd system, install new version, download opensips from git, compile appropriated modules.
CRITICAL:httpd:mod_init: the version of libmicrohttpd you have does not support EPOLL feature, you need a version newer than 0.9.50, but running 0.9.33
workaround for it:
cd /usr/src/
yum install git "@Development Tools" openssl-devel libxslt lynx -y
git clone --recursive https://github.com/OpenSIPS/opensips.git -b 3.2 opensips-3.2
yum remove libmicrohttpd libmicrohttpd-devel
wget https://cbs.centos.org/kojifiles/packages/libmicrohttpd/0.9.59/2.el7/x86_64/libmicrohttpd-0.9.59-2.el7.x86_64.rpm --no-check-certificate
wget https://cbs.centos.org/kojifiles/packages/libmicrohttpd/0.9.59/2.el7/x86_64/libmicrohttpd-devel-0.9.59-2.el7.x86_64.rpm --no-check-certificate
yum install libmicrohttpd-0.9.59-2.el7.x86_64.rpm libmicrohttpd-devel-0.9.59-2.el7.x86_64.rpm -y
cd opensips-3.2
make modules=modules/httpd modules
make modules=modules/mi_http modules
make modules=modules/prometheus modules
#copy your compiled modules to opensips modules directory, then restart opensips.
cp modules/httpd/httpd.so /usr/lib64/opensips/modules
cp modules/mi_http/mi_http.so /usr/lib64/opensips/modules
cp modules/prometheus/prometheus.so /usr/lib64/opensips/modules
| Posted in ansible | No Comments »