Enable LDAP on the XMPP 5apps.com vhost
Refactor the ejabberd config file to remove hardcoded values about the vhosts Refs #123
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
|
||||
include_recipe "kosmos-postgresql"
|
||||
|
||||
ejabberd_credentials = data_bag_item("credentials", "ejabberd")
|
||||
|
||||
cookbook_file "#{Chef::Config[:file_cache_path]}/pg.sql" do
|
||||
source "pg.sql"
|
||||
mode "0664"
|
||||
@@ -55,35 +57,90 @@ postgresql_user 'ejabberd' do
|
||||
password postgresql_data_bag_item['ejabberd_user_password']
|
||||
end
|
||||
|
||||
postgresql_database 'ejabberd' do
|
||||
owner 'ejabberd'
|
||||
action :create
|
||||
notifies :run, "execute[create db schema ejabberd]", :delayed
|
||||
hosts = [
|
||||
{
|
||||
name: "kosmos.org",
|
||||
sql_database: "ejabberd",
|
||||
ldap_enabled: false,
|
||||
append_host_config: <<-EOF
|
||||
modules:
|
||||
mod_muc:
|
||||
host: "kosmos.chat"
|
||||
access:
|
||||
- allow
|
||||
access_admin:
|
||||
- allow: admin
|
||||
access_create: muc_create
|
||||
access_persistent: muc_create
|
||||
max_user_conferences: 1000
|
||||
default_room_options:
|
||||
mam: true
|
||||
EOF
|
||||
},
|
||||
{
|
||||
name: "5apps.com",
|
||||
sql_database: "ejabberd_5apps",
|
||||
ldap_enabled: true,
|
||||
ldap_password: ejabberd_credentials['5apps_ldap_password'],
|
||||
append_host_config: <<-EOF
|
||||
modules:
|
||||
mod_muc:
|
||||
host: "muc.@HOST@"
|
||||
access:
|
||||
- allow: local
|
||||
access_admin:
|
||||
- allow: admin
|
||||
access_create: muc_create
|
||||
access_persistent: muc_create
|
||||
max_user_conferences: 1000
|
||||
default_room_options:
|
||||
anonymous: false
|
||||
public: true
|
||||
members_only: true
|
||||
public_list: false
|
||||
persistent: true
|
||||
mam: true
|
||||
EOF
|
||||
}
|
||||
]
|
||||
|
||||
hosts.each do |host|
|
||||
postgresql_database host[:sql_database] do
|
||||
owner 'ejabberd'
|
||||
action :create
|
||||
notifies :run, "execute[create db schema #{host[:sql_database]}]", :delayed
|
||||
end
|
||||
|
||||
execute "create db schema #{host[:sql_database]}" do
|
||||
user "ejabberd"
|
||||
command "psql #{host[:sql_database]}} < #{Chef::Config[:file_cache_path]}/pg.sql"
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
postgresql_database 'ejabberd_5apps' do
|
||||
owner 'ejabberd'
|
||||
action :create
|
||||
notifies :run, "execute[create db schema ejabberd_5apps]", :delayed
|
||||
end
|
||||
ldap_domain = node['kosmos-dirsrv']['master_hostname']
|
||||
ldap_encryption_type = node.chef_environment == "development" ? "none" : "tls"
|
||||
ldap_base = "cn=users,dc=kosmos,dc=org"
|
||||
|
||||
execute "create db schema ejabberd" do
|
||||
user "ejabberd"
|
||||
command "psql ejabberd < #{Chef::Config[:file_cache_path]}/pg.sql"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "create db schema ejabberd_5apps" do
|
||||
user "ejabberd"
|
||||
command "psql ejabberd_5apps < #{Chef::Config[:file_cache_path]}/pg.sql"
|
||||
action :nothing
|
||||
end
|
||||
admin_users = [
|
||||
"greg@5apps.com",
|
||||
"sebastian@5apps.com",
|
||||
"garret@5apps.com",
|
||||
"raucao@kosmos.org",
|
||||
"greg@kosmos.org",
|
||||
"galfert@kosmos.org"
|
||||
]
|
||||
|
||||
template "/opt/ejabberd/conf/ejabberd.yml" do
|
||||
source "ejabberd.yml.erb"
|
||||
mode 0640
|
||||
sensitive true
|
||||
variables pgsql_password: postgresql_data_bag_item['ejabberd_user_password']
|
||||
variables pgsql_password: postgresql_data_bag_item['ejabberd_user_password'],
|
||||
hosts: hosts,
|
||||
ldap_base: ldap_base,
|
||||
ldap_server: ldap_domain,
|
||||
ldap_encryption_type: ldap_encryption_type,
|
||||
admin_users: admin_users
|
||||
notifies :run, "execute[ejabberdctl reload_config]", :delayed
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user