Changeset - 5283779cf2aa
[Not reviewed]
3 5 0
Branko Majic (branko) - 5 years ago 2020-12-23 22:20:08
branko@majic.rs
MAR-168: Clean-up references to database_server root password:

- Updated role reference documentation.
- Updated usage instructions.
- Updated test configurations.
- Remvoed unused files/variables.
- Updated test site configuration.
8 files changed with 4 insertions and 39 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -1979,58 +1979,50 @@ running a bare Django project):
 
        text_colour: "black"
 
        text: "TEST ENVIRONMENT"
 
      proxy_headers:
 
        Accept-Encoding: '""'
 

	
 
    # Use wsgi_requirements to deploy Gunicorn.
 
    - role: wsgi_website
 
      fqdn: wsgi.example.com
 
      wsgi_application: wsgi:main
 
      wsgi_requirements:
 
        - gunicorn==19.7.1
 
	- futures==3.1.1
 

	
 

	
 
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.
 

	
 
.. note::
 
   On Debian Stretch it is possible to login into the database through
 
   Unix socket as ``root`` operating system account as well - relying
 
   on Unix socket user authentication without providing password. This
 
   is the default set-up of MariaDB server on Debian Stretch
 

	
 
* Deploys MariaDB client configuration in location ``/root/.my.cnf`` that
 
  contains username and password for the root database user.
 
* Sets-up the database root user for passwordless login via UNIX
 
  socket authentication.
 

	
 

	
 
Role dependencies
 
~~~~~~~~~~~~~~~~~
 

	
 
Depends on the following roles:
 

	
 
* **common**
 

	
 

	
 
Parameters
 
~~~~~~~~~~
 

	
 
This role has no parameters.
 

	
 

	
 
Distribution compatibility
 
~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
Role is compatible with the following distributions:
 

	
 
- Debian 9 (Stretch)
 

	
 

	
docs/usage.rst
Show inline comments
 
@@ -1322,60 +1322,50 @@ Adding the database server
 

	
 
Since both of the web applications we want to deploy need a database, we will
 
proceed to set-up the database server role on the web server itself. *Majic
 
Ansible Roles* in particular come with a role that will deploy MariaDB database
 
server.
 

	
 
1. Update the playbook for web server to include the database server role.
 

	
 

	
 
    :file:`~/mysite/playbooks/web.yml`
 
    ::
 

	
 
      ---
 

	
 
      - hosts: web
 
        remote_user: ansible
 
        become: yes
 
        roles:
 
          - common
 
          - ldap_client
 
          - mail_forwarder
 
          - web_server
 
          - database_server
 

	
 
2. Now let's configure the role. This is rather simplistic, since we only need
 
   to set the database server root (admin) password.
 

	
 
   .. note::
 
      Default MariaDB server configuration on Debian Stretch enables
 
      the ``root`` OS user to login via Unix socket without providing
 
      password as well.
 

	
 
   :file:`~/mysite/group_vars/web.yml`
 
   ::
 

	
 
      db_root_password: root
 
2. This particular role has no parameters, and no additional steps are
 
   necessary to configure it. So move along...
 

	
 
3. No TLS support has been implemented for this role (yet), so simply apply the
 
   changes::
 

	
 
     workon mysite && ansible-playbook playbooks/site.yml
 

	
 
4. If no errors have been reported, you should have a database server up and
 
   running on the web server. You should be able to log-in using password
 
   ``root`` by running the following command on the web server itself::
 

	
 
     mysql -uroot -p
 

	
 
   Of course, no database has been created for either of the web applications,
 
   but we will get to that one later (there is a dedicated ``database`` role
 
   which can be combined with web app roles for this purpose).
 

	
 

	
 
Deploying a PHP web application (The Bug Genie)
 
-----------------------------------------------
 

	
 
We have some basic infrastructure up and running on our web server, so
 
now we can move on to setting-up a PHP web application on it. As
 
mentioned before, we will take *The Bug Genie* as an example.
 

	
roles/database/molecule/default/group_vars/parameters-mandatory.yml
Show inline comments
 
---
 

	
 
db_name: testdb
 
db_password: testdbpassword
 

	
 
# database_server role
 
db_root_password: "root_password"
roles/database/molecule/default/group_vars/parameters-optional.yml
Show inline comments
 
---
 

	
 
db_name: testdb
 
db_password: testdbpassword
 
enable_backup: true
 

	
 
# database_server
 
db_root_password: "root_password"
 

	
 
# backup_client
 
backup_client_username: "bak-localhost"
 
backup_encryption_key: "{{ lookup('file', 'tests/data/gnupg/parameters-optional.asc') }}"
 
backup_server: localhost
 
backup_server_host_ssh_public_keys:
 
  - "{{ lookup('file', 'tests/data/ssh/server_rsa.pub') }}"
 
  - "{{ lookup('file', 'tests/data/ssh/server_ed25519.pub') }}"
 
  - "{{ lookup('file', 'tests/data/ssh/server_ecdsa.pub') }}"
 
backup_ssh_key: "{{ lookup('file', 'tests/data/ssh/parameters-optional' ) }}"
roles/database_server/molecule/default/group_vars/deprecated.yml
Show inline comments
 
deleted file
roles/database_server/molecule/default/group_vars/parameters-mandatory.yml
Show inline comments
 
deleted file
roles/database_server/templates/root_my.cnf.j2
Show inline comments
 
deleted file
testsite/group_vars/web.yml
Show inline comments
 
---
 

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

	
 
smtp_relay_host: mail.{{ testsite_domain }}
 

	
 
smtp_relay_truststore: "{{ lookup('file', inventory_dir + '/tls/ca.pem') }}"
 

	
 
default_https_tls_key: "{{ lookup('file', inventory_dir + '/tls/web.' + testsite_domain + '_https.key') }}"
 
default_https_tls_certificate: "{{ lookup('file', inventory_dir + '/tls/web.' + testsite_domain + '_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."
 

	
 
db_root_password: "root"
 

	
 
website_mail_recipients: "john.doe@example.com"
 

	
 
environment_indicator:
 
  background_colour: "purple"
 
  text_colour: "white"
 
  text: "Majic Ansible Roles Test Site"
 

	
 
proxy_headers:
 
  Accept-Encoding: '"gzip"'
 

	
 
web_server_tls_protocols:
 
  - TLSv1.2
 
  - TLSv1.1
 

	
 
web_server_tls_ciphers: "DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:\
 
DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:ECDHE-RSA-AES128-GCM-SHA256:\
 
ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA:!aNULL:!MD5:!EXPORT"
0 comments (0 inline, 0 general)