From fbd3499cdb3208572370a4dd0e81f4275c5a54df Mon Sep 17 00:00:00 2001
From: Debora Benedetto <debora.benedetto@hpe.com>
Date: Fri, 5 Aug 2022 17:46:42 +0200
Subject: [PATCH] removed tpl file in monitoring file generation

---
 icgparser/doml/v1/nginx-openstack_v1.domlx    |  4 ++--
 input_file_generated/ir.json                  | 14 ++++++------
 .../nginx_openstack/nginx/config.yaml         |  2 +-
 .../nginx_openstack/nginx/ssh_key.j2          |  2 +-
 .../piacere_monitoring/config.yaml            |  2 +-
 .../piacere_monitoring/ssh_key.j2             |  2 +-
 .../nginx_openstack/terraform/config.yaml     |  4 ++--
 .../nginx_openstack/terraform/main.tf         |  6 ++---
 .../nginx_openstack/terraform/output.tf       |  8 +++----
 template-location.properties                  |  2 +-
 templates/ansible/ubuntu/monitoring/main.tpl  | 22 -------------------
 .../ansible/ubuntu/piacere_main.tpl           |  0
 12 files changed, 23 insertions(+), 45 deletions(-)
 delete mode 100644 templates/ansible/ubuntu/monitoring/main.tpl
 rename output_files_generated/nginx_openstack/piacere_monitoring/main.tpl => templates/ansible/ubuntu/piacere_main.tpl (100%)

diff --git a/icgparser/doml/v1/nginx-openstack_v1.domlx b/icgparser/doml/v1/nginx-openstack_v1.domlx
index d33ba1d..4195ffc 100644
--- a/icgparser/doml/v1/nginx-openstack_v1.domlx
+++ b/icgparser/doml/v1/nginx-openstack_v1.domlx
@@ -12,7 +12,7 @@
       </machineDefinition>
     </nodes>
     <networks name="net1" protocol="tcp/ip" addressRange="16.0.0.0/24" connectedIfaces="//@infrastructure/@nodes.0/@machineDefinition/@ifaces.0"/>
-    <credentials xsi:type="infra:KeyPair" name="ssh_key" user="user1"/>
+    <credentials xsi:type="infra:KeyPair" name="user1" user="user1"/>
     <groups xsi:type="infra:SecurityGroup" name="sg" groupedNodes="//@infrastructure/@nodes.0/@machineDefinition" ifaces="//@infrastructure/@nodes.0/@machineDefinition/@ifaces.0">
       <rules name="icmp" protocol="icmp" fromPort="-1" toPort="-1">
         <cidr>0.0.0.0/0</cidr>
@@ -32,7 +32,7 @@
     <providers name="openstack">
       <vms name="concrete_vm" maps="//@infrastructure/@nodes.0/@machineDefinition">
         <annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
-        <annotations xsi:type="commons:SProperty" key="vm_flavor" value="ubuntu"/>
+        <annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
       </vms>
       <networks name="concrete_net" maps="//@infrastructure/@networks.0">
         <annotations xsi:type="commons:SProperty" key="name" value="ostack2"/>
diff --git a/input_file_generated/ir.json b/input_file_generated/ir.json
index 4f3fb5a..91bfefb 100644
--- a/input_file_generated/ir.json
+++ b/input_file_generated/ir.json
@@ -50,7 +50,7 @@
         ],
         "credentials": [
           {
-            "infra_element_name": "ssh_key",
+            "infra_element_name": "user1",
             "user": "user1"
           }
         ],
@@ -71,7 +71,7 @@
         "provider": "openstack",
         "vms": [
           {
-            "credentials": "ssh_key",
+            "credentials": "user1",
             "group": "sg",
             "i1": {
               "associated": "sg",
@@ -82,7 +82,7 @@
             "infra_element_name": "vm1",
             "name": "concrete_vm",
             "os": "Ubuntu-Focal-20.04-Daily-2022-04-19",
-            "vm_flavor": "ubuntu",
+            "vm_flavor": "small",
             "vm_name": "nginx-host"
           }
         ]
@@ -94,7 +94,7 @@
         "piacere_monitoring": {
           "name": "piacere_monitoring",
           "node": {
-            "credentials": "ssh_key",
+            "credentials": "user1",
             "group": "sg",
             "i1": {
               "associated": "sg",
@@ -105,7 +105,7 @@
             "infra_element_name": "vm1",
             "name": "concrete_vm",
             "os": "Ubuntu-Focal-20.04-Daily-2022-04-19",
-            "vm_flavor": "ubuntu",
+            "vm_flavor": "small",
             "vm_name": "nginx-host"
           }
         }
@@ -118,7 +118,7 @@
         "nginx": {
           "name": "nginx",
           "node": {
-            "credentials": "ssh_key",
+            "credentials": "user1",
             "group": "sg",
             "i1": {
               "associated": "sg",
@@ -129,7 +129,7 @@
             "infra_element_name": "vm1",
             "name": "concrete_vm",
             "os": "Ubuntu-Focal-20.04-Daily-2022-04-19",
-            "vm_flavor": "ubuntu",
+            "vm_flavor": "small",
             "vm_name": "nginx-host"
           },
           "source_code": "/usr/share/nginx/html/index.html"
diff --git a/output_files_generated/nginx_openstack/nginx/config.yaml b/output_files_generated/nginx_openstack/nginx/config.yaml
index dff8ba5..8b7284e 100644
--- a/output_files_generated/nginx_openstack/nginx/config.yaml
+++ b/output_files_generated/nginx_openstack/nginx/config.yaml
@@ -2,7 +2,7 @@
 ---
 input:
   - instance_ip_vm1
-  - instance_server_private_key_ssh_key
+  - instance_server_private_key_user1
 output: []
 engine: ansible
 ...
diff --git a/output_files_generated/nginx_openstack/nginx/ssh_key.j2 b/output_files_generated/nginx_openstack/nginx/ssh_key.j2
index 4d512f8..1431f67 100644
--- a/output_files_generated/nginx_openstack/nginx/ssh_key.j2
+++ b/output_files_generated/nginx_openstack/nginx/ssh_key.j2
@@ -1 +1 @@
-{{ instance_server_private_key_ssh_key }}
+{{ instance_server_private_key_user1 }}
diff --git a/output_files_generated/nginx_openstack/piacere_monitoring/config.yaml b/output_files_generated/nginx_openstack/piacere_monitoring/config.yaml
index dff8ba5..8b7284e 100644
--- a/output_files_generated/nginx_openstack/piacere_monitoring/config.yaml
+++ b/output_files_generated/nginx_openstack/piacere_monitoring/config.yaml
@@ -2,7 +2,7 @@
 ---
 input:
   - instance_ip_vm1
-  - instance_server_private_key_ssh_key
+  - instance_server_private_key_user1
 output: []
 engine: ansible
 ...
diff --git a/output_files_generated/nginx_openstack/piacere_monitoring/ssh_key.j2 b/output_files_generated/nginx_openstack/piacere_monitoring/ssh_key.j2
index 4d512f8..1431f67 100644
--- a/output_files_generated/nginx_openstack/piacere_monitoring/ssh_key.j2
+++ b/output_files_generated/nginx_openstack/piacere_monitoring/ssh_key.j2
@@ -1 +1 @@
-{{ instance_server_private_key_ssh_key }}
+{{ instance_server_private_key_user1 }}
diff --git a/output_files_generated/nginx_openstack/terraform/config.yaml b/output_files_generated/nginx_openstack/terraform/config.yaml
index 21942c2..783f272 100644
--- a/output_files_generated/nginx_openstack/terraform/config.yaml
+++ b/output_files_generated/nginx_openstack/terraform/config.yaml
@@ -9,8 +9,8 @@ input:
   - OS_PROJECT_NAME
 output:
 
-  - instance_server_public_key_ssh_key
-  - instance_server_private_key_ssh_key
+  - instance_server_public_key_user1
+  - instance_server_private_key_user1
   - instance_ip_vm1
 
 ...
diff --git a/output_files_generated/nginx_openstack/terraform/main.tf b/output_files_generated/nginx_openstack/terraform/main.tf
index 30cac93..40789ea 100644
--- a/output_files_generated/nginx_openstack/terraform/main.tf
+++ b/output_files_generated/nginx_openstack/terraform/main.tf
@@ -25,8 +25,8 @@ data "openstack_networking_network_v2" "external" {
 resource "openstack_compute_instance_v2" "vm1" {
   name        = "nginx-host"
   image_name  = "Ubuntu-Focal-20.04-Daily-2022-04-19"
-  flavor_name = "ubuntu"
-  key_pair    = openstack_compute_keypair_v2.ssh_key.name
+  flavor_name = "small"
+  key_pair    = openstack_compute_keypair_v2.user1.name
   network {
     port = openstack_networking_port_v2.net1.id
   }
@@ -141,7 +141,7 @@ resource "openstack_compute_secgroup_v2" "ssh" {
 
 
 # Create ssh keys
-resource "openstack_compute_keypair_v2" "ssh_key" {
+resource "openstack_compute_keypair_v2" "user1" {
   name       = "user1"
   # public_key = "user1"
 }
diff --git a/output_files_generated/nginx_openstack/terraform/output.tf b/output_files_generated/nginx_openstack/terraform/output.tf
index 5c4fe27..f0cc70b 100644
--- a/output_files_generated/nginx_openstack/terraform/output.tf
+++ b/output_files_generated/nginx_openstack/terraform/output.tf
@@ -1,11 +1,11 @@
 
 
-output "instance_server_public_key_ssh_key" {
-  value = openstack_compute_keypair_v2.ssh_key.public_key
+output "instance_server_public_key_user1" {
+  value = openstack_compute_keypair_v2.user1.public_key
 }
 
-output "instance_server_private_key_ssh_key" {
-  value = openstack_compute_keypair_v2.ssh_key.private_key
+output "instance_server_private_key_user1" {
+  value = openstack_compute_keypair_v2.user1.private_key
 }
 
 output "instance_ip_vm1" {
diff --git a/template-location.properties b/template-location.properties
index f0617fe..3dcafba 100644
--- a/template-location.properties
+++ b/template-location.properties
@@ -42,7 +42,7 @@ nginx = templates/ansible/ubuntu/nginx.tpl
 mysql = templates/ansible/ubuntu/mysql.tpl
 wordpress = templates/ansible/ubuntu/wordpress.tpl
 postgres = templates/ansible/ubuntu/postgres.tpl
-piacere_monitoring = templates/ansible/ubuntu/monitoring/main.tpl
+piacere_monitoring = templates/ansible/ubuntu/piacere_main.tpl
 
 [ansible.centos]
 mysql = templates/ansible/centos/mysql.tpl
diff --git a/templates/ansible/ubuntu/monitoring/main.tpl b/templates/ansible/ubuntu/monitoring/main.tpl
deleted file mode 100644
index 657a7ea..0000000
--- a/templates/ansible/ubuntu/monitoring/main.tpl
+++ /dev/null
@@ -1,22 +0,0 @@
----
-- hosts: localhost
-  tasks:
-    - name: print disclamer
-      debug:
-        msg: this can also be done with "ansible-galaxy install -r requirements"
-    - name: install telegraf from galaxy
-      community.general.ansible_galaxy_install:
-        type: role
-        requirements_file: ansible_requirements.yml
-
-- hosts: all
-  pre_tasks:
-    - name: Ensure gnupg package
-      package:
-        name: gnupg
-        state: present
-      become: true
-  vars_files:
-    - vars/main.yaml
-  roles:
-    - dj-wasabi.telegraf
\ No newline at end of file
diff --git a/output_files_generated/nginx_openstack/piacere_monitoring/main.tpl b/templates/ansible/ubuntu/piacere_main.tpl
similarity index 100%
rename from output_files_generated/nginx_openstack/piacere_monitoring/main.tpl
rename to templates/ansible/ubuntu/piacere_main.tpl
-- 
GitLab