From 6bc72214612485e9dec3b7091db83123e9185cfc Mon Sep 17 00:00:00 2001
From: Benedetto Debora <Debora.Benedetto@hpecds.com>
Date: Mon, 28 Feb 2022 17:56:30 +0100
Subject: [PATCH] Refactoring: remove old files, add output folder for
 genereted files, add ansible templates

---
 Output-code/mysql-vars.yml                    |   4 -
 Output-code/outputNetwork.tf                  |  14 --
 Output-code/outputdb.tf                       |  14 --
 Output-code/outputvm.tf                       |  32 ----
 Output-code/postgres-vars.yml                 |   4 -
 Output-code/wordpress-vars.yml                |   6 -
 __pycache__/ansibleBuilder.cpython-39.pyc     | Bin 2557 -> 0 bytes
 __pycache__/ansibleUtils.cpython-39.pyc       | Bin 1905 -> 0 bytes
 ansibleBuilder.py                             |  60 -------
 ansibleUtils.py                               |  43 -----
 api/InfrastructureTemplateController.py       |   2 +-
 input_file_example/nginx/parameter.json       |   2 +-
 input_file_example/parametri.JSON             |   1 -
 input_file_example/parametri.txt              |   1 -
 input_file_example/parametriaz.JSON           |   1 -
 input_file_example/parametriaz.txt            |   1 -
 input_file_example/parametrig.JSON            |   1 -
 input_file_example/parametrig.txt             |   1 -
 input_file_example/properties.JSON            |  30 ----
 input_file_example/properties.yaml            |  18 --
 input_file_example/propertiesaz.yaml          |  16 --
 input_file_example/propertiesg.yaml           |  13 --
 input_file_example/toscainput.yaml            |  10 --
 input_file_example/wordpress/parameters.json  | 162 ++++++++----------
 main.py                                       |   7 +-
 .../nginx_openstack/terraform/main.tf         | 125 ++++++++------
 .../wordpress_azure/terraform/main.tf         | 157 +++--------------
 .../nginx_openstack/ansible/nginx.play        |  45 +++++
 .../nginx_openstack/terraform/main.tf         | 101 +++++++++++
 .../wordpress_azure/ansible/mysql.play        |  97 +++++++++++
 .../wordpress_azure/ansible/wordpress.play    |  69 ++++++++
 .../wordpress_azure/terraform/main.tf         |  47 +++++
 plugin/TemplateUtils.py                       |   3 +
 template-location.properties                  |  16 +-
 .../ansible/centos/mysql.tpl                  |   8 +-
 .../ansible/centos/postgres.tpl               |  10 +-
 .../ansible/centos/wordpress.tpl              |  16 +-
 templates/ansible/ubuntu/mysql.tpl            |   9 +-
 templates/ansible/ubuntu/postgres.tpl         |   4 +-
 templates/ansible/ubuntu/wordpress.tpl        |   7 +-
 templates/terraform/azure/init.tpl            |  15 ++
 templates/terraform/azure/network.tpl         |  32 ++--
 templates/terraform/azure/resource_group.tpl  |   6 +
 templates/terraform/azure/virtual_machine.tpl |  55 ++++++
 templates/terraform/azure/vm.tpl              |  15 --
 45 files changed, 655 insertions(+), 625 deletions(-)
 delete mode 100644 Output-code/mysql-vars.yml
 delete mode 100644 Output-code/outputNetwork.tf
 delete mode 100644 Output-code/outputdb.tf
 delete mode 100644 Output-code/outputvm.tf
 delete mode 100644 Output-code/postgres-vars.yml
 delete mode 100644 Output-code/wordpress-vars.yml
 delete mode 100644 __pycache__/ansibleBuilder.cpython-39.pyc
 delete mode 100644 __pycache__/ansibleUtils.cpython-39.pyc
 delete mode 100644 ansibleBuilder.py
 delete mode 100644 ansibleUtils.py
 delete mode 100644 input_file_example/parametri.JSON
 delete mode 100644 input_file_example/parametri.txt
 delete mode 100644 input_file_example/parametriaz.JSON
 delete mode 100644 input_file_example/parametriaz.txt
 delete mode 100644 input_file_example/parametrig.JSON
 delete mode 100644 input_file_example/parametrig.txt
 delete mode 100644 input_file_example/properties.JSON
 delete mode 100644 input_file_example/properties.yaml
 delete mode 100644 input_file_example/propertiesaz.yaml
 delete mode 100644 input_file_example/propertiesg.yaml
 delete mode 100644 input_file_example/toscainput.yaml
 create mode 100644 output_files_generated/nginx_openstack/ansible/nginx.play
 create mode 100644 output_files_generated/nginx_openstack/terraform/main.tf
 create mode 100644 output_files_generated/wordpress_azure/ansible/mysql.play
 create mode 100644 output_files_generated/wordpress_azure/ansible/wordpress.play
 create mode 100644 output_files_generated/wordpress_azure/terraform/main.tf
 rename Output-code/mysql-play.yml => templates/ansible/centos/mysql.tpl (89%)
 rename Output-code/postgres-play.yml => templates/ansible/centos/postgres.tpl (89%)
 rename Output-code/wordpress-play.yml => templates/ansible/centos/wordpress.tpl (77%)
 create mode 100644 templates/terraform/azure/init.tpl
 create mode 100644 templates/terraform/azure/resource_group.tpl
 create mode 100644 templates/terraform/azure/virtual_machine.tpl
 delete mode 100644 templates/terraform/azure/vm.tpl

diff --git a/Output-code/mysql-vars.yml b/Output-code/mysql-vars.yml
deleted file mode 100644
index 918bfb5..0000000
--- a/Output-code/mysql-vars.yml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-db_user: app1user
-db_password: app1user
-db_name: app1
\ No newline at end of file
diff --git a/Output-code/outputNetwork.tf b/Output-code/outputNetwork.tf
deleted file mode 100644
index f8a76aa..0000000
--- a/Output-code/outputNetwork.tf
+++ /dev/null
@@ -1,14 +0,0 @@
-resource "aws_subnet" "aws_subnet" {
-  vpc_id = aws_vpc.aws_vpc.id
-  cidr_block = "10.0.1.0/24"
-  tags = {
-    Name = "piacere_subnet"
-  }
-
-}
-resource "aws_vpc" "aws_vpc" {
-  cidr = "10.0.0.0/16"
-  tags = {
-    Name = "piacere_vpc"
-  }
-}
diff --git a/Output-code/outputdb.tf b/Output-code/outputdb.tf
deleted file mode 100644
index d4cb60b..0000000
--- a/Output-code/outputdb.tf
+++ /dev/null
@@ -1,14 +0,0 @@
-resource "aws_db_instance" "education" {
-  identifier             = "education"
-  instance_class         = "db.t3.micro"
-  allocated_storage      = 5
-  engine                 = "postgres"
-  engine_version         = "13.1"
-  username               = "edu"
-  password               = var.db_password
-  db_subnet_group_name   = aws_db_subnet_group.education.name
-  vpc_security_group_ids = [aws_security_group.rds.id]
-  parameter_group_name   = aws_db_parameter_group.education.name
-  publicly_accessible    = true
-  skip_final_snapshot    = true
-}
diff --git a/Output-code/outputvm.tf b/Output-code/outputvm.tf
deleted file mode 100644
index fb88657..0000000
--- a/Output-code/outputvm.tf
+++ /dev/null
@@ -1,32 +0,0 @@
-
-data "aws_ami" "ami1" {
-  #executable_users = ["self"]
-  most_recent = true
-  name_regex = "ubuntu*"
-  #owners = ["self"]
-  
-  owners = ["099720109477"] # Canonical
-}
-resource "aws_instance" "instance1" {
-  ami = data.aws_ami.ami1.id
-  instance_type = "t2.micro"
-    tags = {
-     Name = "firstvm"
-   }
-}
-
-data "aws_ami" "ami2" {
-  #executable_users = ["self"]
-  most_recent = true
-  name_regex = "ubuntu*"
-  #owners = ["self"]
-  
-  owners = ["099720109477"] # Canonical
-}
-resource "aws_instance" "instance2" {
-  ami = data.aws_ami.ami2.id
-  instance_type = "t2.micro"
-    tags = {
-     Name = "secondvm"
-   }
-}
diff --git a/Output-code/postgres-vars.yml b/Output-code/postgres-vars.yml
deleted file mode 100644
index 918bfb5..0000000
--- a/Output-code/postgres-vars.yml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-db_user: app1user
-db_password: app1user
-db_name: app1
\ No newline at end of file
diff --git a/Output-code/wordpress-vars.yml b/Output-code/wordpress-vars.yml
deleted file mode 100644
index b62b457..0000000
--- a/Output-code/wordpress-vars.yml
+++ /dev/null
@@ -1,6 +0,0 @@
----
-WORDPRESS_DB_HOST: 10.10.10.10
-WORDPRESS_DB_USER: app1user
-WORDPRESS_DB_PASSWORD: app1user
-WORDPRESS_DB_NAME: app1
-WORDPRESS_TABLE_PREFIX: wp
\ No newline at end of file
diff --git a/__pycache__/ansibleBuilder.cpython-39.pyc b/__pycache__/ansibleBuilder.cpython-39.pyc
deleted file mode 100644
index 245f04603423cbbd1fc1aaee129825259c9264d9..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 2557
zcmYe~<>g{vU|`t2VMpRB4hDwDAPzESW?*1&U|?V<c41&(NMT4}%wdRPaA!ziN?~qc
zNMUYfiehwUNMT7~ZDB}ZZDxvMa%V_kOJQ$eNMUbgieh$WNa0A~Y+*>@Y-WmLNns3T
z(BygvGT$#5L?UCjO?C_n45<uJj42FJOrZ>^%&9CXj5ZLO2}(0VX%-uXRMu3M6jmFk
ztx;?#9Kj5loVPeV^9o8!ToOwXZ*e3R6vUTQ7Np+dOwLb9jW0+n$+*Q^lA2qPlUR}p
zkwI|LWK$AL5|i1G+zDbcF)%PVg91f~fq|ihv4$a@p@yl3A)c{@xrQO0sfMM7A)dL0
zwT2;{C50iFVI`xVCTkJMe?=?|3=BoAAOd7g5jz6|gC^T8mg3Z$G@J@nG8BR0=$Egv
zRZM7cYEf~Fseys1p`nRkjDKFLOHpQ7s)DY9vrBMHKxR&&LP%<HNq$U#r=zoLkSm-{
z%qz}J%1L!9&CE$jEz&Efyu}e8pP83g5+4sTyck3<FtR~ml@L7m^kB;TG}%FV@)C1X
z<Ku5}#mDF7r<CS^*gWy^g{6r(P#NaplA>Gu@$rdydHE%YC7Jno#qsgCm~#^gig-XC
z2iXMn5QN|ciGczX6h6fu6<mxQFvwH{lEIx+Oz<ZaP|^S;6}A+XIgBZ+DQqn)QS2$~
z!3>%lw|GLJ3BWTiE&mn^INDjjse}a-=PMa+ab<#%P&|m23~~l65rEhr3{C+u;1rO>
z0FHgeEKn+7u3^jqr2tk?+!t|xqqqnh-69~rf@5D4!~(^Bkr+sxsfZIKAORu};R6mD
zP>6uk6oX7)00&H!D6-p;B8a1i7i0n-h~Nhi0w6*VL<oThkgIV=f-nOE14wN#$jQ)1
zU@8KM;*J0<qzFi1Okrwah+<A*PGM<bh+;`)O<|qG2rdm+;Q5l*5t0yn!HEYYTtNu{
zgu&qoa&HMk4Py#pGgB>74buX~g$%(AnoNGT7>hKSZn5MSq~_h?EJ{sG$;r%1E!JcP
zhu|$Sc(zW?&n?JFErDeBC=Qr7B+-Gx7!<s>c+yi#;$f1qpgaxAq6~~&j8#%7PSrzJ
zm<)<USb6|O42TbQw;MP;q%dYP6^WHFEMTl*s$s5SS;$<=TEm#al+9G6Q^K%-2}P7S
zo2kgDgkb?Qk|=91gC>h#6h}dRaY=enYH<{6Ze?*{P84T(eo;z6QEG9qCd(}zXr>M=
z$;>H^5&|XEq{QOX;&`|&euNlAzhH4{QCVhkYCOUmHgL#+3nipdF(<RQ1YA7bV#&_T
zONrvhOD&I2%gjkd4?y13luSejDuO}~l>R^|m5-5w5rV6vQNt2Nk0v9ySWE`RJuFN?
zkpSX@!&HHRfuV$<h6$V&m}{69FxD_GWMpKhVP3$rkb#i_l+QGo{HmDBwKbWGq!}0(
zZn2gZWtODgVolD;FHY5D0ekTlAIRF&l=$TQypq(s60oheSg?7D3#=XNUr-8%<~=S@
zs*phS2|}TtCVLTD_LBo;I#3-^1kQ-+ATBuRAqY?+ERtkkU;sHAY!3$$2MY%$SPXZ*
zlS0aOsmv*ia~Q!jGD{Ro3QI79ChILOM@T;NbapQiXJBAJ$!Q?#L4^-Ebn76Y%h=3V
z%T&VH%uve=%E;+VwJbF(E)218wX8KvSxhxdS<K=LDa_&wHLT(cDJ<d)wQM!a3s`E{
z7Bbed*Dx;tsba2SuVKn!t6^QpQp-`pm<8e?>tYpWsO79-UcgbqQNy{AiIJgD3LJNA
zeo-t1If<3GSjrNMihnWcR<Y=n6y#K~=vC(CXmWzfAaH;bflE+u;fV-aQ0WMc%OX$!
zYjS}jy9iX4M)AOMwp(USY7{Rtzd*{KC{|FyE-nHk*&<NRF9M~rB2`c%fs!9aLQhZ4
zODzJm7(lHELr_8o6;cdL9E@yCpc+epk&97;QG&4wmP9<A-Stp3ftmqmNd#OZYlG|r
zMGBgoMH&nY4Ei9OK*~6nz<f>CB6*N{kPuSHfRrL>2b%^;T(>xEAQiP8Bgi07+0Mbl
K$H&LTCjtQR;TCQH

diff --git a/__pycache__/ansibleUtils.cpython-39.pyc b/__pycache__/ansibleUtils.cpython-39.pyc
deleted file mode 100644
index 0ba03ad252deaa81133f89e1de3929d6ac1ee814..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 1905
zcmYe~<>g{vU|`t2VMpR@P6md@APzESVqjo!U|?V<)?r{^NMT4}%wY&&NMTB0ZefUG
zOkqi3ZDELFN?}W3Z()dHPT@%5Y+;CEN#P1+(ByszGDnl~7Nb@&$P^F{gxMJw7+4q>
z7@R?-hJZ|EOkrwas9|tnXlATss$p_rh_$I@u3=ulkixu>v6iKVC51(jp_a9VVF6<e
zNQAA1C52Uzp@y-BRgyuRp@t=e4NNoCu-Pya3e_+KGib8=B{PC-gJO^aK$ZrBER|qj
zU`S`EVTcu|WlUkHVJu@PVyR)A$W+J@%%I8mi&<G&c_o7;(=8@FgIkQnMIe1(;+MCx
zRZM7cYEf~Fseys1p`nRkjDKFLOHpQ7s)DY9vrBMHKxR&&LP%<HNq$U#r=zoLkSm-{
z%qz}J%1I3^$;>I%E2zB1Ws{RxT#}rhTVMyW;WNmkRm$n9d8tL2$?>^~CCM47MS3<l
z`N@en#ddlK)kVw<3=A(pzAFL|FF}6OWV*##T#%Dla*H)HFD11?ll>NNNosCEPGU)F
zJjk9~yu}5n$(d=H$?++PC5cgdU<)$y(&KY7^HPg%v4E&3P7oOnHix+^v8afbfq?<+
zbqE29x?B8cP6WB8m=EN7Mm|OkMlLXxV=NM4U|>iFNrI$6m=!tVGZ+{cYM4?Ovzdy-
zN*HQDk;x><(9BfJT*H*Yl+9EWSHoDtB*~D%EXk0<lFd|PmBI>2W^<ToS@NWi<T$dK
zib7I2Q@B#tL2_WTSU~2aa6^(yFoPzK-z}E1#G>L`ECo4<mA9DugKx2=q$Xu1=G|gW
zEGVfGSAYUtg@XLzlJug~;=&wVLxYt}MWPH03{hPE!SMl(&fcye!ME6wQ}asli*GSk
zmgfG-hw4*6)@W$Jg<V*;IJKxOwFsANa(-S(QDzb@>72}@;#&+WnZN;iizO>RGjAnp
z5h&o1q8b#pw^*_>^HQP&^HR&>QPMyWKbGhe0%=J~EKV(shxwfclu1C*$H2$|j#B|f
z9!3F1E=DfKBBj9;t3|>f4~c*XP&^fhfmq@U3=CDZpcv3q$gKoLBvP=$gpzYIQ}ar|
zL9MG$P+5|ZpQl@#T2fk2lAoVbj4BQ`Bn1*Lx(Yd&Nninp3A!n%WhknRbqg{Jia;ey
zktE19QXoPaM96>$Sr8!)B0zZ_IaeW~0c<?T7sWW@KzV4yfe$DSKo}On#^8`b5dno3
zl4wePayCi^fe7ej=A#8^l>o>X5Y|<Is42o9zJj1ckeQqsU!Gr-Qc#pyTntLdxI$Qk
zfq}tKll2xKw9s}c&CE$jEdpmfa26;6#X%8B86*zTVw1xrH$SB`C)EyAKo@f`Ffed1
Lad2{Qb8rIy2)nFJ

diff --git a/ansibleBuilder.py b/ansibleBuilder.py
deleted file mode 100644
index 424ef70..0000000
--- a/ansibleBuilder.py
+++ /dev/null
@@ -1,60 +0,0 @@
-import ansibleUtils 
-
-class InputData:
-    app_type: str
-    code_path: str
-    template_type: str
-    template_path: str
-    template_data: map
-
-    def __init__(self, app_type, code_path, template_type, template_path, template_data):
-        self.app_type = app_type
-        self.code_path = code_path
-        self.template_type = template_type
-        self.template_path = template_path
-        self.template_data = template_data
-
-class TemplateInfo:
-    path: str
-    type: str
-    data: map
-
-    def __init__(self, input_data: InputData):
-        self.path = input_data.template_path
-        self.type = input_data.template_type
-        self.data = input_data.template_data
-
-class AnsibleModule:
-    
-    def get_template(self, template_complete_path):
-        template = open(template_complete_path, "r")
-        return template.readlines()
-
-    def edit_template(self, template_type, template_list, template_data, kind):
-        if template_type == "postgres":
-            new_file = ansibleUtils.databases_postgres(template_list, template_data, kind)
-        if template_type == "mysql":
-            new_file = ansibleUtils.databases_mysql(template_list, template_data, kind)
-        if template_type == "wordpress":
-            new_file = ansibleUtils.service_wordpress(template_list, template_data, kind)  
-        return new_file
-
-    def write_file(self, edited_content, code_path: str):
-        file = open(code_path, "w+")
-        file.write(edited_content)
-        file.close()
-
-class AnsibleICG:
-
-    def generate_code(self, input_data: InputData):
-
-        templateFile = TemplateInfo(input_data)
-        ansibleModule = AnsibleModule()
-
-        kinds = ["play", "vars"]
-        for kind in kinds:
-            template_complete_path = templateFile.path + templateFile.type + "-" + kind + ".tpl"
-            template_list = ansibleModule.get_template(template_complete_path)
-            edited_content = ansibleModule.edit_template(templateFile.type, template_list, templateFile.data, kind)
-            code_path = input_data.code_path + templateFile.type + "-" + kind + ".yml"
-            ansibleModule.write_file(edited_content, code_path)
diff --git a/ansibleUtils.py b/ansibleUtils.py
deleted file mode 100644
index dbfe787..0000000
--- a/ansibleUtils.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from ansibleBuilder import *
-
-def generic_matcher(template_list, specific_data):
-    matching_lines = [s for s in template_list if "###" in s]
-    for line in matching_lines:
-        line_plit = line.split('###')
-        var = line_plit[1]
-        index = template_list.index(line)
-        template_list[index] = line_plit[0]+specific_data[var]+line_plit[2]
-    return template_list
-
-def databases_postgres(template_list, template_data, kind):
-    if kind == "vars":
-        new_template_list = generic_matcher(template_list, template_data[kind])
-    if kind == "play":
-        if template_data[kind]["OS"] == "debian":
-            specific_data = {"OS": "apt", "OS_PACKETS": "        - postgresql-10"}
-        elif template_data[kind]["OS"] == "centos":
-            specific_data = {"OS": "yum", "OS_PACKETS": "        - postgresql10\n        - postgresql10-server\n        - postgresql10-contrib\n        - postgresql10-libs"}
-        new_template_list = generic_matcher(template_list, specific_data)
-    return "".join(new_template_list)
-
-def databases_mysql(template_list, template_data, kind):
-    if kind == "vars":
-        new_template_list = generic_matcher(template_list, template_data[kind])
-    if kind == "play":
-        if template_data[kind]["OS"] == "debian":
-            specific_data = {"OS": "apt", "OS_PACKETS": "    - mysql-server\n    - mysql-client\n    - python-setuptools\n    - python-mysqldb\n    - libmysqlclient-dev\n    - python3-pip"}
-        elif template_data[kind]["OS"] == "centos":
-            specific_data = {"OS": "yum", "OS_PACKETS": "        - postgresql10\n        - postgresql10-server\n        - postgresql10-contrib\n        - postgresql10-libs"}
-        new_template_list = generic_matcher(template_list, specific_data)
-    return "".join(new_template_list)
-
-def service_wordpress(template_list, template_data, kind):
-    if kind == "vars":
-        new_template_list = generic_matcher(template_list, template_data[kind])
-    if kind == "play":
-        if template_data[kind]["OS"] == "debian":
-            specific_data = {"OS": "apt", "OS_PACKETS": "        - python3\n        - python3-pip\n        - docker\n        - docker.io"}
-        elif template_data[kind]["OS"] == "centos":
-            specific_data = {"OS": "yum", "OS_PACKETS": "        - docker"}
-        new_template_list = generic_matcher(template_list, specific_data)
-    return "".join(new_template_list)
\ No newline at end of file
diff --git a/api/InfrastructureTemplateController.py b/api/InfrastructureTemplateController.py
index 0706024..ca223f4 100644
--- a/api/InfrastructureTemplateController.py
+++ b/api/InfrastructureTemplateController.py
@@ -21,7 +21,7 @@ def create_infrastructure_files(intermediate_representation: dict = Body(...)):
     return FileResponse(compress_file_path, media_type='application/octet-stream', filename=compress_file_name)
 
 def choose_plugin(parameters):
-    # os.system('rm -f /opt/Output-code/*')
+    # os.system('rm -f /opt/output_files_generated/*')
     for step in parameters["steps"]:
         if step["programming_language"] == "ansible":
             input_data = step["data"]
diff --git a/input_file_example/nginx/parameter.json b/input_file_example/nginx/parameter.json
index 87c35d8..37c1f8e 100644
--- a/input_file_example/nginx/parameter.json
+++ b/input_file_example/nginx/parameter.json
@@ -1,5 +1,5 @@
 {
-  "output_path": "output_file_example/nginx_openstack/",
+  "output_path": "output_files_generated/nginx_openstack/",
   "steps": [
     {
       "programming_language": "terraform",
diff --git a/input_file_example/parametri.JSON b/input_file_example/parametri.JSON
deleted file mode 100644
index 0372e76..0000000
--- a/input_file_example/parametri.JSON
+++ /dev/null
@@ -1 +0,0 @@
-{"provider": "aws", "network":{"subname": "Danilo", "vpcname": "Molteni"}, "vm":{"os": "ubuntu"}}
\ No newline at end of file
diff --git a/input_file_example/parametri.txt b/input_file_example/parametri.txt
deleted file mode 100644
index 9837d5d..0000000
--- a/input_file_example/parametri.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"provider": "aws", "anagrafica":{"nome": "Danilo", "cognome": "Molteni"}, "vm":{"os": "ubuntu"}}
\ No newline at end of file
diff --git a/input_file_example/parametriaz.JSON b/input_file_example/parametriaz.JSON
deleted file mode 100644
index fba59e4..0000000
--- a/input_file_example/parametriaz.JSON
+++ /dev/null
@@ -1 +0,0 @@
-{"provider": "azurerm", "network":{"subname": "Danilo", "vpcname": "Molteni"}, "vm":{"source": "hashicorp/azurerm", "version": "~>2.0"}}
\ No newline at end of file
diff --git a/input_file_example/parametriaz.txt b/input_file_example/parametriaz.txt
deleted file mode 100644
index 0e243c1..0000000
--- a/input_file_example/parametriaz.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"provider": "azurerm", "anagrafica":{"nome": "Danilo", "cognome": "Molteni"}, "vm":{"source": "hashicorp/azurerm", "version": "~>2.0"}}
\ No newline at end of file
diff --git a/input_file_example/parametrig.JSON b/input_file_example/parametrig.JSON
deleted file mode 100644
index 0f7d559..0000000
--- a/input_file_example/parametrig.JSON
+++ /dev/null
@@ -1 +0,0 @@
-{"provider": "gcp", "network":{"subname": "Danilo", "vpcname": "Molteni"},  "vm":{"name": "flask-vm-$8"}}
\ No newline at end of file
diff --git a/input_file_example/parametrig.txt b/input_file_example/parametrig.txt
deleted file mode 100644
index 7075dbd..0000000
--- a/input_file_example/parametrig.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"provider": "gcp", "anagrafica":{"nome": "Danilo", "cognome": "Molteni"},  "vm":{"name": "flask-vm-$8"}}
\ No newline at end of file
diff --git a/input_file_example/properties.JSON b/input_file_example/properties.JSON
deleted file mode 100644
index 7a35287..0000000
--- a/input_file_example/properties.JSON
+++ /dev/null
@@ -1,30 +0,0 @@
-{
-    "provider": "aws",
-    "network": [
-        {
-            "id": 1,
-            "subname": "Danilo",
-            "vpcname": "Molteni"
-        }
-    ],
-    "vm": [
-        {
-            "id": 1,
-            "ram": 128,
-            "cpu": 32
-        },
-        {
-            "id": 2,
-            "ram": 256,
-            "cpu": 64
-        }
-    ],
-    "db": [
-        {
-            "id": 1,
-            "engine": "postgres",
-            "username": "danilo",
-            "storage": 1
-        }
-    ]
-}
\ No newline at end of file
diff --git a/input_file_example/properties.yaml b/input_file_example/properties.yaml
deleted file mode 100644
index 0e87c84..0000000
--- a/input_file_example/properties.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
----
-provider: aws
-network:
-  - id: 1
-    subname: Danilo
-    vpcname: Molteni
-vm:
-  - id: 1
-    ram : 128
-    cpu : 32
-  - id: 2
-    ram : 256
-    cpu : 64
-db:
-  - id: 1
-    engine: postgres
-    username: danilo
-    storage: 1
\ No newline at end of file
diff --git a/input_file_example/propertiesaz.yaml b/input_file_example/propertiesaz.yaml
deleted file mode 100644
index 04c6f60..0000000
--- a/input_file_example/propertiesaz.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
----
-provider: azurerm
-network:
-  - id: 1
-    name: Danilo
-    subnet_names: [Molteni]
-vm:
-  - id: 1
-    source: hashicorp/azurerm
-    version: "~>2.0"
-db:
-  - id: 1
-    name: Danilo
-    group_name: Molteni
-    server_name: DaniloMolteni
-    email: molteni@hpe.com
diff --git a/input_file_example/propertiesg.yaml b/input_file_example/propertiesg.yaml
deleted file mode 100644
index 60a7582..0000000
--- a/input_file_example/propertiesg.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
----
-provider: gcp
-network:
-  - id: 1
-    subname: Danilo
-    vpcname: Molteni
-vm:
-  - id: 1
-    name: flask-vm-$8
-db:
-  - id: 1
-    name: Danilo
-    instance_name: Molteni
diff --git a/input_file_example/toscainput.yaml b/input_file_example/toscainput.yaml
deleted file mode 100644
index 3e4615f..0000000
--- a/input_file_example/toscainput.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-description: Template for deploying a single server with predefined properties.
-
-provider: aws
-network:
-  subname: Danilo
-  vpcname: Molteni
-vm:
-  os: ubuntu
\ No newline at end of file
diff --git a/input_file_example/wordpress/parameters.json b/input_file_example/wordpress/parameters.json
index 93f3c90..45a7d27 100644
--- a/input_file_example/wordpress/parameters.json
+++ b/input_file_example/wordpress/parameters.json
@@ -1,91 +1,77 @@
 {
-    "steps": [
-        {
-            "programming_language": "terraform",
-            "output_path": "Output-code/",
-            "data": {
-                "provider": "aws",
-                "network": [
-                    {
-                        "id": 1,
-                        "subnetname": "piacere_subnet",
-                        "subnet_cidrblock": "10.0.1.0/24",
-                        "vpcname": "piacere_vpc",
-                        "vpc_cidr": "10.0.0.0/16"
-                    }
-                ],
-                "vm": [
-                    {
-                        "id": 1,
-                        "os": "ubuntu",
-                        "ram": 1,
-                        "cpu": 1,
-                        "name": "firstvm"
-                    },
-                    {
-                        "id": 2,
-                        "os": "ubuntu",
-                        "ram": 1,
-                        "cpu": 1,
-                        "name": "secondvm"
-                    }
-                ],
-                "db": [
-                    {
-                        "id": 1,
-                        "name": "Danilo",
-                        "group_name": "Molteni",
-                        "server_name": "DaniloMolteni",
-                        "email": "molteni@hpe.com"
-                    }
-                ]
-            }
-        },
-        {
-            "programming_language": "ansible",
-            "type": "database",
-            "output_path": "Output-code/",
-            "info": {
-                "name": "mysql",
-                "template_path": "Databases-templates/"
-            },
-            "data": {
-                "vars": {
-                    "DB_USER": "app1user",
-                    "DB_PASSWORD": "app1user",
-                    "DB_NAME": "app1"
-                },
-                "play": {
-                    "OS": "debian",
-                    "HOST": 1,
-                    "ADMIN_USER": "A",
-                    "ADMIN_PASSWORD": "A"
-                }
-            }
-        },
-        {
-            "programming_language": "ansible",
-            "type": "docker-service",
-            "output_path": "Output-code/",
-            "info": {
-                "name": "wordpress",
-                "template_path": "Docker-services-templates/"
-            },
-            "data": {
-                "vars": {
-                    "WORDPRESS_DB_HOST": "10.10.10.10",
-                    "WORDPRESS_DB_USER": "app1user",
-                    "WORDPRESS_DB_PASSWORD": "app1user",
-                    "WORDPRESS_DB_NAME": "app1",
-                    "WORDPRESS_TABLE_PREFIX": "wp"
-                },
-                "play": {
-                    "OS": "debian",
-                    "HOST": 2,
-                    "ADMIN_USER": "B",
-                    "ADMIN_PASSWORD": "B"
-                }
-            }
+  "output_path": "output_files_generated/wordpress_azure/",
+  "steps": [
+    {
+      "programming_language": "terraform",
+      "data": {
+        "provider": "azure",
+        "resource_group": [
+          {
+            "name": "wordpress-rg",
+            "location": "eastus"
+          }
+        ],
+        "vms": [
+          {
+            "resource_group_name": "wordpress-example",
+            "name": "wordpress-vm",
+            "size": "Standard_B1s",
+            "admin_username": "adminuser",
+            "admin_password": "P@$$w0rd1234!",
+            "ssh_user": "adminuser",
+            "ssh_key_file": "/ssh_keys/wordpress_rsa.pub",
+            "image_offer": "UbuntuServer",
+            "image_sku": "18.04-LTS",
+            "network_name": "wordpress_net"
+          },
+          {
+            "resource_group_name": "wordpress-example",
+            "name": "myql-vm",
+            "size": "Standard_B1s",
+            "admin_username": "adminuser",
+            "admin_password": "P@$$w0rd1234!",
+            "ssh_user": "adminuser",
+            "ssh_key_file": "/ssh_keys/wordpress_rsa.pub",
+            "image_offer": "UbuntuServer",
+            "image_sku": "18.04-LTS",
+            "network_name": "mysql_net"
+          }
+        ],
+        "net": [
+          {
+            "resource_group_name": "wordpress-example",
+            "name": "wordpress_net"
+          },
+          {
+            "resource_group_name": "mysql-example",
+            "name": "mysql_net"
+          }
+        ]
+      }
+    },
+    {
+      "programming_language": "ansible",
+      "data": {
+        "operating_system": "ubuntu",
+        "mysql": {
+          "db_user": "app1user",
+          "db_password": "app1user",
+          "db_name": "app1"
         }
-    ]
+      }
+    },
+    {
+      "programming_language": "ansible",
+      "data": {
+        "operating_system": "ubuntu",
+        "wordpress": {
+          "wordpress_db_host": "10.10.10.10",
+          "wordpress_db_user": "app1user",
+          "wordpress_db_password": "app1user",
+          "wordpress_db_name": "app1",
+          "wordpress_table_prefix": "wp"
+        }
+      }
+    }
+  ]
 }
\ No newline at end of file
diff --git a/main.py b/main.py
index 960b240..098ca34 100644
--- a/main.py
+++ b/main.py
@@ -1,9 +1,6 @@
-import json
 import logging
 from fastapi import FastAPI
-
 import api.InfrastructureTemplateController
-from api import InfrastructureTemplateController
 
 fast_api = FastAPI()
 
@@ -11,6 +8,4 @@ fast_api.include_router(api.InfrastructureTemplateController.api_router)
 logging.getLogger().setLevel(logging.INFO)
 
 if __name__ == '__main__':
-    parameters_file = open("input_file_example/nginx/parameter.json")
-    parameters_file = json.load(parameters_file)
-    InfrastructureTemplateController.choose_plugin(parameters_file)
+    logging.info("Starting ICG application")
diff --git a/output_file_example/nginx_openstack/terraform/main.tf b/output_file_example/nginx_openstack/terraform/main.tf
index a91ec88..341a4e4 100644
--- a/output_file_example/nginx_openstack/terraform/main.tf
+++ b/output_file_example/nginx_openstack/terraform/main.tf
@@ -10,76 +10,48 @@ required_version = ">= 0.14.0"
 
 # Configure the OpenStack Provider
 provider "openstack" {
-  user_name   = "admin"
-  tenant_name = "test"
-  password    = "wRpuXgVqBzQqGwx8Bu0sylEeb8FgjSYG"
-  auth_url    = "https://127.0.0.1:5000/v3"
+  user_name   = "{{ user }}"           #admin
+  tenant_name = "{{ tenant }}"         #test
+  password    = "{{ password }}"       #test
+  auth_url    = "{{ url }}"            #https://127.0.0.1:5000/v3
   insecure    = true
 }
-# Create virtual machine
-resource "openstack_compute_instance_v2" "nginx-host" {
-  name        = "nginx-host"
-  image_name  = "ubuntu-20.04.3"
-  flavor_name = "small"
-  key_pair    = openstack_compute_keypair_v2.nginx-host_ssh_key.name
-  network {
-    port = openstack_networking_port_v2.ostack2.id
-  }
-}
 
-# Create ssh keys
-resource "openstack_compute_keypair_v2" "nginx-host_ssh_key" {
-  name       = "ubuntu"
-  public_key = "/home/user1/.ssh/openstack.key"
+resource "openstack_compute_keypair_v2" "user_key" {
+  name       = "user1"
+  public_key = "{{ ssh_key }}"   #ssh-rsa xxxx
 }
 
-# Create floating ip
-resource "openstack_networking_floatingip_v2" "nginx-host_floating_ip" {
-  pool = "external"
-  # fixed_ip = "16.0.0.1"
-}
-
-# Attach floating ip to instance
-resource "openstack_compute_floatingip_associate_v2" "nginx-host_floating_ip_association" {
-  floating_ip = openstack_networking_floatingip_v2.nginx-host_floating_ip.address
-  instance_id = openstack_compute_instance_v2.nginx-host.id
+# Router creation. UUID external gateway
+resource "openstack_networking_router_v2" "generic" {
+  name                = "router-generic"
+  external_network_id = "${openstack_networking_network_v2.external.id}"    #External network id
 }
 
-## Network
-
-# Create Network
-resource "openstack_networking_network_v2" "ostack2" {
+# Network creation
+resource "openstack_networking_network_v2" "generic" {
   name = "ostack2"
 }
 
-# Create Subnet
-resource "openstack_networking_subnet_v2" "ostack2_subnet" {
-  name            = "ostack2_subnet"
-  network_id      = openstack_networking_network_v2.ostack2.id
+#### HTTP SUBNET ####
+
+# Subnet http configuration
+resource "openstack_networking_subnet_v2" "nginx" {
+  name            = "subnet-nginx"
+  network_id      = openstack_networking_network_v2.generic.id
   cidr            = "16.0.0.0/24"
   dns_nameservers = ["8.8.8.8", "8.8.8.4"]
 }
 
-# Attach networking port
-resource "openstack_networking_port_v2" "ostack2" {
-  name           = "ostack2"
-  network_id     = openstack_networking_network_v2.ostack2.id
-  admin_state_up = true
-  security_group_ids = [
-    
-    openstack_compute_secgroup_v2.rule_1_secgroup.id,
-    
-    openstack_compute_secgroup_v2.rule_2_secgroup.id,
-    
-  ]
-  fixed_ip {
-    subnet_id = openstack_networking_subnet_v2.ostack2_subnet.id
-  }
+# Router interface configuration
+resource "openstack_networking_router_interface_v2" "nginx" {
+  router_id = openstack_networking_router_v2.generic.id
+  subnet_id = openstack_networking_subnet_v2.nginx.id
 }
 
-resource "openstack_compute_secgroup_v2" "rule_1_secgroup" {
-  name        = "rule_1"
-  description  = "Security group rule for port 80-80"
+resource "openstack_compute_secgroup_v2" "http" {
+  name        = "http"
+  description = "Open input http port"
   rule {
     from_port   = 80
     to_port     = 80
@@ -88,9 +60,9 @@ resource "openstack_compute_secgroup_v2" "rule_1_secgroup" {
   }
 }
 
-resource "openstack_compute_secgroup_v2" "rule_2_secgroup" {
-  name        = "rule_2"
-  description  = "Security group rule for port 22-22"
+resource "openstack_compute_secgroup_v2" "ssh" {
+  name        = "ssh"
+  description = "Open input ssh port"
   rule {
     from_port   = 22
     to_port     = 22
@@ -99,3 +71,42 @@ resource "openstack_compute_secgroup_v2" "rule_2_secgroup" {
   }
 }
 
+#
+# Create instance
+#
+resource "openstack_compute_instance_v2" "nginx" {
+  name        = "nginx-host"
+  image_name  = "cirros"
+  flavor_name = "m1.tiny"
+  key_pair    = openstack_compute_keypair_v2.user_key.name
+  network {
+    port = openstack_networking_port_v2.nginx.id
+  }
+}
+
+# Create network port
+resource "openstack_networking_port_v2" "nginx" {
+  name           = "nginx"
+  network_id     = openstack_networking_network_v2.generic.id
+  admin_state_up = true
+  security_group_ids = [
+    "${openstack_compute_flavor_v2.default.id}"        #default flavour id
+  ]
+  fixed_ip {
+    subnet_id = openstack_networking_subnet_v2.nginx.id
+  }
+}
+
+# Create floating ip
+resource "openstack_networking_floatingip_v2" "nginx" {
+#  pool = "ostack2"
+#  port_id = openstack_networking_port_v2.nginx.id
+  pool = "external"
+#  fixed_ip = "16.0.0.1"
+}
+
+# Attach floating ip to instance
+resource "openstack_compute_floatingip_associate_v2" "nginx" {
+  floating_ip = openstack_networking_floatingip_v2.nginx.address
+  instance_id = openstack_compute_instance_v2.nginx.id
+}
diff --git a/output_file_example/wordpress_azure/terraform/main.tf b/output_file_example/wordpress_azure/terraform/main.tf
index da9a048..004ee38 100644
--- a/output_file_example/wordpress_azure/terraform/main.tf
+++ b/output_file_example/wordpress_azure/terraform/main.tf
@@ -13,154 +13,37 @@ provider "azurerm" {
   features {}
 }
 
-resource "azurerm_resource_group" "rg" {
-  name     = "TerraformTesting"
-  location = "eastus" ## REQUIRED
-}
-
 ## VIRTUAL NETWORK
-resource "azurerm_virtual_network" "vnet" {
-  name                = "vNet"
+resource "azurerm_virtual_network" "wordpress_net_vnetwork" {
+  name                = "wordpress_net"
   address_space       = ["10.0.0.0/16"]
-  location            = azurerm_resource_group.rg.location
-  resource_group_name = azurerm_resource_group.rg.name
+  location            = azurerm_resource_group.wordpress-example.location
+  resource_group_name = azurerm_resource_group.wordpress-example.name
 }
 
-resource "azurerm_subnet" "subnet" {
+## SUBNET
+resource "azurerm_subnet" "wordpress_net_subnet" {
   name                 = "internal"
-  resource_group_name  = azurerm_resource_group.rg.name
-  virtual_network_name = azurerm_virtual_network.vnet.name
+  resource_group_name  = azurerm_resource_group.wordpress-example.name
+  virtual_network_name = azurerm_virtual_network.wordpress_net_vnetwork.name
   address_prefixes       = ["10.0.2.0/24"]
 }
 
-## WORDPRESS PUBLIC IP
-resource "azurerm_public_ip" "wordpress_public_ip" {
-  name = "wordpress_public_ip"
-  location = azurerm_resource_group.rg.location
-  resource_group_name = azurerm_resource_group.rg.name
-  allocation_method = "Dynamic" ##REQUIRED??
-  sku = "Basic"
-}
-
-## WORDPRESS NETWORK INTERFACE
-resource "azurerm_network_interface" "wordpress_nic" {
-  name                = "wordpress_nic"
-  location            = azurerm_resource_group.rg.location
-  resource_group_name = azurerm_resource_group.rg.name
-
-  ip_configuration {
-    name                          = "ipconfig1"
-    subnet_id                     = azurerm_subnet.subnet.id
-    private_ip_address_allocation = "Dynamic"
-    public_ip_address_id = azurerm_public_ip.wordpress_public_ip.id
-  }
-}
-
-## WORDPRESS VM
-resource "azurerm_linux_virtual_machine" "wordpress" { ## REQUIRED
-  resource_group_name = azurerm_resource_group.rg.name
-  ## instance details
-  name                = "wordpress-machine"
-  location            = azurerm_resource_group.rg.location
-  size                = "Standard_B1s" ## REQUIRED
-  ## administrator account
-  admin_username      = "adminuser"
-  admin_password      = "P@$$w0rd1234!" ##For Bastion Connection
-  disable_password_authentication = false
-  #availability_set_id = azurerm_availability_set.DemoAset.id
-  network_interface_ids = [
-    azurerm_network_interface.wordpress_nic.id
-  ]
-
-  os_disk {
-    caching              = "None"
-    storage_account_type = "Standard_LRS" ## REQUIRED
-  }
-
-  admin_ssh_key {
-    username = "adminuser"
-    public_key = file("${path.module}/ssh_keys/wordpress_rsa.pub")
-  }
-
-  source_image_reference {
-    publisher = "Canonical"
-    offer     = "UbuntuServer"
-    sku       = "18.04-LTS"
-    version   = "latest"
-  }
-}
-
-## MYSQL SAAS
-resource "azurerm_mysql_server" "mysql" {
-  name                = "mysql-machine"
-  location            = azurerm_resource_group.rg.location
-  resource_group_name = azurerm_resource_group.rg.name
-
-  administrator_login          = "app1user"
-  administrator_login_password = "app1"
-
-  sku_name   = "B_Gen5_2"
-  storage_mb = 10
-  version    = "5.7"
-
-  auto_grow_enabled                 = true
-  backup_retention_days             = 7
-  geo_redundant_backup_enabled      = false
-  infrastructure_encryption_enabled = false
-  public_network_access_enabled     = true
-  ssl_enforcement_enabled           = true
-  ssl_minimal_tls_version_enforced  = "TLS1_2"
-}
 
-## EXECUTION MANAGER PUBLIC IP
-resource "azurerm_public_ip" "em_public_ip" {
-  name = "em_public_ip"
-  location = azurerm_resource_group.rg.location
-  resource_group_name = azurerm_resource_group.rg.name
-  allocation_method = "Dynamic" ##REQUIRED??
-  sku = "Basic"
+## VIRTUAL NETWORK
+resource "azurerm_virtual_network" "mysql_net_vnetwork" {
+  name                = "mysql_net"
+  address_space       = ["10.0.0.0/16"]
+  location            = azurerm_resource_group.mysql-example.location
+  resource_group_name = azurerm_resource_group.mysql-example.name
 }
 
-## EXECUTION MANAGER NETWORK INTERFACE
-resource "azurerm_network_interface" "em_nic" {
-  name                = "em_nic"
-  location            = azurerm_resource_group.rg.location
-  resource_group_name = azurerm_resource_group.rg.name
-
-  ip_configuration {
-    name                          = "ipconfig1"
-    subnet_id                     = azurerm_subnet.subnet.id
-    private_ip_address_allocation = "Dynamic"
-    public_ip_address_id = azurerm_public_ip.em_public_ip.id
-  }
+## SUBNET
+resource "azurerm_subnet" "mysql_net_subnet" {
+  name                 = "internal"
+  resource_group_name  = azurerm_resource_group.mysql-example.name
+  virtual_network_name = azurerm_virtual_network.mysql_net_vnetwork.name
+  address_prefixes       = ["10.0.2.0/24"]
 }
 
-## EXECUTION MANAGER
-resource "azurerm_linux_virtual_machine" "execution_manager" { ## REQUIRED
-  resource_group_name = azurerm_resource_group.rg.name
-  ## instance details
-  name                = "execution-manager-machine"
-  location            = azurerm_resource_group.rg.location
-  size                = "Standard_B1s" ## REQUIRED
-  ## administrator account
-  admin_username      = "adminuser"
-  admin_ssh_key {
-    username = "adminuser"
-    public_key = file("${path.module}/ssh_keys/wordpress_rsa.pub")
-  }
-  network_interface_ids = [
-    azurerm_network_interface.em_nic.id
-  ]
 
-  os_disk {
-    caching              = "None"
-    storage_account_type = "Standard_LRS"
-  }
-
-  source_image_reference {
-    publisher = "OpenLogic"
-    offer     = "CentOS"
-    sku       = "7.5"
-    version   = "latest"
-  }
-} 
\ No newline at end of file
diff --git a/output_files_generated/nginx_openstack/ansible/nginx.play b/output_files_generated/nginx_openstack/ansible/nginx.play
new file mode 100644
index 0000000..c8790e1
--- /dev/null
+++ b/output_files_generated/nginx_openstack/ansible/nginx.play
@@ -0,0 +1,45 @@
+---
+- hosts: 16.0.0.1
+  gather_facts: no
+  become: yes
+  vars:
+    ansible_ssh_private_key_file: "/home/user1/.ssh/openstack.key"
+    ansible_ssh_user: "ubuntu"
+  tasks:
+    - name: Update repositories
+      apt:
+        update_cache: yes
+
+    - name: Install nginx
+      package:
+        name: nginx
+
+    - name: Start nginx
+      service:
+        name: nginx
+        enabled: yes
+        state: started
+
+    - name: Set attributes
+      set_stats:
+        data:
+          site_config_dir: /etc/nginx/conf.d
+
+    - name: Install sample site
+      copy:
+        dest: ""
+        content: |
+          <!doctype html>
+          <html lang="en">
+          <head>
+            <title>Hello World!</title>
+          </head>
+          <body>
+            <h1>Sample web page</h1>
+            <p>With little content ;)</p>
+          </body>
+          </html>
+      with_items:
+        - /var/www/html/index.html
+        - /usr/share/nginx/html/index.html
+
diff --git a/output_files_generated/nginx_openstack/terraform/main.tf b/output_files_generated/nginx_openstack/terraform/main.tf
new file mode 100644
index 0000000..a91ec88
--- /dev/null
+++ b/output_files_generated/nginx_openstack/terraform/main.tf
@@ -0,0 +1,101 @@
+terraform {
+required_version = ">= 0.14.0"
+  required_providers {
+    openstack = {
+      source  = "terraform-provider-openstack/openstack"
+      version = "~> 1.35.0"
+    }
+  }
+}
+
+# Configure the OpenStack Provider
+provider "openstack" {
+  user_name   = "admin"
+  tenant_name = "test"
+  password    = "wRpuXgVqBzQqGwx8Bu0sylEeb8FgjSYG"
+  auth_url    = "https://127.0.0.1:5000/v3"
+  insecure    = true
+}
+# Create virtual machine
+resource "openstack_compute_instance_v2" "nginx-host" {
+  name        = "nginx-host"
+  image_name  = "ubuntu-20.04.3"
+  flavor_name = "small"
+  key_pair    = openstack_compute_keypair_v2.nginx-host_ssh_key.name
+  network {
+    port = openstack_networking_port_v2.ostack2.id
+  }
+}
+
+# Create ssh keys
+resource "openstack_compute_keypair_v2" "nginx-host_ssh_key" {
+  name       = "ubuntu"
+  public_key = "/home/user1/.ssh/openstack.key"
+}
+
+# Create floating ip
+resource "openstack_networking_floatingip_v2" "nginx-host_floating_ip" {
+  pool = "external"
+  # fixed_ip = "16.0.0.1"
+}
+
+# Attach floating ip to instance
+resource "openstack_compute_floatingip_associate_v2" "nginx-host_floating_ip_association" {
+  floating_ip = openstack_networking_floatingip_v2.nginx-host_floating_ip.address
+  instance_id = openstack_compute_instance_v2.nginx-host.id
+}
+
+## Network
+
+# Create Network
+resource "openstack_networking_network_v2" "ostack2" {
+  name = "ostack2"
+}
+
+# Create Subnet
+resource "openstack_networking_subnet_v2" "ostack2_subnet" {
+  name            = "ostack2_subnet"
+  network_id      = openstack_networking_network_v2.ostack2.id
+  cidr            = "16.0.0.0/24"
+  dns_nameservers = ["8.8.8.8", "8.8.8.4"]
+}
+
+# Attach networking port
+resource "openstack_networking_port_v2" "ostack2" {
+  name           = "ostack2"
+  network_id     = openstack_networking_network_v2.ostack2.id
+  admin_state_up = true
+  security_group_ids = [
+    
+    openstack_compute_secgroup_v2.rule_1_secgroup.id,
+    
+    openstack_compute_secgroup_v2.rule_2_secgroup.id,
+    
+  ]
+  fixed_ip {
+    subnet_id = openstack_networking_subnet_v2.ostack2_subnet.id
+  }
+}
+
+resource "openstack_compute_secgroup_v2" "rule_1_secgroup" {
+  name        = "rule_1"
+  description  = "Security group rule for port 80-80"
+  rule {
+    from_port   = 80
+    to_port     = 80
+    ip_protocol = "tcp"
+    cidr        = "0.0.0.0/0"
+  }
+}
+
+resource "openstack_compute_secgroup_v2" "rule_2_secgroup" {
+  name        = "rule_2"
+  description  = "Security group rule for port 22-22"
+  rule {
+    from_port   = 22
+    to_port     = 22
+    ip_protocol = "tcp"
+    cidr        = "0.0.0.0/0"
+  }
+}
+
diff --git a/output_files_generated/wordpress_azure/ansible/mysql.play b/output_files_generated/wordpress_azure/ansible/mysql.play
new file mode 100644
index 0000000..d273e15
--- /dev/null
+++ b/output_files_generated/wordpress_azure/ansible/mysql.play
@@ -0,0 +1,97 @@
+---
+- hosts: DB
+  become: yes
+
+  pre_tasks:
+  - name: Install MySQL
+    apt: name= update_cache=yes cache_valid_time=3600 state=present
+    with_items:
+    - mysql-server
+    - mysql-client
+    - python-setuptools
+    - python-mysqldb
+    - libmysqlclient-dev
+    - python3-pip
+
+  - name: Remove a symbolic link
+    ansible.builtin.file: 
+      path: /usr/bin/python
+      state: absent
+
+  - name: Create a symbolic link
+    ansible.builtin.file: 
+      src: /usr/bin/python3
+      dest: /usr/bin/python
+      state: link
+    register: result
+    retries: 3
+    delay: 5
+    until: result is not failed
+
+  - name: Create a symbolic link
+    ansible.builtin.file: 
+      src: /usr/bin/pip3
+      dest: /usr/bin/pip
+      state: link
+    register: result
+    retries: 3
+    delay: 5
+    until: result is not failed
+      
+  - name: Install Python packages
+    pip: "name= state=present"
+    with_items:
+      - PyMySQL
+
+  - name: edit firewall
+    service:
+      name: ufw
+      state: stopped
+      enabled: false
+
+  tasks:
+  - name: Start the MySQL service
+    service:
+      name: mysql
+      state: started
+      enabled: true
+
+  - name: Creation mysql file configuration
+    file:
+      path: "/root/.my.cnf"
+      state: touch
+
+  - name: Editing configuration file
+    replace:
+      path: /etc/mysql/mysql.conf.d/mysqld.cnf
+      regexp: '(.*bind-addres.*)'
+      replace: '#\1'
+
+  - name: Restart MySQL
+    service: name=mysql state=restarted
+
+  - name: Ensure MySQL started
+    service:
+      name: mysql
+      state: started
+
+  - name: update mysql password for application account
+    mysql_user:
+      login_unix_socket: /var/run/mysqld/mysqld.sock
+      name: "app1user"
+      host: "%"
+      password: "app1user"
+      state: present
+      login_user: root
+      login_password: test
+      check_implicit_admin: yes
+      priv: "*.*:ALL,GRANT"
+
+  - name: Add the application database
+    mysql_db: 
+      name: "app1"
+      state: present
+      login_unix_socket: /var/run/mysqld/mysqld.sock
+
+  - name: Restart MySQL
+    service: name=mysql state=restarted
diff --git a/output_files_generated/wordpress_azure/ansible/wordpress.play b/output_files_generated/wordpress_azure/ansible/wordpress.play
new file mode 100644
index 0000000..f8e98e0
--- /dev/null
+++ b/output_files_generated/wordpress_azure/ansible/wordpress.play
@@ -0,0 +1,69 @@
+---
+- hosts: APP1
+  become: yes
+
+  pre_tasks:
+    - name: "Install packages"
+      apt: "name= state=present"
+      with_items:
+        - python3
+        - python3-pip
+        - docker
+        - docker.io
+
+    - name: Remove a symbolic link
+      ansible.builtin.file: 
+        path: /usr/bin/python
+        state: absent
+
+    - name: Create a symbolic link
+      ansible.builtin.file: 
+        src: /usr/bin/python3
+        dest: /usr/bin/python
+        state: link
+      register: result
+      retries: 3
+      delay: 5
+      until: result is not failed
+
+    - name: Create a symbolic link
+      ansible.builtin.file: 
+        src: /usr/bin/pip3
+        dest: /usr/bin/pip
+        state: link
+      register: result
+      retries: 3
+      delay: 5
+      until: result is not failed
+    
+    - name: "Install Python packages"
+      pip: "name=  state=present"
+      with_items:
+        - docker
+
+    - name: edit firewall
+      service:
+        name: ufw
+        state: stopped
+        enabled: false
+        
+  tasks:
+    - name: Create a volume
+      community.docker.docker_volume:
+        name: mydata
+        
+    - name: Start a WP container
+      community.docker.docker_container:
+        name: wordpress
+        image: wordpress:5.8.0
+        state: started
+        env:
+          WORDPRESS_DB_HOST: "10.10.10.10"
+          WORDPRESS_DB_USER: "app1user"
+          WORDPRESS_DB_PASSWORD: "app1user"
+          WORDPRESS_DB_NAME: "app1"
+          WORDPRESS_TABLE_PREFIX: "wp"
+        ports:
+          - "8080:80"
+        volumes:
+          - mydata
diff --git a/output_files_generated/wordpress_azure/terraform/main.tf b/output_files_generated/wordpress_azure/terraform/main.tf
new file mode 100644
index 0000000..851c144
--- /dev/null
+++ b/output_files_generated/wordpress_azure/terraform/main.tf
@@ -0,0 +1,47 @@
+terraform {
+  required_providers {
+    azurerm = {
+      source  = "hashicorp/azurerm"
+      version = "~> 2.65"
+    }
+  }
+
+  required_version = ">= 0.14.9"
+}
+
+provider "azurerm" {
+  features {}
+}
+
+## VIRTUAL NETWORK
+resource "azurerm_virtual_network" "wordpress_net_vnetwork" {
+  name                = "wordpress_net"
+  address_space       = ["10.0.0.0/16"]
+  location            = azurerm_resource_group.wordpress-example.location
+  resource_group_name = azurerm_resource_group.wordpress-example.name
+}
+
+## SUBNET
+resource "azurerm_subnet" "wordpress_net_subnet" {
+  name                 = "internal"
+  resource_group_name  = azurerm_resource_group.wordpress-example.name
+  virtual_network_name = azurerm_virtual_network.wordpress_net_vnetwork.name
+  address_prefixes       = ["10.0.2.0/24"]
+}
+
+## VIRTUAL NETWORK
+resource "azurerm_virtual_network" "mysql_net_vnetwork" {
+  name                = "mysql_net"
+  address_space       = ["10.0.0.0/16"]
+  location            = azurerm_resource_group.mysql-example.location
+  resource_group_name = azurerm_resource_group.mysql-example.name
+}
+
+## SUBNET
+resource "azurerm_subnet" "mysql_net_subnet" {
+  name                 = "internal"
+  resource_group_name  = azurerm_resource_group.mysql-example.name
+  virtual_network_name = azurerm_virtual_network.mysql_net_vnetwork.name
+  address_prefixes       = ["10.0.2.0/24"]
+}
+
diff --git a/plugin/TemplateUtils.py b/plugin/TemplateUtils.py
index c90ff5d..1bda9f2 100644
--- a/plugin/TemplateUtils.py
+++ b/plugin/TemplateUtils.py
@@ -1,5 +1,7 @@
 import configparser
 import logging
+import os
+
 import jinja2
 from jinja2 import Template
 
@@ -35,6 +37,7 @@ def read_template(template_path):
 
 
 def write_template(template, output_path_file):
+    os.makedirs(os.path.dirname(output_path_file), exist_ok=True)
     file = open(output_path_file, "w+")
     file.write(template)
     logging.info("Writing file at: '%s'", output_path_file)
diff --git a/template-location.properties b/template-location.properties
index af672eb..a1b9ac4 100644
--- a/template-location.properties
+++ b/template-location.properties
@@ -4,7 +4,19 @@ vm = templates/terraform/open_stack/virtual_machine.tpl
 net = templates/terraform/open_stack/network.tpl
 sg = templates/terraform/open_stack/port_rule.tpl
 
+[terraform.azure]
+init = templates/terraform/azure/init.tpl
+vm = templates/terraform/azure/virtual_machine.tpl
+net = templates/terraform/azure/network.tpl
+rg = templates/terraform/azure/resource_group.tpl
+
 [ansible.ubuntu]
 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
+mysql = templates/ansible/ubuntu/mysql.tpl
+wordpress = templates/ansible/ubuntu/wordpress.tpl
+postgres = templates/ansible/ubuntu/postgres.tpl
+
+[ansible.centos]
+mysql = templates/ansible/centos/mysql.tpl
+postgres = templates/ansible/centos/postgres.tpl
+wordpress = templates/ansible/centos/wordpress.tpl
\ No newline at end of file
diff --git a/Output-code/mysql-play.yml b/templates/ansible/centos/mysql.tpl
similarity index 89%
rename from Output-code/mysql-play.yml
rename to templates/ansible/centos/mysql.tpl
index 8025582..fff1148 100644
--- a/Output-code/mysql-play.yml
+++ b/templates/ansible/centos/mysql.tpl
@@ -1,12 +1,10 @@
 ---
 - hosts: DB
   become: yes
-  vars_files:
-    - mysql-vars.yml
 
   pre_tasks:
   - name: Install MySQL
-    apt: name={{ item }} update_cache=yes cache_valid_time=3600 state=present
+    yum: name={{ item }} update_cache=yes cache_valid_time=3600 state=present
     with_items:
     - mysql-server
     - mysql-client
@@ -47,7 +45,7 @@
 
   - name: edit firewall
     service:
-      name: ufw
+      name: firewalld
       state: stopped
       enabled: false
 
@@ -79,7 +77,6 @@
 
   - name: update mysql password for application account
     mysql_user:
-      login_unix_socket: /var/run/mysqld/mysqld.sock
       name: "{{ db_user }}"
       host: "%"
       password: "{{ db_password }}"
@@ -93,7 +90,6 @@
     mysql_db: 
       name: "{{ db_name }}"
       state: present
-      login_unix_socket: /var/run/mysqld/mysqld.sock
 
   - name: Restart MySQL
     service: name=mysql state=restarted
diff --git a/Output-code/postgres-play.yml b/templates/ansible/centos/postgres.tpl
similarity index 89%
rename from Output-code/postgres-play.yml
rename to templates/ansible/centos/postgres.tpl
index d924991..b4fa1e8 100644
--- a/Output-code/postgres-play.yml
+++ b/templates/ansible/centos/postgres.tpl
@@ -2,14 +2,14 @@
 - hosts: DB
   become: yes
 
-  vars_files:
-    - postgres-vars.yml
-
   pre_tasks:
     - name: "Install packages"
-      apt: "name={{ item }} state=present"
+      yum: "name={{ item }} state=present"
       with_items:
-        - postgresql-10
+        - postgresql10
+        - postgresql10-server
+        - postgresql10-contrib
+        - postgresql10-libs
         - python3
         - python3-pip
 
diff --git a/Output-code/wordpress-play.yml b/templates/ansible/centos/wordpress.tpl
similarity index 77%
rename from Output-code/wordpress-play.yml
rename to templates/ansible/centos/wordpress.tpl
index 695d163..fecc1d5 100644
--- a/Output-code/wordpress-play.yml
+++ b/templates/ansible/centos/wordpress.tpl
@@ -2,17 +2,11 @@
 - hosts: APP1
   become: yes
 
-  vars_files:
-    - wordpress-vars.yml
-
   pre_tasks:
     - name: "Install packages"
       apt: "name={{ item }} state=present"
       with_items:
-        - python3
-        - python3-pip
         - docker
-        - docker.io
 
     - name: Remove a symbolic link
       ansible.builtin.file: 
@@ -61,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:
diff --git a/templates/ansible/ubuntu/mysql.tpl b/templates/ansible/ubuntu/mysql.tpl
index afb4242..38a8e83 100644
--- a/templates/ansible/ubuntu/mysql.tpl
+++ b/templates/ansible/ubuntu/mysql.tpl
@@ -4,9 +4,14 @@
 
   pre_tasks:
   - name: Install MySQL
-    ###OS###: name={{ item }} update_cache=yes cache_valid_time=3600 state=present
+    apt: name={{ item }} update_cache=yes cache_valid_time=3600 state=present
     with_items:
-###OS_PACKETS###
+    - mysql-server
+    - mysql-client
+    - python-setuptools
+    - python-mysqldb
+    - libmysqlclient-dev
+    - python3-pip
 
   - name: Remove a symbolic link
     ansible.builtin.file: 
diff --git a/templates/ansible/ubuntu/postgres.tpl b/templates/ansible/ubuntu/postgres.tpl
index 129ee69..b8de484 100644
--- a/templates/ansible/ubuntu/postgres.tpl
+++ b/templates/ansible/ubuntu/postgres.tpl
@@ -4,9 +4,9 @@
 
   pre_tasks:
     - name: "Install packages"
-      ###OS###: "name={{ item }} state=present"
+      apt: "name={{ item }} state=present"
       with_items:
-###OS_PACKETS###
+        - postgresql-10
         - python3
         - python3-pip
 
diff --git a/templates/ansible/ubuntu/wordpress.tpl b/templates/ansible/ubuntu/wordpress.tpl
index 42d4399..774efd7 100644
--- a/templates/ansible/ubuntu/wordpress.tpl
+++ b/templates/ansible/ubuntu/wordpress.tpl
@@ -4,9 +4,12 @@
 
   pre_tasks:
     - name: "Install packages"
-      ###OS###: "name={{ item }} state=present"
+      apt: "name={{ item }} state=present"
       with_items:
-###OS_PACKETS###
+        - python3
+        - python3-pip
+        - docker
+        - docker.io
 
     - name: Remove a symbolic link
       ansible.builtin.file: 
diff --git a/templates/terraform/azure/init.tpl b/templates/terraform/azure/init.tpl
new file mode 100644
index 0000000..33d115d
--- /dev/null
+++ b/templates/terraform/azure/init.tpl
@@ -0,0 +1,15 @@
+terraform {
+  required_providers {
+    azurerm = {
+      source  = "hashicorp/azurerm"
+      version = "~> 2.65"
+    }
+  }
+
+  required_version = ">= 0.14.9"
+}
+
+provider "azurerm" {
+  features {}
+}
+
diff --git a/templates/terraform/azure/network.tpl b/templates/terraform/azure/network.tpl
index 51acd1a..b2ee446 100644
--- a/templates/terraform/azure/network.tpl
+++ b/templates/terraform/azure/network.tpl
@@ -1,23 +1,15 @@
-resource "azurerm_resource_group" "example" {
-  name     = "{{ name }}"
-  location = "West Europe"
+## VIRTUAL NETWORK
+resource "azurerm_virtual_network" "{{ name ~ "_vnetwork" }}" {
+  name                = "{{ name }}"
+  address_space       = ["10.0.0.0/16"]
+  location            = azurerm_resource_group.{{ resource_group_name }}.location
+  resource_group_name = azurerm_resource_group.{{ resource_group_name }}.name
 }
 
-module "network" {
-  source              = "Azure/network/azurerm"
-  resource_group_name = azurerm_resource_group.example.name
-  address_spaces      = ["10.0.0.0/16", "10.2.0.0/16"]
-  subnet_prefixes     = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
-  subnet_names        = {{ subnet_names }}
-
-  subnet_service_endpoints = {
-    {{ endpoints }}
-  }
-
-  tags = {
-    environment = "dev"
-    costcenter  = "it"
-  }
-
-  depends_on = [azurerm_resource_group.example]
+## SUBNET
+resource "azurerm_subnet" "{{ name ~ "_subnet" }}" {
+  name                 = "internal"
+  resource_group_name  = azurerm_resource_group.{{ resource_group_name }}.name
+  virtual_network_name = azurerm_virtual_network.{{ name ~ "_vnetwork" }}.name
+  address_prefixes       = ["10.0.2.0/24"]
 }
\ No newline at end of file
diff --git a/templates/terraform/azure/resource_group.tpl b/templates/terraform/azure/resource_group.tpl
new file mode 100644
index 0000000..1647b0c
--- /dev/null
+++ b/templates/terraform/azure/resource_group.tpl
@@ -0,0 +1,6 @@
+## RESOURCE GROUP
+
+resource "azurerm_resource_group" "{{ name }}" {
+  name     = "{{ name }}"
+  location = "{{ location }}" ## REQUIRED
+}
\ No newline at end of file
diff --git a/templates/terraform/azure/virtual_machine.tpl b/templates/terraform/azure/virtual_machine.tpl
new file mode 100644
index 0000000..eac12cd
--- /dev/null
+++ b/templates/terraform/azure/virtual_machine.tpl
@@ -0,0 +1,55 @@
+## CREATE VM
+resource "azurerm_linux_virtual_machine" "{{ name }}" { ## REQUIRED
+  resource_group_name = azurerm_resource_group.rg.{{ resource_group_name }}
+  ## instance details
+  name                = "{{ name }}"
+  location            = azurerm_resource_group.{{ resource_group_name }}.location
+  size                = "{{ size }}" ## REQUIRED
+  ## administrator account
+  admin_username      = "{{ admin_username }}"
+  admin_password      = "{{ admin_password }}" ##For Bastion Connection
+  disable_password_authentication = false
+  network_interface_ids = [
+    azurerm_network_interface.{{ network_name }}.id
+  ]
+
+  os_disk {
+    caching              = "None"
+    storage_account_type = "Standard_LRS" ## REQUIRED
+  }
+
+  admin_ssh_key {
+    username = "{{ ssh_user }}"
+    public_key = file("${path.module}{{ ssh_key_file }}")
+  }
+
+  source_image_reference {
+    publisher = "Canonical"
+    offer     = "{{ image_offer }}"
+    sku       = "{{ image_sku }}"
+    version   = "latest"
+  }
+}
+
+## VM NETWORK INTERFACE
+resource "azurerm_network_interface" "{{ name ~ "_vnet_interface" }}" {
+  name                = "{{ name ~ "_nic" }}"
+  location            = azurerm_resource_group.{{ resource_group_name }}.location
+  resource_group_name = azurerm_resource_group.{{ resource_group_name }}.name
+
+  ip_configuration {
+    name                          = "ipconfig1"
+    subnet_id                     = azurerm_subnet.{{ network_name ~ "_subnet" }}.id
+    private_ip_address_allocation = "Dynamic"
+    public_ip_address_id = azurerm_public_ip.wordpress_public_ip.id
+  }
+}
+
+## PUBLIC IP
+resource "azurerm_public_ip" "{{ name ~ "_public_ip" }}" {
+  name = "{{ name ~ "_public_ip" }}"
+  location = azurerm_resource_group.{{ resource_group_name }}.location
+  resource_group_name = azurerm_resource_group.{{ resource_group_name }}.name
+  allocation_method = "Dynamic" ##REQUIRED??
+  sku = "Basic"
+}
\ No newline at end of file
diff --git a/templates/terraform/azure/vm.tpl b/templates/terraform/azure/vm.tpl
deleted file mode 100644
index 5380c5a..0000000
--- a/templates/terraform/azure/vm.tpl
+++ /dev/null
@@ -1,15 +0,0 @@
-terraform {
-  required_providers {
-    azurerm = {
-      source = "{{ source }}"
-      version = "{{ version }}"
-    }
-  }
-}
-provider "azurerm" {
-  features {}
-}
-resource "azurerm_resource_group" "rg" {
-  name = "{{ name }}"
-  location = "{{ location }}"
-}
\ No newline at end of file
-- 
GitLab