Skip to content
Snippets Groups Projects
Commit f0b255e9 authored by debora.benedetto@hpe.com's avatar debora.benedetto@hpe.com
Browse files

add piacere monitoring iac generation

parent 6c8831c8
No related branches found
No related tags found
No related merge requests found
Showing with 24 additions and 20 deletions
{{ instance_server_private_key }}
\ No newline at end of file
pma_deployment_id: "123e4567-e89b-12d3-a456-426614174002"
pma_influxdb_bucket: "bucket"
pma_influxdb_token: "piacerePassword"
pma_influxdb_org: "piacere"
pma_influxdb_addr: "https://influxdb.pm.ci.piacere.digital.tecnalia.dev"
telegraf_agent_package_state: latest telegraf_agent_package_state: latest
telegraf_agent_output: telegraf_agent_output:
...@@ -19,5 +25,3 @@ telegraf_plugins_default: ...@@ -19,5 +25,3 @@ telegraf_plugins_default:
- plugin: processes - plugin: processes
- plugin: disk - plugin: disk
- plugin: net - plugin: net
\ No newline at end of file
output "instance_server_public_key_" { output "instance_server_public_key_ssh_key" {
value = openstack_compute_keypair_v2.ssh_key.public_key value = openstack_compute_keypair_v2.ssh_key.public_key
} }
output "instance_server_private_key_" { output "instance_server_private_key_ssh_key" {
value = openstack_compute_keypair_v2.ssh_key.private_key value = openstack_compute_keypair_v2.ssh_key.private_key
} }
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import logging import logging
from icgparser.IntermediateRepresentationUtility import IntermediateRepresentationResources
from plugin import TemplateUtils from plugin import TemplateUtils
from plugin.PluginException import PluginResourceNotFoundError from plugin.PluginException import PluginResourceNotFoundError
...@@ -43,8 +45,10 @@ def create_inventory_file(parameters, language, operating_system, template_name) ...@@ -43,8 +45,10 @@ def create_inventory_file(parameters, language, operating_system, template_name)
return template_filled return template_filled
def create_files(parameters, output_path): def create_files(step, output_path):
language = "ansible" language = step[IntermediateRepresentationResources.LANGUAGE.value]
step_name = step[IntermediateRepresentationResources.STEP_NAME.value]
parameters = step["data"]
for resource_name, resource in parameters.items(): for resource_name, resource in parameters.items():
logging.info("Creating template for resource '%s'", resource_name) logging.info("Creating template for resource '%s'", resource_name)
operating_system = find_operating_system(resource) operating_system = find_operating_system(resource)
...@@ -53,10 +57,10 @@ def create_files(parameters, output_path): ...@@ -53,10 +57,10 @@ def create_files(parameters, output_path):
# for resource_params in parameters[resource_name]: # for resource_params in parameters[resource_name]:
resource_params = parameters[resource_name] resource_params = parameters[resource_name]
ansible_output_file_path = output_path + "/".join([language, resource_name]) + ".yaml" ansible_output_file_path = output_path + "/".join([step_name, resource_name]) + ".yaml"
inventory_output_file_path = output_path + "/".join([language, "inventory"]) + ".j2" inventory_output_file_path = output_path + "/".join([step_name, "inventory"]) + ".j2"
config_output_file_path = output_path + "/".join([language, "config"]) + ".yaml" config_output_file_path = output_path + "/".join([step_name, "config"]) + ".yaml"
ssh_key_output_file_path = output_path + "/".join([language, "ssh_key.j2"]) ssh_key_output_file_path = output_path + "/".join([step_name, "ssh_key.j2"])
template = TemplateUtils.read_template(ansible_template_path) template = TemplateUtils.read_template(ansible_template_path)
template_filled = TemplateUtils.edit_template(template, resource_params) template_filled = TemplateUtils.edit_template(template, resource_params)
......
...@@ -19,11 +19,6 @@ from distutils.dir_util import copy_tree ...@@ -19,11 +19,6 @@ from distutils.dir_util import copy_tree
from plugin import TemplateUtils, PluginUtility from plugin import TemplateUtils, PluginUtility
def store_monitoring_agents_folder(output_path):
logging.info(f"Adding monitoring agents folder in {output_path}")
copy_tree("templates/terraform/open_stack/agents_playbook", output_path)
def create_files(parameters, output_path): def create_files(parameters, output_path):
language = "terraform" language = "terraform"
provider = parameters["provider"] provider = parameters["provider"]
...@@ -58,7 +53,6 @@ def create_files(parameters, output_path): ...@@ -58,7 +53,6 @@ def create_files(parameters, output_path):
TemplateUtils.write_template(terraform_out_file, output_file_stored_path) TemplateUtils.write_template(terraform_out_file, output_file_stored_path)
config_file_stored_path = output_path + "/config.yaml" config_file_stored_path = output_path + "/config.yaml"
TemplateUtils.write_template(config_file, config_file_stored_path) TemplateUtils.write_template(config_file, config_file_stored_path)
store_monitoring_agents_folder(output_path)
logging.info("Terraform main file available at: {}".format(main_file_stored_path)) logging.info("Terraform main file available at: {}".format(main_file_stored_path))
logging.info(f"Terraform output file available at {output_file_stored_path}") logging.info(f"Terraform output file available at {output_file_stored_path}")
......
...@@ -41,6 +41,7 @@ nginx = templates/ansible/ubuntu/nginx.tpl ...@@ -41,6 +41,7 @@ nginx = templates/ansible/ubuntu/nginx.tpl
mysql = templates/ansible/ubuntu/mysql.tpl mysql = templates/ansible/ubuntu/mysql.tpl
wordpress = templates/ansible/ubuntu/wordpress.tpl wordpress = templates/ansible/ubuntu/wordpress.tpl
postgres = templates/ansible/ubuntu/postgres.tpl postgres = templates/ansible/ubuntu/postgres.tpl
piacere_monitoring = templates/ansible/ubuntu/piacere_init.tpl
[ansible.centos] [ansible.centos]
mysql = templates/ansible/centos/mysql.tpl mysql = templates/ansible/centos/mysql.tpl
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
--- ---
input: input:
- instance_ip_{{ node.vm_name }} - instance_ip_{{ node.vm_name }}
- instance_server_private_key_{{ node.vm_key_name }} - instance_server_private_key_{{ node.credentials }}
output: [] output: []
engine: ansible engine: ansible
... ...
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
#} #}
output "instance_server_public_key_{{ vm_key_name }}" { output "instance_server_public_key_{{ credentials }}" {
value = openstack_compute_keypair_v2.{{ credentials }}.public_key value = openstack_compute_keypair_v2.{{ credentials }}.public_key
} }
output "instance_server_private_key_{{ vm_key_name }}" { output "instance_server_private_key_{{ credentials }}" {
value = openstack_compute_keypair_v2.{{ credentials }}.private_key value = openstack_compute_keypair_v2.{{ credentials }}.private_key
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment