--- /dev/null
+---
+- name: Creates the NGINX configuration file for a PHP site
+ # needed facts (variables) from commandline (e.g. -e domain=example.com -e force=true):
+ # domain: the site domain name
+ # optional facts:
+ # document_root: the document root of the site without path, e.g. example.com. Default: domain
+ # shortname: the short name of the site. Used for log file names
+ # php_version: the PHP version to use. Default: 8.3
+ # force: if true, the site will be created even if it already exists. Default: false
+ hosts: all
+ vars_files:
+ - ../vars/common.yaml
+ - ../vars/ssl-certificate.yaml
+ tasks:
+ - name: Check pre-requisites
+ fail: msg="The variable 'domain' must be defined and not empty."
+ when: domain is not defined or domain == ""
+ - name: create certificate for {{ domain }}
+ import_tasks: ../tasks/t_ssl_create_certificate.yaml
+ - name: Create the NGINX configuration for {{domain}}
+ import_tasks: ../tasks/t_nginx_create_site.yaml
+
--- /dev/null
+---
+- name: Creates the MySQL administrator with all privileges for all databases
+ hosts: all
+ vars_files:
+ - ../vars/mysql_vault.yaml
+ - ../vars/mysql.yaml
+ tasks:
+ - name: Create the database adminstrator {{dba_name}}
+ import_tasks : ../tasks/t_pg_create_admin.yaml
--- /dev/null
+---
+- name: Create PostGreSql database and user for a web application
+# needed facts (variables) from commandline (e.g. -e db_name=webapp):
+# db_name: name of the database
+# db_host: the ip or name of the host hosting mysql. Normally: localhost
+# db_user: name of the database user
+# db_password: password of the database user
+ hosts: all
+ vars_files:
+ - ../vars/pg_vault.yaml
+ - ../vars/pg.yaml
+ tasks:
+ - name: Create the database adminstrator {{dba_name}}
+ import_tasks : ../tasks/t_pg_db_and_user.yaml
--- /dev/null
+# needed facts (variables):
+# dba_name: name of the database user with all privileges
+# dba_password: password of the database user with all privileges
+- name: Create the database administrator {{dba_name}}
+ community.postgresql.postgresql_user:
+ name: "{{ dba_name }}"
+ password: "{{ dba_password }}"
+ state: present
+
+- name: Grant all privileges to dba
+ community.postgresql.postgresql_privs:
+ db: all
+ role: "dba"
+ privs: "ALL"
+ type: database
--- /dev/null
+# needed facts:
+# db_name: name of the database
+# db_host: the ip or name of the host hosting mysql. Normally: localhost
+# db_user: name of the database user
+# db_password: password of the database user
+# webapp_name: name of the web application
+# dba_name: name of the database user with all privileges
+# dba_password: password of the database user with all privileges
+
+- name: Ensure PostgreSQL database {{ db_name }} exists
+ community.postgresql.postgresql_db:
+ name: "{{ db_name }}"
+ login_host: "{{ db_host | default('localhost') }}"
+ login_user: "{{ dba_name }}"
+ login_password: "{{ dba_password }}"
+ state: present
+- name: Create the role with the name of the database: {{ db_name }} for PostgreSQL
+ community.postgresql.postgresql_user:
+ name: "{{ db_name }}"
+ login_host: "{{ db_host | default('localhost') }}"
+ login_user: "{{ dba_name }}"
+ login_password: "{{ dba_password }}"
+ db: "{{ db_name }}"
+ state: present
+- name: Create the database user {{ db_user }} for PostgreSQL
+ community.postgresql.postgresql_user:
+ name: "{{ db_user }}"
+ password: "{{ db_password }}"
+ login_host: "{{ db_host | default('localhost') }}"
+ login_user: "{{ dba_name }}"
+ login_password: "{{ dba_password }}"
+ db: "{{ db_name }}"
+ state: present
+ - name: Grant role {{ db_name }} to user {{ db_user }}
+ community.postgresql.postgresql_privs:
+ db: "postgres"
+ role: "{{ db_user }}"
+ type: role
+ privs: "{{ db_name }}"
+ login_host: "{{ db_host | default('localhost') }}"
+ login_user: "{{ dba_name }}"
+ login_password: "{{ dba_password }}"
\ No newline at end of file