Skip to content

Instantly share code, notes, and snippets.

@borutmrak
Created April 22, 2015 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borutmrak/333049c7e43cd7d7aab8 to your computer and use it in GitHub Desktop.
Save borutmrak/333049c7e43cd7d7aab8 to your computer and use it in GitHub Desktop.
asterisk pillar
asterisk:
sip:
users:
'00_tpl_grandstream-phone':
opts:
type: "friend"
context: "from-local"
host: "dynamic"
nat: "no"
dtmfmode: "rfc2833"
disallow: "all"
allow: "g722,alaw,ulaw"
parent:
"!"
dids: []
localexts: []
'800':
opts:
secret: xxxx
call-limit: 1
parent:
00_tpl_grandstream-phone
"802":
opts:
secret: xxxx
parent:
00_tpl_grandstream-phone
@borutmrak
Copy link
Author

How about this? Is there a way to simplify:

{%- for user, args in salt['pillar.get']('asterisk:sip:users') | dictsort %}
[{{ user }}]({{ args['parent'] }})
  {%- if 'disallow' in args['opts'].keys() %}
        disallow={{ args['opts']['disallow'] }}
        allow={{ args['opts']['allow'] }}
    {%- do args['opts'].pop('allow', None) -%}
    {%- do args['opts'].pop('disallow', None) -%}
  {%- endif %}
  {%- for opt, optval in args['opts'].items() %}
        {{ opt }}={{ optval }}
  {%- endfor %}
{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment