diff --git a/REFERENCE.md b/REFERENCE.md index fee96ce74a06ff1f7692f8ab836e4c0c62cbf204..18146a473c5268aad1e54366e3e43acda791faaa 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -55,6 +55,8 @@ Data type: `Stdlib::Fqdn` Name (fully qualified domain name) of the Coturn server +Default value: `$facts['networking']['fqdn']` + ##### <a name="listening_ips"></a>`listening_ips` Data type: `Array[Stdlib::IP::Address]` diff --git a/manifests/init.pp b/manifests/init.pp index dead2222887bf5651117326055f86bff50c68813..a652315a9850ed86a8473be2a907e79e18d4c091 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -61,9 +61,7 @@ # This flag means that no log file rollover will be used, and the log file # name will be constructed as-is, without PID and date appendage. class coturn ( - - Stdlib::Fqdn $realm, - + Stdlib::Fqdn $realm = $facts['networking']['fqdn'], Array[Stdlib::IP::Address] $listening_ips = [], Stdlib::Port $listening_port = 3478, Optional[Stdlib::Port] $tls_listening_port = undef, diff --git a/spec/acceptance/coturn_spec.rb b/spec/acceptance/coturn_spec.rb index d8e1ce8861e3f05aa184238488b32938110bae8e..a33b94dd6b413e85ed4d588926305bb11350831e 100644 --- a/spec/acceptance/coturn_spec.rb +++ b/spec/acceptance/coturn_spec.rb @@ -1,13 +1,12 @@ require 'spec_helper_acceptance' ip_server = fact('networking.ip') +fqdn_server = fact('networking.fqdn') describe 'coturn' do context 'with defaults' do pp = %( - class { 'coturn' : - realm => 'coturn.example.org', - } + include coturn ) it 'applies without error' do @@ -28,7 +27,7 @@ describe 'coturn' do describe file('/etc/turnserver.conf') do it { is_expected.to be_file } its(:content) { is_expected.to contain 'listening-port=3478' } - its(:content) { is_expected.to contain 'realm=coturn.example.org' } + its(:content) { is_expected.to contain "realm=#{fqdn_server}" } end describe file('/etc/default/coturn') do diff --git a/spec/classes/coturn_spec.rb b/spec/classes/coturn_spec.rb index 2fecf2a30b73a830cc9ca4e1fd9f6bd06b3777db..b25ce29012485252920de36b237cb684e3a17e65 100644 --- a/spec/classes/coturn_spec.rb +++ b/spec/classes/coturn_spec.rb @@ -1,24 +1,20 @@ require 'spec_helper' describe 'coturn' do - on_supported_os.each do |os, os_facts| + on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { os_facts } - let(:params) do - { - realm: 'coturn.example.org', - } - end + let(:facts) { facts } + + fqdn_server = facts[:networking]['fqdn'] it { is_expected.to compile } it { is_expected.to contain_service('coturn') } - it { is_expected.to contain_file('/etc/turnserver.conf').with_content(%r{realm=coturn.example.org}) } + it { is_expected.to contain_file('/etc/turnserver.conf').with_content(%r{realm=#{fqdn_server}}) } it { is_expected.to contain_file('/etc/turnserver.conf').that_notifies('Service[coturn]') } context 'with given listening_ips' do let(:params) do { - realm: 'coturn.example.org', listening_ips: ['1.2.3.4', '5.6.7.8'], } end @@ -30,7 +26,6 @@ describe 'coturn' do context 'with given tls_listening_port' do let(:params) do { - realm: 'coturn.example.org', tls_listening_port: 88, } end @@ -41,7 +36,6 @@ describe 'coturn' do context 'with given cert' do let(:params) do { - realm: 'coturn.example.org', cert: '/etc/cert/example.com.pem', } end @@ -52,7 +46,6 @@ describe 'coturn' do context 'with given private_key' do let(:params) do { - realm: 'coturn.example.org', private_key: '/etc/cert/pkey_example.com.pem', } end @@ -63,7 +56,6 @@ describe 'coturn' do context 'with dh2066 true' do let(:params) do { - realm: 'coturn.example.org', dh2066: true, } end @@ -74,7 +66,6 @@ describe 'coturn' do context 'with tlsv1 false' do let(:params) do { - realm: 'coturn.example.org', tlsv1: false, } end @@ -85,7 +76,6 @@ describe 'coturn' do context 'with tlsv1_1 false' do let(:params) do { - realm: 'coturn.example.org', tlsv1_1: false, } end @@ -96,7 +86,6 @@ describe 'coturn' do context 'with simple_log true' do let(:params) do { - realm: 'coturn.example.org', simple_log: true, } end