From a16015664dff5a24c5b1b301fa87d2ae06b3b4aa Mon Sep 17 00:00:00 2001
From: Benedetto Debora <Debora.Benedetto@hpecds.com>
Date: Mon, 28 Feb 2022 12:39:42 +0100
Subject: [PATCH] Refactoring: re-organized ansible files, update properties
 with new templates location

---
 .../terraform/.terraform.lock.hcl             | 21 -------------------
 template-location.properties                  |  4 +++-
 .../Databases-templates/mysql-vars.tpl        |  4 ----
 .../Databases-templates/postgres-vars.tpl     |  4 ----
 .../wordpress-vars.tpl                        |  6 ------
 .../mysql-play.tpl => ubuntu/mysql.tpl}       |  2 --
 .../postgres-play.tpl => ubuntu/postgres.tpl} |  3 ---
 .../wordpress.tpl}                            | 13 +++++-------
 8 files changed, 8 insertions(+), 49 deletions(-)
 delete mode 100644 output_file_example/wordpress_azure/terraform/.terraform.lock.hcl
 delete mode 100644 templates/ansible/Databases-templates/mysql-vars.tpl
 delete mode 100644 templates/ansible/Databases-templates/postgres-vars.tpl
 delete mode 100644 templates/ansible/Docker-services-templates/wordpress-vars.tpl
 rename templates/ansible/{Databases-templates/mysql-play.tpl => ubuntu/mysql.tpl} (98%)
 rename templates/ansible/{Databases-templates/postgres-play.tpl => ubuntu/postgres.tpl} (97%)
 rename templates/ansible/{Docker-services-templates/wordpress-play.tpl => ubuntu/wordpress.tpl} (80%)

diff --git a/output_file_example/wordpress_azure/terraform/.terraform.lock.hcl b/output_file_example/wordpress_azure/terraform/.terraform.lock.hcl
deleted file mode 100644
index 8ac33bf..0000000
--- a/output_file_example/wordpress_azure/terraform/.terraform.lock.hcl
+++ /dev/null
@@ -1,21 +0,0 @@
-# This file is maintained automatically by "terraform init".
-# Manual edits may be lost in future updates.
-
-provider "registry.terraform.io/hashicorp/azurerm" {
-  version     = "2.85.0"
-  constraints = "~> 2.65"
-  hashes = [
-    "h1:vNaBITW0Ds/fgAUZnyl4v9idIBSOqe4NlCXhMsM/CVw=",
-    "zh:03461c202d202732a5a770a159512664b635d144d10d707376c9a376deb80568",
-    "zh:248748c9dccf4efc65e323d651ecba18da067f33f41203b20a5364bd05d3f8ee",
-    "zh:2bedcf1a56e1d7ae5dbc1881ac404379abe908f2b63bfde710d52f1e3c0b4bcb",
-    "zh:495a861c19e6bd4c9c096f8ccba02f5d71e9f1abdb88493994f4b4f014897b44",
-    "zh:5660eddc6e5d78a80b0e748bed9fa16a406f6f3ddefdf1e4102353397a382fc9",
-    "zh:6384b8c5d986b221820a6daffebb26bc00537f9fe64cab65a573097245561890",
-    "zh:70155e6ce66ccc65d7d3ace9c2bb5f8f3575f595df0404b2e32dc342ae08c06b",
-    "zh:7b9e3a6b89862108e59b5aa2db189f6ac28688c4e84e6ad4ff0b777cdda35382",
-    "zh:844514a87268fc58238a9c337d3ce41e5a2923634b554e2d72e97d810153ff35",
-    "zh:a302d17e8a20e7e75b36a58e3aec0e5fb1f3134cd410a6790f857a734baadf80",
-    "zh:cb9313b00e8d9e4b3c4c2f93c4e529eb7c9805817e55afadb3ae80ff193d9663",
-  ]
-}
diff --git a/template-location.properties b/template-location.properties
index eb216af..af672eb 100644
--- a/template-location.properties
+++ b/template-location.properties
@@ -5,4 +5,6 @@ net = templates/terraform/open_stack/network.tpl
 sg = templates/terraform/open_stack/port_rule.tpl
 
 [ansible.ubuntu]
-nginx = templates/ansible/ubuntu/nginx.tpl
\ No newline at end of file
+nginx = templates/ansible/ubuntu/nginx.tpl
+mysql = templates/ansible/ubuntu/mysql-play.tpl
+wordpress = templates/ansible/ubuntu/wordpress-play.tpl
\ No newline at end of file
diff --git a/templates/ansible/Databases-templates/mysql-vars.tpl b/templates/ansible/Databases-templates/mysql-vars.tpl
deleted file mode 100644
index 971cbd1..0000000
--- a/templates/ansible/Databases-templates/mysql-vars.tpl
+++ /dev/null
@@ -1,4 +0,0 @@
----
-db_user: ###DB_USER###
-db_password: ###DB_PASSWORD###
-db_name: ###DB_NAME###
\ No newline at end of file
diff --git a/templates/ansible/Databases-templates/postgres-vars.tpl b/templates/ansible/Databases-templates/postgres-vars.tpl
deleted file mode 100644
index 971cbd1..0000000
--- a/templates/ansible/Databases-templates/postgres-vars.tpl
+++ /dev/null
@@ -1,4 +0,0 @@
----
-db_user: ###DB_USER###
-db_password: ###DB_PASSWORD###
-db_name: ###DB_NAME###
\ No newline at end of file
diff --git a/templates/ansible/Docker-services-templates/wordpress-vars.tpl b/templates/ansible/Docker-services-templates/wordpress-vars.tpl
deleted file mode 100644
index d7e874e..0000000
--- a/templates/ansible/Docker-services-templates/wordpress-vars.tpl
+++ /dev/null
@@ -1,6 +0,0 @@
----
-WORDPRESS_DB_HOST: ###WORDPRESS_DB_HOST###
-WORDPRESS_DB_USER: ###WORDPRESS_DB_USER###
-WORDPRESS_DB_PASSWORD: ###WORDPRESS_DB_PASSWORD###
-WORDPRESS_DB_NAME: ###WORDPRESS_DB_NAME###
-WORDPRESS_TABLE_PREFIX: ###WORDPRESS_TABLE_PREFIX###
\ No newline at end of file
diff --git a/templates/ansible/Databases-templates/mysql-play.tpl b/templates/ansible/ubuntu/mysql.tpl
similarity index 98%
rename from templates/ansible/Databases-templates/mysql-play.tpl
rename to templates/ansible/ubuntu/mysql.tpl
index d8d7829..afb4242 100644
--- a/templates/ansible/Databases-templates/mysql-play.tpl
+++ b/templates/ansible/ubuntu/mysql.tpl
@@ -1,8 +1,6 @@
 ---
 - hosts: DB
   become: yes
-  vars_files:
-    - mysql-vars.yml
 
   pre_tasks:
   - name: Install MySQL
diff --git a/templates/ansible/Databases-templates/postgres-play.tpl b/templates/ansible/ubuntu/postgres.tpl
similarity index 97%
rename from templates/ansible/Databases-templates/postgres-play.tpl
rename to templates/ansible/ubuntu/postgres.tpl
index 1348249..129ee69 100644
--- a/templates/ansible/Databases-templates/postgres-play.tpl
+++ b/templates/ansible/ubuntu/postgres.tpl
@@ -2,9 +2,6 @@
 - hosts: DB
   become: yes
 
-  vars_files:
-    - postgres-vars.yml
-
   pre_tasks:
     - name: "Install packages"
       ###OS###: "name={{ item }} state=present"
diff --git a/templates/ansible/Docker-services-templates/wordpress-play.tpl b/templates/ansible/ubuntu/wordpress.tpl
similarity index 80%
rename from templates/ansible/Docker-services-templates/wordpress-play.tpl
rename to templates/ansible/ubuntu/wordpress.tpl
index 45be10c..42d4399 100644
--- a/templates/ansible/Docker-services-templates/wordpress-play.tpl
+++ b/templates/ansible/ubuntu/wordpress.tpl
@@ -2,9 +2,6 @@
 - hosts: APP1
   become: yes
 
-  vars_files:
-    - wordpress-vars.yml
-
   pre_tasks:
     - name: "Install packages"
       ###OS###: "name={{ item }} state=present"
@@ -58,11 +55,11 @@
         image: wordpress:5.8.0
         state: started
         env:
-          WORDPRESS_DB_HOST: "{{WORDPRESS_DB_HOST}}"
-          WORDPRESS_DB_USER: "{{WORDPRESS_DB_USER}}"
-          WORDPRESS_DB_PASSWORD: "{{WORDPRESS_DB_PASSWORD}}"
-          WORDPRESS_DB_NAME: "{{WORDPRESS_DB_NAME}}"
-          WORDPRESS_TABLE_PREFIX: "{{WORDPRESS_TABLE_PREFIX}}"
+          WORDPRESS_DB_HOST: "{{ wordpress_db_host }}"
+          WORDPRESS_DB_USER: "{{ wordpress_db_user }}"
+          WORDPRESS_DB_PASSWORD: "{{ wordpress_db_password }}"
+          WORDPRESS_DB_NAME: "{{ wordpress_db_name }}"
+          WORDPRESS_TABLE_PREFIX: "{{ wordpress_table_prefix }}"
         ports:
           - "8080:80"
         volumes:
-- 
GitLab