Changeset - 09625826d96f
[Not reviewed]
0 3 4
Branko Majic (branko) - 9 years ago 2015-08-16 21:25:25
branko@majic.rs
MAR-15: Added implementation for the database server role. Performs very simpled deployment and set-up of MariaDB database server.
7 files changed with 76 insertions and 1 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -1177,6 +1177,40 @@ running a bare Django project):
 
      uid: 2004
 
      virtualenv_packages:
 
        - django
 
      wsgi_application: django_example_com.wsgi:application
 
      https_tls_key: "{{ inventory_dir }}/tls/wsgi.example.com_https.key"
 
      https_tls_certificate: "{{ inventory_dir }}/tls/wsgi.example.com_https.pem"
 

	
 

	
 
Database Server
 
---------------
 

	
 
The ``database_server`` role can be used for setting-up a MariaDB database
 
server on destination machine.
 

	
 
The role implements the following:
 

	
 
* Installs MariaDB server and client.
 
* Configures MariaDB server and client to use *UTF-8* encoding by default.
 
* Sets password for the database root user.
 
* Deploys MariaDB client configuration in location ``/root/.my.cnf`` that
 
  contains username and password for the root database user.
 

	
 

	
 
Parameters
 
~~~~~~~~~~
 

	
 
**db_root_password** (string, mandatory)
 
  Password for the *root* database user.
 

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
Here is an example configuration for setting-up the database server:
 

	
 
.. code-block:: yaml
 

	
 
   ---
 

	
 
   db_root_password: root
roles/database_server/files/utf8.cnf
Show inline comments
 
new file 100644
 
[client]
 
default-character-set = utf8
 

	
 
[mysqld]
 
character-set-server  = utf8
 
collation-server      = utf8_general_ci
 
character_set_server  = utf8
 
collation_server      = utf8_general_ci
roles/database_server/handlers/main.yml
Show inline comments
 
new file 100644
 
---
 

	
 
- name: Restart MariaDB
 
  service: name=mysql state=restarted
 
\ No newline at end of file
roles/database_server/tasks/main.yml
Show inline comments
 
new file 100644
 
---
 

	
 
- name: Install MariaDB
 
  apt: name="{{ item }}" state=installed
 
  with_items:
 
    - mariadb-client
 
    - mariadb-server
 
    - python-mysqldb
 

	
 
- name: Enable and start MariaDB
 
  service: name=mysql enabled=yes state=started
 

	
 
- name: Set password for the root database user
 
  mysql_user: check_implicit_admin=yes name=root password="{{ db_root_password }}"
 

	
 
- name: Deploy username and password for the root database user
 
  template: src="root_my.cnf.j2" dest="/root/.my.cnf"
 
            owner=root group=root mode=400
 

	
 
- name: Set UTF-8 encoding as default for MariaDB
 
  copy: src="utf8.cnf" dest="/etc/mysql/conf.d/utf8.cnf"
 
        owner=root group=root mode=644
 
  notify: Restart MariaDB
roles/database_server/templates/root_my.cnf.j2
Show inline comments
 
new file 100644
 
[client]
 
user=root
 
password={{ db_root_password }}
testsite/group_vars/web.yml
Show inline comments
 
@@ -19,7 +19,9 @@ smtp_relay_host: mail.example.com
 
smtp_relay_truststore: /etc/ssl/certs/example_ca_chain.pem
 

	
 
https_tls_key: "{{ inventory_dir }}/tls/web.example.com_https.key"
 
https_tls_certificate: "{{ inventory_dir }}/tls/web.example.com_https.pem"
 

	
 
web_default_title: "Welcome to Example Inc."
 
web_default_message: "You are attempting to access the web server using a wrong name or an IP address. Please check your URL."
 
\ No newline at end of file
 
web_default_message: "You are attempting to access the web server using a wrong name or an IP address. Please check your URL."
 

	
 
db_root_password: "root"
 
\ No newline at end of file
testsite/playbooks/web.yml
Show inline comments
 
@@ -4,9 +4,10 @@
 
  remote_user: ansible
 
  sudo: yes
 
  roles:
 
    - common
 
    - ldap_client
 
    - mail_forwarder
 
    - database_server
 
    - web_server
 
    - phpinfo
 
    - wsgihello
0 comments (0 inline, 0 general)