Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reading of contexts/users from databags. #15

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# develop
* Remove reading of contexts/users from databags. These should be replaced by included files per context/user and potentially a LWRP.

# 1.1.1
* Attribute typo in template
Expand Down
Empty file removed data_bags/.gitkeep
Empty file.
7 changes: 0 additions & 7 deletions data_bags/asterisk_contexts/adhearsion.json

This file was deleted.

9 changes: 0 additions & 9 deletions data_bags/asterisk_users/usera.json

This file was deleted.

7 changes: 0 additions & 7 deletions recipes/config.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
def data_bag_items(bag_name)
data_bag(bag_name).map { |id| data_bag_item bag_name, id }
end

users = data_bag_items(:asterisk_users)
dialplan_contexts = data_bag_items(:asterisk_contexts)
config_dir = "#{node['asterisk']['prefix']['conf']}/asterisk"

if platform_family?('rhel', 'fedora')
Expand All @@ -27,7 +21,6 @@ def data_bag_items(bag_name)
template "#{config_dir}/#{template_file}.conf" do
source "#{template_file}.conf.erb"
mode 0644
variables :users => users, :dialplan_contexts => dialplan_contexts
notifies :reload, resources('service[asterisk]')
end
end
18 changes: 0 additions & 18 deletions templates/default/extensions.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@ TRUNKMSD=1 ; MSD digits to strip (usually 1 or 0)

[default]
exten => s,1,Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})})
<% if @users[0] %>
exten => s,n,Dial(SIP/<%= @users[0]['username'] %>, 10)
<% end %>
exten => s,n, Hangup
<% if @users[0] %>
exten => <%= @users[0]['username'] %>, 1, Dial(SIP/<%= @users[0]['username'] %>, 10)
<% end %>

[outbound]
include => seven-digit
include => local-devices
include => tollfree
include => dial-uri

[local-devices]
<% @users.each do |user| %>
exten => <%= user['extension'] %>, 1, Dial(SIP/<%= user['username'] %>, 10)
<% end %>

[tollfree]
exten => _411, 1, Dial(SIP/[email protected],60)
exten => _1800NXXXXXX,1,Dial(SIP/${EXTEN}@proxy.ideasip.com,60)
Expand All @@ -47,10 +36,3 @@ exten => _NXXNXXXXXX,n,Goto(1${EXTEN},1)
exten => _[a-z].,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)
exten => _[A-Z].,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)
exten => _X.,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)

<% @dialplan_contexts.each do |context| %>
[<%= context['name'] %>]
<% context['entries'].each do |entry| %>
<%= entry %>
<% end %>
<% end %>
10 changes: 0 additions & 10 deletions templates/default/sip.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,3 @@ externip = <%= node['asterisk']['public_ip'] %> ; Address that we're going to p


[authentication]

<% @users.each do |user| %>
[<%= user['username'] %>]
defaultuser=<%= user['username'] %>
secret=<%= user['password'] %>
type=friend
callerid="<%= user['full_name'] %> <<%= user['username'] %>>"
host=dynamic
context=<%= user['context'] %>
<% end %>
25 changes: 0 additions & 25 deletions test/integration/package/serverspec/localhost/asterisk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,6 @@
it { should be_listening.with('udp') }
end

describe file("/etc/asterisk/extensions.conf") do
it {
should contain(<<-CONTEXT
[adhearsion]
exten => _.,1,AGI(agi:async)
CONTEXT
)
}
end

describe file("/etc/asterisk/sip.conf") do
it {
should contain(<<-CONTEXT
[usera]
defaultuser=usera
secret=usera
type=friend
callerid="User A <usera>"
host=dynamic
context=adhearsion
CONTEXT
)
}
end

describe package('sox') do
it { should be_installed }
end
Expand Down
25 changes: 0 additions & 25 deletions test/integration/source/serverspec/localhost/asterisk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,6 @@
it { should be_listening.with('udp') }
end

describe file("/etc/asterisk/extensions.conf") do
it {
should contain(<<-CONTEXT
[adhearsion]
exten => _.,1,AGI(agi:async)
CONTEXT
)
}
end

describe file("/etc/asterisk/sip.conf") do
it {
should contain(<<-CONTEXT
[usera]
defaultuser=usera
secret=usera
type=friend
callerid="User A <usera>"
host=dynamic
context=adhearsion
CONTEXT
)
}
end

describe package('sox') do
it { should be_installed }
end
Expand Down