Changeset - dbc3381e1ff3
[Not reviewed]
0 3 3
Branko Majic (branko) - 10 years ago 2016-01-06 01:01:47
branko@majic.rs
MAR-44: Implemented backup support for the XMPP server role. Updated test site to include XMPP server as one of the backup clients.
6 files changed with 32 insertions and 1 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -554,192 +554,203 @@ Parameters
 
  connections. This applies for both remote and local connections.
 

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
Here is an example configuration for setting-up LDAP server:
 

	
 
.. code-block:: yaml
 

	
 
  ---
 

	
 
  ldap_server_domain: "example.com"
 
  ldap_server_organization: "Example Corporation"
 
  ldap_server_log_level: 256
 
  ldap_server_tls_certificate: ~/tls/ldap.example.com_ldap.pem
 
  ldap_server_tls_key: ~/tls/ldap.example.com_ldap.key
 
  ldap_server_ssf: 128
 
  
 
  ldap_permissions:
 
    - >
 
      to *
 
      by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth manage
 
      by * break
 
    - >
 
      to attrs=userPassword,shadowLastChange
 
      by self write
 
      by anonymous auth
 
      by dn="cn=admin,dc=example,dc=com" write
 
      by * none
 
    - >
 
      to dn.base=""
 
      by * read
 
    - >
 
      to *
 
      by self write
 
      by dn="cn=admin,dc=example,dc=com" write
 
      by users read
 
      by * none
 
  
 
  ldap_entries:
 
    - dn: ou=people,dc=example,dc=com
 
      objectClass: organizationalUnit
 
      ou: people
 
    - dn: ou=groups,dc=example,dc=com
 
      objectClass: organizationalUnit
 
      ou: groups
 
    - dn: uid=john,dc=example,dc=com
 
      objectClass:
 
        - inetOrgPerson
 
        - simpleSecurityObject
 
      userPassword: somepassword
 
      uid: john
 
      cn: John Doe
 
      sn: Doe
 

	
 

	
 
XMPP Server
 
-----------
 

	
 
The ``xmpp_server`` role can be used for setting-up Prosody, an XMPP server, on
 
destination machine.
 

	
 
The role implements the following:
 

	
 
* Sets-up the Prosody apt repository.
 
* Deploys XMPP TLS private key and certificate.
 
* Installs Prosody.
 
* Configures Prosody.
 
* Configures firewall to allow incoming connections to the XMPP server.
 

	
 
Prosody is configured as follows:
 

	
 
* Modules enabled: roster, saslauth, tls, dialback, posix, private, vcard,
 
  version, uptime, time, ping, pep, register, admin_adhoc, announce, legacyauth.
 
* Self-registration is not allowed.
 
* TLS is configured. Legacy TLS is available on port 5223.
 
* Client-to-server communication requires encryption (TLS).
 
* Authentication is done via LDAP. For setting the LDAP TLS truststore, see
 
  :ref:`LDAP Client <ldap_client>`.
 
* Internal storage is used.
 
* For each domain specified, a dedicated conference/multi-user chat (MUC)
 
  service is set-up, with FQDN set to ``conference.DOMAIN``.
 
* For each domain specified, a dedicated file proxy service will be set-up, with
 
  FQDN set to ``proxy.DOMAIN``.
 

	
 
Prosody expects a specific directory structure in LDAP when doing look-ups:
 

	
 
* Prosody will log-in to LDAP as user
 
  ``cn=prosody,ou=services,XMPP_LDAP_BASE_DN``.
 
* User entries are read from sub-tree (first-level only)
 
  ``ou=people,XMPP_LDAP_BASE_DN``. Query filter used for finding users is
 
  ``(&(mail=$user@$host)(memberOf=cn=xmpp,ou=groups,XMPP_LDAP_BASE_DN))``. This
 
  allows group-based granting of XMPP service to users.
 

	
 

	
 
Backups
 
~~~~~~~
 

	
 
If the backup for this role has been enabled, the following paths are backed-up:
 

	
 
**/var/lib/prosody/**
 
  Roster information, as well as undelivered (offline) messages for all XMPP
 
  users. Keep in mind that list of available users and their credentials are
 
  stored in the LDAP directory (which is backed-up via LDAP server role).
 

	
 

	
 
Parameters
 
~~~~~~~~~~
 

	
 
**xmpp_administrators** (list, mandatory)
 
  List of Prosody users that should be granted administrator privileges over
 
  Prosody. Each item is a string with value equal to XMPP user ID
 
  (i.e. ``john.doe@example.com``).
 

	
 
**xmpp_domains** (list, optional, ``{{ ansible_domain }}``)
 
  List of domains that are served by this Prosody instance. Each item is a
 
  string specifying a domain.
 

	
 
**xmpp_ldap_base_dn** (string, mandatory)
 
  Base DN on the LDAP server. A specific directory structure is expected under
 
  this entry (as explained above) in order to locate the available domains,
 
  users, aliases etc.
 

	
 
**xmpp_ldap_password** (string, mandatory)
 
  Password used for authenticating to the LDAP server.
 

	
 
**xmpp_ldap_server** (string, mandatory)
 
  Fully qualified domain name, hostname, or IP address of the LDAP server used
 
  for user authentication and listing.
 

	
 
**xmpp_tls_certificate** (string, optional, ``{{ tls_certificate_dir }}/{{ ansible_fqdn }}_xmpp.pem``)
 
  Path to file on Ansible host that contains the X.509 certificate used for TLS
 
  for SMTP service. The file will be copied to directory ``/etc/ssl/certs/``.
 

	
 
**xmpp_tls_key** (string, optional, ``{{ tls_private_key_dir }}/{{ ansible_fqdn }}_xmpp.key``)
 
  Path to file on Ansible host that contains the private key used for TLS for
 
  XMPP service. The file will be copied to directory ``/etc/ssl/private/``.
 

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
Here is an example configuration for setting-up XMPP server using Prosody:
 

	
 
.. code-block:: yaml
 

	
 
  ---
 

	
 
  xmpp_administrators:
 
    - john.doe@example.com
 
  xmpp_domains:
 
    - example.com
 
  xmpp_ldap_base_dn: dc=example,dc=com
 
  xmpp_ldap_password: xmpp
 
  xmpp_ldap_server: ldap.example.com
 
  # These are default key and certificate that generated during Prosody
 
  # installation. Possibly you want to deploy your own.
 
  xmpp_tls_key: /etc/prosody/certs/localhost.key
 
  xmpp_tls_certificate: /etc/prosody/certs/localhost.crt
 

	
 

	
 
Mail Server
 
-----------
 

	
 
The ``mail_server`` role can be used for setting-up a complete mail server
 
solution, which includes both SMTP and IMAP service, on destination machine.
 

	
 
Postfix is used SMTP, while Dovecot is used for IMAP.
 

	
 
The role implements the following:
 

	
 
* Installs rsync.
 
* Deploys IMAP/SMTP TLS private keys and certificates.
 
* Installs and configures Dovecot, Postfix, ClamAV, and ClamAV Milter.
 
* Purges Exim4 configuration (just in case).
 
* Installs SWAKS (utility for testing SMTP servers).
 
* Sets-up the necessary directories and files under Postfix chroot.
 
* Configures firewall to allow incoming connections to the mail server. This
 
  includes set-up of redirection from TCP port 26 to TCP port 25 (alternate SMTP
 
  to work around common network blocks).
 

	
 
Deployed services are configured as follows:
 

	
 
* Both Postfix and Dovecot look-up available domains, users, and aliases in
 
  LDAP.
 
* Incoming and outgoing mail is scanned with ClamAV (via ClamAV
 
  Milter). Infected mails are rejected.
 
* Mail is stored in directory ``/var/MAIL_USER/DOMAIN/USER``, using ``Maildir``
 
  format.
 
* TLS is required for user log-ins for both SMTP and IMAP.
 
* RBL's are used for combating spam (if any is specified in configuration, see
 
  below).
 

	
 
Both Postfix and Dovecot expect a specific directory structure in LDAP when
 
doing look-ups:
 

	
 
* Postfix will log-in to LDAP as user
 
  ``cn=postfix,ou=services,MAIL_LDAP_BASE_DN``.
 
* Dovecot will log-in to LDAP as user
 
  ``cn=dovecot,ou=services,MAIL_LDAP_BASE_DN``.
 
* Domain entries need to be available as
 
  ``dc=DOMAIN,ou=domains,ou=mail,ou=services,MAIL_LDAP_BASE_DN``.
roles/xmpp_server/files/backup_patterns
Show inline comments
 
new file 100644
 
/var/lib/prosody
 
\ No newline at end of file
roles/xmpp_server/meta/main.yml
Show inline comments
 
new file 100644
 
---
 

	
 
dependencies:
 
  - role: backup_client
 
    when: enable_backup
 
\ No newline at end of file
roles/xmpp_server/tasks/backup.yml
Show inline comments
 
new file 100644
 
---
 

	
 
- name: Deploy include patterns to backup
 
  copy: src="backup_patterns" dest="/etc/duply/main/patterns/xmpp_server"
 
        owner="root" group="root" mode="700"
 
  notify:
 
    - Assemble Duply include patterns
 
\ No newline at end of file
roles/xmpp_server/tasks/main.yml
Show inline comments
 
---
 

	
 
- name: Install Python apt bindings
 
  apt: name=python-apt
 

	
 
- name: Add Prosody repository apt key
 
  apt_key:
 
    data: "{{ lookup('file', 'prosody-debian-packages.gpg') }}"
 
    state: present
 

	
 
- name: Add Prosody repository
 
  apt_repository: repo="deb http://packages.prosody.im/debian jessie main" state=present
 

	
 
- name: Install Lua Sec library (needed for TLS)
 
  apt: name=lua-sec state=installed
 

	
 
- name: Install Lua LDAP library
 
  apt: name=lua-ldap state=installed
 

	
 
- name: Install Prosody
 
  apt: name=prosody state=installed
 

	
 
- name: Allow Prosody user to traverse the directory with TLS private keys
 
  user: name=prosody append=yes groups=ssl-cert
 

	
 
- name: Deploy XMPP TLS private key
 
  copy: dest="/etc/ssl/private/{{ xmpp_tls_key | basename }}" src="{{ xmpp_tls_key }}"
 
        mode=640 owner=root group=prosody
 
  notify:
 
    - Restart Prosody
 

	
 
- name: Deploy XMPP TLS certificate
 
  copy: dest="/etc/ssl/certs/{{ xmpp_tls_certificate | basename }}" src="{{ xmpp_tls_certificate }}"
 
        mode=644 owner=root group=root
 
  notify:
 
    - Restart Prosody
 

	
 
- name: Set-up directory for storing additional Prosody modules
 
  file: path=/usr/local/lib/prosody/modules/ state=directory mode=755 owner=root group=root
 

	
 
- name: Deploy the Prosody mod_auth_ldap module
 
  get_url: url=https://prosody-modules.googlecode.com/hg/mod_auth_ldap/mod_auth_ldap.lua
 
           dest=/usr/local/lib/prosody/modules/mod_auth_ldap.lua
 

	
 
- name: Set-up file permissions for the Prosody mod_auth_ldap module
 
  file: dest=/usr/local/lib/prosody/modules/mod_auth_ldap.lua owner=root group=root mode=644
 

	
 
- name: Deploy Prosody configuration file
 
  template: src=prosody.cfg.lua.j2 dest=/etc/prosody/prosody.cfg.lua
 
  notify:
 
    - Restart Prosody
 

	
 
- name: Enable and start Prosody service
 
  service: name=prosody enabled=yes state=started
 

	
 
- name: Deploy firewall configuration for XMPP server
 
  copy: src="ferm_xmpp.conf" dest="/etc/ferm/conf.d/30-xmpp.conf" owner=root group=root mode=640
 
  notify:
 
    - Restart ferm
 
\ No newline at end of file
 
    - Restart ferm
 

	
 
- name: Enable backup
 
  include: backup.yml
 
  when: enable_backup
 
\ No newline at end of file
testsite/group_vars/backup.yml
Show inline comments
 
---
 

	
 
local_mail_aliases:
 
  root: "root john.doe@{{ testsite_domain }}"
 

	
 
smtp_relay_host: mail.{{ testsite_domain }}
 

	
 
smtp_relay_truststore: /etc/ssl/certs/ca.pem
 

	
 
backup_clients:
 
  - server: web.{{ testsite_domain }}
 
    public_key: "{{ lookup('file', inventory_dir + '/ssh/web.' + testsite_domain + '.pub') }}"
 
    ip: 10.32.64.18
 
  - server: mail.{{ testsite_domain }}
 
    public_key: "{{ lookup('file', inventory_dir + '/ssh/mail.' + testsite_domain + '.pub') }}"
 
    ip: 10.32.64.15
 
  - server: ldap.{{ testsite_domain }}
 
    public_key: "{{ lookup('file', inventory_dir + '/ssh/ldap.' + testsite_domain + '.pub') }}"
 
    ip: 10.32.64.12
 
  - server: xmpp.{{ testsite_domain }}
 
    public_key: "{{ lookup('file', inventory_dir + '/ssh/xmpp.' + testsite_domain + '.pub') }}"
 
    ip: 10.32.64.16
 

	
 
backup_host_ssh_private_keys:
 
  dsa: "{{ lookup('file', inventory_dir + '/ssh/backup_server_dsa_key') }}"
 
  rsa: "{{ lookup('file', inventory_dir + '/ssh/backup_server_rsa_key') }}"
 
  ed25519: "{{ lookup('file', inventory_dir + '/ssh/backup_server_ed25519_key') }}"
 
  ecdsa: "{{ lookup('file', inventory_dir + '/ssh/backup_server_ecdsa_key') }}"
0 comments (0 inline, 0 general)