Skip to content
Snippets Groups Projects
Commit 447e1e85 authored by Radosław Piliszek's avatar Radosław Piliszek :flag_ua:
Browse files

Merge branch 'monitoring' into 'master'

Monitoring

See merge request !1
parents 5c82ece0 5145fe9d
No related branches found
No related tags found
1 merge request!1Monitoring
Showing
with 61 additions and 145 deletions
--- ---
iac: iac:
- terraform - terraform
- piacere_monitoring_requirements
- piacere_monitoring - piacere_monitoring
- nginx - nginx
... ...
\ No newline at end of file
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html # https://docs.ansible.com/ansible/latest/reference_appendices/config.html
[defaults] [defaults]
host_key_checking = False host_key_checking = False
inventory = {{CWD}}/hosts.yaml ; This points to the file that lists your hosts
remote_user = esilab
deprecation_warnings=False ; to remove the python version depretation warning deprecation_warnings=False ; to remove the python version depretation warning
display_skipped_hosts = no display_skipped_hosts = no
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
input: input:
- instance_ip_vm1 - instance_ip_vm1
- instance_server_private_key_user1 - instance_server_private_key_user1
- DEPLOYMENT_ID
output: [] output: []
engine: ansible engine: ansible
... ...
all:
hosts:
localhost:
ansible_connection: local
#!/bin/bash
set -e
SCRIPT_DIR=$(dirname "$0")
# to avoid the being run in a world writable directory we explicitly assign the ANSIBLE_CONFIG variable
if [[ -f ./ansible.cfg ]]
then
export ANSIBLE_CONFIG=./ansible.cfg
else
if [[ -f $SCRIPT_DIR/ansible.cfg ]]
then
export ANSIBLE_CONFIG=$SCRIPT_DIR/ansible.cfg
fi
fi
if [[ -z "$ANSIBLE_CONFIG" ]]
then
echo ANSIBLE_CONFIG to assigned using default https://docs.ansible.com/ansible/latest/reference_appendices/config.html
else
echo ANSIBLE_CONFIG=$ANSIBLE_CONFIG
fi
if [[ -z "$1" ]]
then
# echo without params
echo ansible-playbook $SCRIPT_DIR/site_requirements.yaml
ansible-playbook $SCRIPT_DIR/site_requirements.yaml
else
# echo with params
echo ansible-playbook $SCRIPT_DIR/site_requirements.yaml --extra-vars "$1"
ansible-playbook $SCRIPT_DIR/site_requirements.yaml --extra-vars "$1"
fi
---
- 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 - hosts: all
pre_tasks: pre_tasks:
- name: Check parameters
fail:
msg: 'variable {{item}} empty'
when: item | length == 0
with_items:
- "{{ pma_deployment_id }}"
- "{{ pma_influxdb_bucket }}"
- "{{ pma_influxdb_token }}"
- "{{ pma_influxdb_org }}"
- "{{ pma_influxdb_addr }}"
- name: Print parameters
debug:
msg:
- "pma_deployment_id: {{ pma_deployment_id }}"
- "pma_influxdb_bucket: {{ pma_influxdb_bucket }}"
- "pma_influxdb_token: {{ pma_influxdb_token }}"
- "pma_influxdb_org: {{ pma_influxdb_org }}"
- "pma_influxdb_addr: {{ pma_influxdb_addr | length }}"
- name: Ensure gnupg package - name: Ensure gnupg package
package: package:
name: gnupg name: gnupg
state: present state: present
become: true become: true
vars_files: vars_files:
- vars/main.yaml - vars/main.yaml
roles: roles:
......
#!/bin/bash
set -e
SCRIPT_DIR=$(dirname "$0")
# to avoid the being run in a world writable directory we explicitly assign the ANSIBLE_CONFIG variable
if [[ -f ./ansible.cfg ]]
then
export ANSIBLE_CONFIG=./ansible.cfg
else
if [[ -f $SCRIPT_DIR/ansible.cfg ]]
then
export ANSIBLE_CONFIG=$SCRIPT_DIR/ansible.cfg
fi
fi
if [[ -z "$ANSIBLE_CONFIG" ]]
then
echo ANSIBLE_CONFIG to assigned using default https://docs.ansible.com/ansible/latest/reference_appendices/config.html
else
echo ANSIBLE_CONFIG=$ANSIBLE_CONFIG
fi
if [[ -z "$1" ]]
then
# echo without params
echo ansible-playbook $SCRIPT_DIR/site.yaml
ansible-playbook $SCRIPT_DIR/site.yaml
else
# echo with params
echo ansible-playbook $SCRIPT_DIR/site.yaml --extra-vars "$1"
ansible-playbook $SCRIPT_DIR/site.yaml --extra-vars "$1"
fi
- hosts: all
pre_tasks:
- name: Check parameters
fail:
msg: 'variable {{item}} not defined'
when: item is not defined
with_items:
- pma_deployment_id
- pma_influxdb_bucket
- pma_influxdb_token
- pma_influxdb_org
- pma_influxdb_addr
- name: Print parameters
debug:
msg:
- "pma_deployment_id: {{ pma_deployment_id }}"
- "pma_influxdb_bucket: {{ pma_influxdb_bucket }}"
- "pma_influxdb_token: {{ pma_influxdb_token }}"
- "pma_influxdb_org: {{ pma_influxdb_org }}"
- "pma_influxdb_addr: {{ pma_influxdb_addr }}"
- name: Ensure gnupg package
package:
name: gnupg
state: present
become: true
vars_files:
- vars/main.yaml
roles:
- dj-wasabi.telegraf
pma_deployment_id: "123e4567-e89b-12d3-a456-426614174002" pma_deployment_id: "{{ lookup('env', 'DEPLOYMENT_ID' ) }}"
pma_influxdb_bucket: "bucket" pma_influxdb_bucket: "{{ lookup('env', 'INFLUXDB_BUCKET' ) }}"
pma_influxdb_token: "piacerePassword" pma_influxdb_token: "{{ lookup('env', 'INFLUXDB_TOKEN' ) }}"
pma_influxdb_org: "piacere" pma_influxdb_org: "{{ lookup('env', 'INFLUXDB_ORG' ) }}"
pma_influxdb_addr: "https://influxdb.pm.ci.piacere.digital.tecnalia.dev" pma_influxdb_addr: "{{ lookup('env', 'INFLUXDB_ADDR' ) }}"
telegraf_agent_package_state: latest telegraf_agent_package_state: latest
......
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html
[defaults]
host_key_checking = False
deprecation_warnings=False ; to remove the python version depretation warning
display_skipped_hosts = no
\ No newline at end of file
---
input: []
output: []
engine: ansible
...
localhost ansible_connection=local
\ No newline at end of file
- name: "Intalling requirements"
hosts: localhost
connection: local
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
...@@ -67,11 +67,7 @@ resource "openstack_networking_port_v2" "net1" { ...@@ -67,11 +67,7 @@ resource "openstack_networking_port_v2" "net1" {
network_id = openstack_networking_network_v2.net1.id network_id = openstack_networking_network_v2.net1.id
admin_state_up = true admin_state_up = true
security_group_ids = [ security_group_ids = [
openstack_compute_secgroup_v2.icmp.id, openstack_compute_secgroup_v2.nginx.id,
openstack_compute_secgroup_v2.http.id,
openstack_compute_secgroup_v2.https.id,
openstack_compute_secgroup_v2.ssh.id,
] ]
fixed_ip { fixed_ip {
subnet_id = openstack_networking_subnet_v2.net1_subnet.id subnet_id = openstack_networking_subnet_v2.net1_subnet.id
...@@ -89,54 +85,43 @@ resource "openstack_networking_router_interface_v2" "net1_router_interface" { ...@@ -89,54 +85,43 @@ resource "openstack_networking_router_interface_v2" "net1_router_interface" {
subnet_id = openstack_networking_subnet_v2.net1_subnet.id subnet_id = openstack_networking_subnet_v2.net1_subnet.id
} }
# generate random string
resource "random_string" "key_pair_user_name" {
length = 16
special = false
upper = false
numeric = false
}
# Create ssh keys # Create ssh keys
resource "openstack_compute_keypair_v2" "user1" { resource "openstack_compute_keypair_v2" "user1" {
name = "user1" name = random_string.key_pair_user_name.result
# public_key = "user1" # public_key = "user1"
} }
# CREATING SECURITY_GROUP # CREATING SECURITY_GROUP
resource "openstack_compute_secgroup_v2" "icmp" { resource "openstack_compute_secgroup_v2" "nginx" {
name = "icmp" name = "nginx"
description = "Security group rule for port -1" description = "Security group rule for nginx"
rule { rule {
from_port = -1 from_port = -1
to_port = -1 to_port = -1
ip_protocol = "icmp" ip_protocol = "icmp"
cidr = "0.0.0.0/0" cidr = "0.0.0.0/0"
} }
}
resource "openstack_compute_secgroup_v2" "http" {
name = "http"
description = "Security group rule for port 80"
rule { rule {
from_port = 80 from_port = 80
to_port = 80 to_port = 80
ip_protocol = "tcp" ip_protocol = "tcp"
cidr = "0.0.0.0/0" cidr = "0.0.0.0/0"
} }
}
resource "openstack_compute_secgroup_v2" "https" {
name = "https"
description = "Security group rule for port 443"
rule { rule {
from_port = 443 from_port = 443
to_port = 443 to_port = 443
ip_protocol = "tcp" ip_protocol = "tcp"
cidr = "0.0.0.0/0" cidr = "0.0.0.0/0"
} }
}
resource "openstack_compute_secgroup_v2" "ssh" {
name = "ssh"
description = "Security group rule for port 22"
rule { rule {
from_port = 22 from_port = 22
to_port = 22 to_port = 22
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment