hnimminh / libresbc

An open source Session Border Controller 🌟 The SBC you dream about 🗽 LibreSBC will help you save thousands of dollars.
https://github.com/hnimminh/libresbc
MIT License
350 stars 79 forks source link

[BUG] Liberator templating-file failure #125

Closed hcaldicott closed 10 months ago

hcaldicott commented 10 months ago

Liberator templating-file fails to correctly update through Ansible when deploying on Debian 11. I am attempting to test out libresbc but getting blocked by this failure:

`TASK [libre : Update liberator templating-file] ***** failed: [mel-sbc] (item={'src': '/opt/libresbc/liberator/configuration.py', 'dest': '/opt/libresbc/v0.7.0/liberator/configuration.py', 'mode': '0754'}) => {"ansible_loop_var": "item", "changed": false, "item": {"dest": "/opt/libresbc/v0.7.0/liberator/configuration.py", "mode": "0754", "src": "/opt/libresbc/liberator/configuration.py"}, "msg": "AnsibleError: template error while templating string: expected token 'end of statement block', got '+'. String: #\n# liberator:configuration.py\n#\n# The Initial Developer of the Original Code is\n# Minh Minh <hnimminh at[@] outlook dot[.] com>\n# Portions created by the Initial Developer are Copyright (C) the Initial Developer.\n# All Rights Reserved.\n#\n\n#-----------------------------------------------------------------------------------------------------\n# GLOBAL CONFIGURATION FILES\n#-----------------------------------------------------------------------------------------------------\n_APPLICATION = 'LIBRESBC'\n_DESCRIPTION = 'Open Source Session Border Controller for Large-Scale Voice Infrastructures'\n_SWVERSION = 'v0.7.0'\n#-----------------------------------------------------------------------------------------------------\n# LIBRE\n#-----------------------------------------------------------------------------------------------------\nLOGDIR = '/var/log/libresbc'\nETCDIR = '/etc/libresbc'\nRUNDIR = '/run/libresbc'\n#-----------------------------------------------------------------------------------------------------\n# RBD UNIX SOCKET LOCALIZE INSTANCE\n#-----------------------------------------------------------------------------------------------------\nRDB_PIDFILE = f'{RUNDIR}/redis.pid'\nRDB_USOCKET = f'{RUNDIR}/redis.sock'\n\n#-----------------------------------------------------------------------------------------------------\n# REDIS ENDPOINT\n#-----------------------------------------------------------------------------------------------------\nREDIS_HOST = '{{redis.host}}'\nREDIS_PORT = {{redis.port}}\nREDIS_DB = {{redis.database}}\nREDIS_PASSWORD = {{ ('%s')|format(redis.password)|to_json if redis.password else 'None' }}\nSCAN_COUNT = 1000\nREDIS_TIMEOUT = 5\n#-----------------------------------------------------------------------------------------------------\n# VOICE ATTRIBUTE\n#-----------------------------------------------------------------------------------------------------\nSWCODECS = ['ALAW', 'ULAW', 'OPUS', 'G729', 'AMR', 'AMR-WB']\n_BUILTINACLS = ['rfc1918.auto', 'nat.auto', 'localnet.auto', 'loopback.auto', 'none', 'wan.auto',\n 'wan_v6.auto', 'wan_v4.auto', 'any_v6.auto', 'any_v4.auto', 'rfc6598.auto']\n#-----------------------------------------------------------------------------------------------------\n# SERVER PROPERTIES\n#-----------------------------------------------------------------------------------------------------\nNODEID = '{{nodeid}}'\nCLUSTERS = {\n 'name': 'defaultname',\n 'members': [NODEID],\n \"rtp_start_port\": 0,\n \"rtp_end_port\": 0,\n \"max_calls_per_second\": 0,\n \"max_concurrent_calls\": 0\n}\n\n#-----------------------------------------------------------------------------------------------------\nCHANGE_CFG_CHANNEL = 'CHANGE_CFG_CHANNEL'\nSECURITY_CHANNEL = 'SECURITY_CHANNEL'\nNODEID_CHANNEL = f'{NODEID.upper()}_CHANNEL'\n#-----------------------------------------------------------------------------------------------------\n# CALL ENGINE EVENT SOCKET\n#-----------------------------------------------------------------------------------------------------\nESL_HOST = '127.0.0.1'\nESL_PORT = 8021\n\n#-----------------------------------------------------------------------------------------------------\n# HTTPCDR DATA\n#-----------------------------------------------------------------------------------------------------\nHTTPCDR_ENDPOINTS = {{httpcdr.endpoints if httpcdr else 'None'}}\n#-----------------------------------------------------------------------------------------------------\n# CDR FILE\n#-----------------------------------------------------------------------------------------------------\nDISKCDR_ENABLE = {% if diskcdr is defined %}{{ 'True' if diskcdr else 'False'}}{% else %}False{% endif +%}\nCDRFNAME_INTERVAL = {% if cdrfilename is defined %}{{cdrfilename.interval}} {% else %}None{% endif +%}\nCDRFNAME_FMT = {% if cdrfilename is defined %}'{{cdrfilename.namefmt}}'{% else %}'%Y-%m-%d.cdr.nice'{% endif +%}\n\n"} --- before: /opt/libresbc/v0.7.0/liberator/system/systemd/liberator.service +++ after: /root/.ansible/tmp/ansible-local-6965lw06f4en/tmp1auccg1z/liberator.service @@ -7,8 +7,8 @@ Type=simple User=root Group=root -WorkingDirectory={{dstdir}}/liberator -ExecStart=/usr/bin/python3 {{dstdir}}/liberator/main.py +WorkingDirectory=/opt/libresbc/v0.7.0/liberator +ExecStart=/usr/bin/python3 /opt/libresbc/v0.7.0/liberator/main.py

SyslogIdentifier=libresbc SyslogFacility=5

changed: [mel-sbc] => (item={'src': '/opt/libresbc/liberator/system/systemd/liberator.service', 'dest': '/opt/libresbc/v0.7.0/liberator/system/systemd/liberator.service', 'mode': '0644'}) `

hcaldicott commented 10 months ago

I've identified the issue -

/liberator/configuration.py:

DISKCDR_ENABLE = {% if diskcdr is defined %}{{ 'True' if diskcdr else 'False'}}{% else %}False{% endif +%} CDRFNAME_INTERVAL = {% if cdrfilename is defined %}{{cdrfilename.interval}} {% else %}None{% endif +%} CDRFNAME_FMT = {% if cdrfilename is defined %}'{{cdrfilename.namefmt}}'{% else %}'%Y-%m-%d.cdr.nice'{% endif +%}

The + characters need to be removed: DISKCDR_ENABLE = {% if diskcdr is defined %}{{ 'True' if diskcdr else 'False'}}{% else %}False{% endif %} CDRFNAME_INTERVAL = {% if cdrfilename is defined %}{{cdrfilename.interval}} {% else %}None{% endif %} CDRFNAME_FMT = {% if cdrfilename is defined %}'{{cdrfilename.namefmt}}'{% else %}'%Y-%m-%d.cdr.nice'{% endif %}

hnimminh commented 10 months ago

@hcaldicott which ansible version are you using?

hnimminh commented 10 months ago

This would be fixed already via #122. closed as no response!