Changeset - 40689344a8f3
[Not reviewed]
0 3 2
Branko Majic (branko) - 9 years ago 2015-08-16 21:41:53
branko@majic.rs
MAR-15: Implemented role for deploying a MariaDB database.
5 files changed with 53 insertions and 0 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -1214,3 +1214,39 @@ Here is an example configuration for setting-up the database server:
 
   ---
 

	
 
   db_root_password: root
 

	
 

	
 
Database
 
--------
 

	
 
The ``database`` role can be used for creating a MariaDB database and
 
accompanying user on destination machine.
 

	
 
The role implements the following:
 

	
 
* Creates MariaDB database.
 
* Creates a dedicated user capable of performing any operation on the created
 
  database. Username is set to be same as the name of database.
 

	
 

	
 
Parameters
 
~~~~~~~~~~
 

	
 
**db_name** (string, mandatory)
 
  Name of the database that should be created.
 

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

	
 

	
 
Examples
 
~~~~~~~~
 

	
 
Here is an example configuration for creating a single database (for some
 
website):
 

	
 
.. code-block:: yaml
 

	
 
  - role: database
 
    db_name: phpinfo_example_com
 
    db_password: phpinfo_example_com
roles/database/meta/main.yml
Show inline comments
 
new file 100644
 
---
 

	
 
allow_duplicates: yes
 
\ No newline at end of file
roles/database/tasks/main.yml
Show inline comments
 
new file 100644
 
---
 

	
 
- name: "Create database {{ db_name }}"
 
  mysql_db: name="{{ db_name }}" state=present
 

	
 
- name: "Create database user {{ db_name }}"
 
  mysql_user: name="{{ db_name }}" password="{{ db_password }}"
 
              priv=*.*:ALL state=present
testsite/playbooks/roles/phpinfo/meta/main.yml
Show inline comments
 
@@ -9,3 +9,6 @@ dependencies:
 
    uid: 2000
 
    https_tls_key: "{{ inventory_dir }}/tls/phpinfo.example.com_https.key"
 
    https_tls_certificate: "{{ inventory_dir }}/tls/phpinfo.example.com_https.pem"
 
  - role: database
 
    db_name: phpinfo_example_com
 
    db_password: phpinfo_example_com
 
\ No newline at end of file
testsite/playbooks/roles/wsgihello/meta/main.yml
Show inline comments
 
@@ -10,3 +10,6 @@ dependencies:
 
      - /static/
 
    https_tls_key: "{{ inventory_dir }}/tls/wsgi.example.com_https.key"
 
    https_tls_certificate: "{{ inventory_dir }}/tls/wsgi.example.com_https.pem"
 
  - role: database
 
    db_name: wsgi_example_com
 
    db_password: wsgi_example_com
 
\ No newline at end of file
0 comments (0 inline, 0 general)