# The number of threads handling network requests
+# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3
-# The number of threads doing disk I/O
+# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8
# The send buffer (SO_SNDBUF) used by the socket server
@@ -57,7 +87,7 @@ socket.request.max.bytes=104857600
############################# Log Basics #############################
-# A comma seperated list of directories under which to store log files
+# A comma separated list of directories under which to store log files
log.dirs={{kafka_log_dirs}}
# The default number of log partitions per topic. More partitions allow greater
@@ -69,10 +99,19 @@ num.partitions=1
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1
- # Migrate any partitions the server is the leader for to other replicas prior to shutting down.
- # This will make the leadership transfer faster and minimize the time each partition is unavailable to a few milliseconds.
+# Migrate any partitions the server is the leader for to other replicas prior to shutting down.
+# This will make the leadership transfer faster and minimize the time each partition is unavailable to a few milliseconds.
controlled.shutdown.enable={{controlled_shutdown_enable}}
+
+############################# Internal Topic Settings #############################
+# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
+# For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.
+offsets.topic.replication.factor=1
+transaction.state.log.replication.factor=1
+transaction.state.log.min.isr=1
+
+
############################# Log Flush Policy #############################
# Messages are immediately written to the filesystem but by default we only fsync() to sync
@@ -80,7 +119,7 @@ controlled.shutdown.enable={{controlled_shutdown_enable}}
# There are a few important trade-offs here:
# 1. Durability: Unflushed data may be lost if you are not using replication.
# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
-# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks.
+# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.
@@ -97,11 +136,11 @@ controlled.shutdown.enable={{controlled_shutdown_enable}}
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.
-# The minimum age of a log file to be eligible for deletion
+# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168
-# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
-# segments don't drop below log.retention.bytes.
+# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
+# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824
# The maximum size of a log segment file. When this size is reached a new log segment will be created.
@@ -122,9 +161,21 @@ log.cleaner.enable=false
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
-zookeeper.connect={% for host in groups[cluster_group] %}{{hostvars[host]['private']['hostname']}}:2181{% if not loop.last %},{% endif %}{% endfor %}
+zookeeper.connect={% for host in groups[zookeeper_cluster_group] %}{% if hostvars[host]['is_zoo_host'] is defined %}{% if hostvars[host]['is_zoo_host'] | bool == True %}{{hostvars[host]['private']['hostname']}}:2181{% if not loop.last %},{% endif %}{% endif %}{% endif %}{% endfor %}
+
+# Enable auto creation of topic on the server
auto.create.topics.enable=true
# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
+
+
+############################# Group Coordinator Settings #############################
+
+# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
+# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
+# The default value for this is 3 seconds.
+# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
+# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
+group.initial.rebalance.delay.ms=0
diff --git a/roles/mariadb/README.md b/roles/mariadb/README.md
new file mode 100644
index 00000000..86ec93e0
--- /dev/null
+++ b/roles/mariadb/README.md
@@ -0,0 +1,36 @@
+Ansible role to deploy a mysql database.
+=========
+
+The role installs the mysql database.
+
+Role Variables
+--------------
+
+The main variables described in `defaults/main.yml`.
+You also need for each host to set up a file named `mariadb.yml` containing the following variable :
+
+- `repo_mariadb: true`
+
+The value of `repo_mariadb` should be true so that the ansible role can download the appropriate MariaDB version from the corresponding repository.
+
+Example Playbook
+----------------
+
+How you can use the role:
+
+```
+- hosts: api
+ become: yes
+ roles:
+ - { role: mariadb, task: main, tags: mariadb }
+```
+
+License
+-------
+
+Apache License, Version 2.0
+
+Author Information
+------------------
+
+GRNET
\ No newline at end of file
diff --git a/roles/mariadb/defaults/main.yml b/roles/mariadb/defaults/main.yml
new file mode 100644
index 00000000..5b7c10f6
--- /dev/null
+++ b/roles/mariadb/defaults/main.yml
@@ -0,0 +1,7 @@
+---
+# MySQL Database
+mysql:
+ user: mariadb_admin
+ password: mariadb_admin
+ host: localhost
+ db: mariadb
\ No newline at end of file
diff --git a/roles/mariadb/handlers/main.yml b/roles/mariadb/handlers/main.yml
new file mode 100644
index 00000000..9f93062a
--- /dev/null
+++ b/roles/mariadb/handlers/main.yml
@@ -0,0 +1,4 @@
+---
+
+- name: restart mysql
+ service: name=mysqld state=restarted
diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml
new file mode 100644
index 00000000..da3c9836
--- /dev/null
+++ b/roles/mariadb/tasks/main.yml
@@ -0,0 +1,49 @@
+---
+
+- name: install MariaDB client
+ yum:
+ name: MariaDB-client
+ state: latest
+ tags:
+ - mariadb
+ - mariadb-install
+
+- name: install MariaDB Server
+ yum:
+ name: MariaDB-server
+ state: latest
+ tags:
+ - mariadb
+ - mariadb-install
+
+- name: run MySQL
+ service:
+ name: mariadb
+ state: started
+ enabled: yes
+ tags:
+ - mariadb
+ - mariadb-service
+
+- name: install required python MySQLdb lib to create databases and users
+ yum:
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - gcc-c++
+ - MySQL-python
+ tags:
+ - mariadb
+ - mariadb-xf
+
+- name: create db user
+ mysql_user: name={{mysql.user}} password={{mysql.password}} priv=*.*:ALL host={{mysql.host}} state=present
+ tags:
+ - mariadb
+ - mariadb-user
+
+- name: create mysql database
+ mysql_db: name={{mysql.db}} state=present
+ tags:
+ - mariadb
+ - mariadb-db
\ No newline at end of file
diff --git a/roles/monbox/README.md b/roles/monbox/README.md
index bd7ece08..fc22f551 100644
--- a/roles/monbox/README.md
+++ b/roles/monbox/README.md
@@ -32,7 +32,7 @@ monbox_authorized_for_all_host_commands:
- "/C=GR/O=HellasGrid/OU=grnet.gr/CN=LL"
# firewall settings for all monbox hosts
-firewall_services_zones:
+firewall_services_zones_extra:
- service: https
zone: public
- service: http
diff --git a/roles/mongodb/README.md b/roles/mongodb/README.md
index 4b98dde1..4455e2dc 100644
--- a/roles/mongodb/README.md
+++ b/roles/mongodb/README.md
@@ -6,31 +6,55 @@ MongoDB role sets up mongodb
Requirements
------------
-You will need to have the repo `mongodb-org-3.2` on the host.
-
Role Variables
--------------
-mongo_bind_interfaces: 127.0.0.1 # A Comma separated list of ips(interfaces) mongo should bind to
-mongo_replicated: false # If set to true mongodb will be deployed in a replicated fashion
-mongo_repo: # Set to mongodb-org-3.2 to install mongo-3.2 or mongodb-org-4.0 to install mongodb 4.0
- # If you want to install mongodb-org-3.2 you should set repo_mongo:yes in commons role
- # If you want to install mondodb-org-4.0 you should set repo_mongo_4x:yes in commons role
-
-Selecting MongoDB 3.2 or 4.0
-----------------------------
-This role supports the installation of MongoDB 3.2 or MongoDB 4.0 versions
-To prepare the deployment for MongoDB 3.2 you should:
- - Set variable `repo_mongo` to `yes` in role commons
- - Set variable `mongo_repo` to `mongodb-org-3.2` in this role
-To prepare the deployment for MongoDB 4.0 you should:
- - Set variable `repo_mongo_4x` to `yes` in role commons
- - Set variable `mongo_repo` to `mongodb-org-4.0` in this role
+* `mongo_bind_interfaces` : 127.0.0.1 # A Comma separated list of ips(interfaces) mongo should bind to
+
+* `mongo_replicated` : false # If set to true mongodb will be deployed in a replicated fashion
+
+* `mongo_repo` : # Set to `mongodb-org-3.2` to install `mongo-3.2` or `mongodb-org-4.0` to install `mongodb 4.0`
+
+> * If you want to install **mongodb-org-3.2** you should set `repo_mongo:yes` in **commons** role
+
+ > * If you want to install **mondodb-org-4.0** you should set `repo_mongo_4x:yes` in **commons** role
+
+ * `mongo_backup_scripts_location` : variable for the location of the back up script
+
+ * `mongo_replica_set_name` : variable that controls the name of the replica set
+
+ * `mongo_backup_dbs` : list variable that names the mongo databases that we want to backup.
+
+ * `is_arbiter`: boolean variable that declares if a host that belongs to a replica set will have the role of an arbiter.
+
+ * `mongo_port`: declares the port on which the replica member listens, defaults to **27017**.
+
+ * `mongo_log_rotate`: enables logrotate script for MongoDB log at /var/log/mongodb.log
+
+ ---
+ :warning: NOTE :warning:
+
+ When declaring the hostnames in the inventory group make sure to NOT have the
+ arbiter(s) machine(s) first.
+
+e.g.
+```
+[mongo_private_cluster_devel]
+ mongo1.grnet.gr
+ mongo2.grnet.gr
+ mongo-arbiter.grnet.gr
+```
+
+In case you don't want to rely on the order of the hosts, you should declare
+the variable `is_arbiter` on each one of the host's host vars file.
+
+---
+
Dependencies
------------
-You need to specify the ansible inventory group that will consist your cluster
-- cluster_group: mongo_cluster
+You need to specify the ansible inventory group that will consist your cluster
+- e.g. mongo_cluster_group: mongo_private_cluster_devel
You need for each host to set up the following variable for the private interface
private:
diff --git a/roles/mongodb/defaults/main.yml b/roles/mongodb/defaults/main.yml
index 1240daaf..45255017 100644
--- a/roles/mongodb/defaults/main.yml
+++ b/roles/mongodb/defaults/main.yml
@@ -3,7 +3,14 @@
# Comma separated list of IPs mongo service should bind to
mongo_bind_interfaces: 127.0.0.1
+mongo_port: 27017
mongo_replicated: false
mongo_log_rotate: false
-
-mongo_repo: mongodb-org-3.2
\ No newline at end of file
+is_arbiter: false
+mongo_repo: mongodb-org-3.2
+mongo_backup_scripts_location: /opt/mongobackup/
+mongo_replica_set_name: rs0
+mongo_backup_dbs:
+ - argo_auth
+ - argo_msg
+ - accounting-system
diff --git a/roles/mongodb/handlers/main.yml b/roles/mongodb/handlers/main.yml
index 19c15da0..73f1598f 100644
--- a/roles/mongodb/handlers/main.yml
+++ b/roles/mongodb/handlers/main.yml
@@ -5,3 +5,11 @@
service:
name: mongod
state: restarted
+
+
+- name: Restart Icinga 2 service
+ service:
+ name: icinga2
+ state: restarted
+
+
diff --git a/roles/mongodb/tasks/main.yml b/roles/mongodb/tasks/main.yml
index 3f834f9a..a8fc2324 100644
--- a/roles/mongodb/tasks/main.yml
+++ b/roles/mongodb/tasks/main.yml
@@ -11,10 +11,45 @@
- mongodb-org
- mongodb-org-server
- git
-
+
+
+- name: Instsall python2-pip
+ package:
+ name: python2-pip
+ state: latest
+ tags:
+ - python2
+ - python2-pip
+
+- name: Set specific version of pip
+ pip:
+ name:
+ - pip>10,<21.0
+ state: forcereinstall
+ executable: pip2
+ extra_args: --upgrade
+ tags:
+ - python2
+ - python2-pip
+ - python2-pip-fix
+
+- name: install pymongo==3.12.3
+ pip:
+ name: pymongo==3.12.3
+ state: present
+ executable: pip2.7
+ tags:
+ - pymongo
+ - motop
+
- name: install motop
pip:
name: git+https://github.com/tart/motop.git
+ state: present
+ executable: pip2.7
+ tags:
+ - motop
+
- name: create mongo replicated folder
file:
@@ -33,8 +68,6 @@
- mongo_install
notify: restart mongo
-
-
- name: Increase soft nproc limits
copy:
src: etc/security/limits.d/99-mongodb-nproc.conf
@@ -55,25 +88,25 @@
template: dest="/tmp/db_init_rs.js" owner=root group=root mode=640 src=db_init_rs.js.j2
tags:
- mongo_replication
- when: mongo_replicated == true and groups[cluster_group][0] == inventory_hostname
+ when: mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname
- name: Run init roles script
shell: mongo < /tmp/db_init_rs.js
tags:
- mongo_replication
- when: mongo_replicated == true and groups[cluster_group][0] == inventory_hostname
+ when: mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname
- name: Move rs add members script
template: dest="/tmp/db_rs_members.js" owner=root group=root mode=640 src=db_rs_members.js.j2
tags:
- mongo_replication
- when: mongo_replicated == true and groups[cluster_group][0] == inventory_hostname
+ when: mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname
- name: Run rs add members script
shell: mongo < /tmp/db_rs_members.js
tags:
- mongo_replication
- when: mongo_replicated == true and groups[cluster_group][0] == inventory_hostname
+ when: mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname
- name: Transfer mongo rotate bash script
copy:
@@ -93,4 +126,70 @@
user: root
job: "/root/mongo_rotate.sh"
cron_file: mongo_rotate
- when: mongo_log_rotate == true
\ No newline at end of file
+ when: mongo_log_rotate == true
+
+- name: Ensures mongodb backup directory for script(s) exists
+ file:
+ path: "{{mongo_backup_scripts_location}}"
+ state: directory
+ tags:
+ - mongo_backup
+ when: (mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname) or mongo_replicated == false
+
+- name: Move MongoDB backup script
+ template:
+ dest: "{{ mongo_backup_scripts_location }}mongo_backup.sh"
+ owner: root
+ group: root
+ mode: 0755
+ src: mongodb_backup.sh.j2
+ tags:
+ - mongo_backup
+ when: (mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname) or mongo_replicated == false
+
+- name: Set up cron job for mongo backup script
+ cron:
+ cron_file: mongodb_backup
+ name: "Set up cron job for mongo backup script"
+ user: root
+ special_time: daily
+ job: "{{ mongo_backup_scripts_location }}mongo_backup.sh"
+ tags:
+ - mongo_backup
+ when: (mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname) or mongo_replicated == false
+
+- name: Move aris authorised key for rsync script
+ copy:
+ src: 'private_files/{{ inventory_hostname }}/auth_key/aris_rsa'
+ dest: /root/.ssh/aris_rsa
+ owner: root
+ group: root
+ mode: 0600
+ tags:
+ - mongo_backup_aris
+ - mongo_backup
+ when: (mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname) or mongo_replicated == false
+
+- name: Move MongoDB rsync script
+ template:
+ src: 'rsync-mongod-backup.sh.j2'
+ dest: "{{ mongo_backup_scripts_location }}rsync-mongod-backup.sh"
+ owner: root
+ group: root
+ mode: 0755
+ tags:
+ - mongo_backup_aris
+ - mongo_backup
+ when: (mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname) or mongo_replicated == false
+
+- name: Add cronjob for rsync script
+ cron:
+ cron_file: mongodb_backup
+ name: "Set up cron job for mongo backup script"
+ user: root
+ special_time: daily
+ job: "{{ mongo_backup_scripts_location }}rsync-mongod-backup.sh"
+ tags:
+ - mongo_backup_aris
+ - mongo_backup
+ when: (mongo_replicated == true and groups[mongo_cluster_group][0] == inventory_hostname) or mongo_replicated == false
\ No newline at end of file
diff --git a/roles/mongodb/templates/db_rs_members.js.j2 b/roles/mongodb/templates/db_rs_members.js.j2
index 72c10da9..63159e87 100644
--- a/roles/mongodb/templates/db_rs_members.js.j2
+++ b/roles/mongodb/templates/db_rs_members.js.j2
@@ -1,10 +1,13 @@
-{%- for host in groups[cluster_group] -%}
+{% for host in groups[mongo_cluster_group] %}
+{% if hostvars[host]["is_arbiter"] | default(is_arbiter) %}
-;
+rs.addArb("{{hostvars[host]['private']['hostname']}}:{{mongo_port}}")
-rs.add("{{hostvars[host]['private']['hostname']}}:27017")
+{% else %}
+rs.add("{{hostvars[host]['private']['hostname']}}:{{mongo_port}}")
+{% endif %}
-{%- endfor -%}
+{% endfor %}
diff --git a/roles/mongodb/templates/init_projects.js.j2 b/roles/mongodb/templates/init_projects.js.j2
deleted file mode 100644
index 35ed2d20..00000000
--- a/roles/mongodb/templates/init_projects.js.j2
+++ /dev/null
@@ -1,19 +0,0 @@
-// Open Database
-use {{argo_msg_store_db}}
-
-// Create projects
-
-{%- if messaging_api_projects is defined -%}
-
-{%- for project in messaging_api_projects -%}
-
-
-// Create projects
-db.projects.update({"name" : "{{project.name}}"},{ "name":"{{project.name}}","uuid" : "{{project.uuid}}", "created_on":new ISODate(), "modified_on": new ISODate()},{"upsert":"true"})
-
-
-
-{%- endfor -%}
-
-
-{%- endif -%}
diff --git a/roles/mongodb/templates/init_roles.js.j2 b/roles/mongodb/templates/init_roles.js.j2
deleted file mode 100644
index 04d6571a..00000000
--- a/roles/mongodb/templates/init_roles.js.j2
+++ /dev/null
@@ -1,40 +0,0 @@
-use {{argo_msg_store_db}}
-db.roles.drop()
-db.roles.insert([
-{"resource" : "users:byToken", "roles" : [ "service_admin" ] },
-{"resource" : "users:list", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "users:show", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "users:create", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "users:update", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "users:refreshToken", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "users:delete", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "projects:metrics", "roles" : [ "service_admin", "project_admin"] },
-{"resource" : "projects:list", "roles" : [ "service_admin"] },
-{"resource" : "projects:create", "roles" : [ "service_admin" ] },
-{"resource" : "projects:show", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "projects:update", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "projects:delete", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "topics:list", "roles" : ["service_admin", "project_admin" ] },
-{"resource" : "topics:publish", "roles" : [ "service_admin","project_admin", "publisher" ] },
-{"resource" : "topics:metrics", "roles" : [ "service_admin", "project_admin", "publisher" ] },
-{"resource" : "topics:list", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "topics:show", "roles" : [ "service_admin", "project_admin", "publisher" ] },
-{"resource" : "topics:create", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "topics:delete", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "topics:acl", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "topics:modifyAcl", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "subscriptions:create", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "subscriptions:delete", "roles" : ["service_admin", "project_admin" ] },
-{"resource" : "subscriptions:list", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "subscriptions:show", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "subscriptions:acknowledge", "roles" : [ "service_admin", "project_admin", "consumer" ] },
-{"resource" : "subscriptions:show", "roles" : [ "service_admin", "project_admin", "consumer" ] },
-{"resource" : "subscriptions:pull", "roles" : [ "service_admin", "project_admin", "consumer" ] },
-{"resource" : "subscriptions:offsets", "roles" : [ "service_admin", "project_admin", "consumer" ] },
-{"resource" : "subscriptions:modifyOffset", "roles" : [ "service_admin", "project_admin", "consumer" ] },
-{"resource" : "subscriptions:metrics", "roles" : [ "service_admin", "project_admin", "consumer" ] },
-{"resource" : "subscriptions:acl", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "subscriptions:modifyAcl", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "subscriptions:modifyPushConfig", "roles" : [ "service_admin", "project_admin" ] },
-{"resource" : "ams:metrics", "roles" : [ "service_admin", "project_admin"] }
-])
diff --git a/roles/mongodb/templates/init_users.js.j2 b/roles/mongodb/templates/init_users.js.j2
deleted file mode 100644
index 2cda1d78..00000000
--- a/roles/mongodb/templates/init_users.js.j2
+++ /dev/null
@@ -1,23 +0,0 @@
-// Open Database
-use {{argo_msg_store_db}}
-
-// Begin inserting new users
-
-{%- if messaging_api_users is defined -%}
-
-{%- for user in messaging_api_users -%}
-
-
-;
-
-
-
-
-db.users.update({"uuid":"{{user.uuid}}", "name" : "{{user.username}}"},{ "uuid":"{{user.uuid}}", "name":"{{user.username}}","email" : "{{user.email}}", {%- if user.projects is defined -%} "projects" : [ {%- for prole in user.projects -%} { "project_uuid":"{{prole.project_uuid}}" {%- if prole.roles is defined -%}, "roles": [ {%- for role in prole.roles -%} "{{role}}" {%- endfor -%} ] {%- endif -%}} {%- endfor -%}],{%- endif -%} {%- if user.service_roles is defined -%} "service_roles": [ {%- for role in user.service_roles -%} "{{role}}" {%- endfor -%}], {%- endif -%} "token" : "{{user.key}}", {%- if user.created_by is defined -%} "created_by":"{{user.created_by}}", {%- endif -%} "created_on":new ISODate(), "modified_on": new ISODate()},{"upsert":"true"})
-
-
-
-{%- endfor -%}
-
-
-{%- endif -%}
diff --git a/roles/mongodb/templates/mongodb_backup.sh.j2 b/roles/mongodb/templates/mongodb_backup.sh.j2
new file mode 100644
index 00000000..d7358843
--- /dev/null
+++ b/roles/mongodb/templates/mongodb_backup.sh.j2
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+TIMESTAMP=`date +%FT%H:00`
+MONGODUMP_PATH="/usr/bin/mongodump"
+BACKUPS_DIR="/root/{{inventory_hostname}}-mongo-data"
+
+{% if mongo_replicated | default(false) | bool %}
+REPLSET_URI="{{mongo_replica_set_name}}/{% for host in groups[mongo_cluster_group] %}{% if hostvars[host]['private']['hostname'] is defined %}{{ hostvars[host]['private']['hostname'] }}{% else %}{{ hostvars[host].ansible_default_ipv4.address }}{% endif %}:{{mongo_port}}{% if not loop.last %},{% endif %}{% endfor %}"
+{% endif %}
+
+DATABASES=(
+ {% for host in mongo_backup_dbs %}
+ {{ host }}
+ {% endfor %}
+)
+
+for DB_NAME in "${DATABASES[@]}"; do
+ BACKUP_NAME="$DB_NAME-$TIMESTAMP"
+ mkdir -p $BACKUPS_DIR/$DB_NAME
+ $MONGODUMP_PATH --host $REPLSET_URI --db $DB_NAME --gzip --archive=$BACKUPS_DIR/$DB_NAME/$BACKUP_NAME.archive
+done
diff --git a/roles/commons/templates/rsync-mongod-backup.sh.j2 b/roles/mongodb/templates/rsync-mongod-backup.sh.j2
similarity index 87%
rename from roles/commons/templates/rsync-mongod-backup.sh.j2
rename to roles/mongodb/templates/rsync-mongod-backup.sh.j2
index e8e54bb3..5d621366 100644
--- a/roles/commons/templates/rsync-mongod-backup.sh.j2
+++ b/roles/mongodb/templates/rsync-mongod-backup.sh.j2
@@ -19,8 +19,8 @@ RPATH="$RPARENTDIR"/"$HOSTNAME"/
#
# local directories to be rsynced
#
-DIRECTORY="/root/{{inventory_hostname}}-mongo-data/{{MONGOBACKUP_APP_NAME}}"
-LPATH="/root/{{inventory_hostname}}-mongo-data/{{MONGOBACKUP_APP_NAME}}"
+DIRECTORY="/root/{{inventory_hostname}}-mongo-data"
+LPATH="/root/{{inventory_hostname}}-mongo-data"
# use rsync for copy
COPYCMD=(/usr/bin/rsync -e "/usr/bin/ssh -i $SSHKEY" -va)
@@ -42,4 +42,4 @@ printf -- "---------------------------------------------------------------------
printf -- "--------------------------------------------------------------------------------------\n"
printf "Backup of files to host %s completed at %s\n" "$RHOST" "`date`"
-printf -- "--------------------------------------------------------------------------------------\n\n"
\ No newline at end of file
+printf -- "--------------------------------------------------------------------------------------\n\n"
diff --git a/roles/pcc-api/README.md b/roles/pcc-api/README.md
new file mode 100644
index 00000000..d4449518
--- /dev/null
+++ b/roles/pcc-api/README.md
@@ -0,0 +1,62 @@
+Ansible role to deploy PCC API.
+=========
+
+The role installs the PCC API.
+
+Requirements
+------------
+
+- `MariaDB v.10.3`
+- `JDK 11+`
+- `Apache Maven 3.8.1+`
+
+Role Variables
+--------------
+
+The main variables described in `defaults/main.yml`.
+You also need for each host to set up a file named `mariadb.yml` containing the following variable :
+
+- `repo_mariadb: true`
+
+The value of `repo_mariadb` should be true so that the ansible role can download the appropriate MariaDB version from the corresponding repository.
+
+Dependencies
+------------
+
+- commons/timezone
+- commons/repos
+- commons/basic_utils
+- commons/users
+- commons/sshd
+- commons/firewall
+- commons/fail2ban
+- commons/cert
+- commons/rsyslog
+- icinga_agent/deploy_icinga_agent
+
+Example Playbook
+----------------
+
+How you can use the role:
+
+```
+- hosts: pcc-api
+ become: yes
+ roles:
+ - { role: pcc-api, task: main, tags: pcc-api }
+```
+
+* Deploy :
+```bash
+ansible-playbook -i pcc-api.ini argo-ansible/pcc-api-playbook.yml --vault-password-file=../vaultARGO
+```
+
+License
+-------
+
+Apache License, Version 2.0
+
+Author Information
+------------------
+
+GRNET
\ No newline at end of file
diff --git a/roles/pcc-api/defaults/main.yml b/roles/pcc-api/defaults/main.yml
new file mode 100644
index 00000000..f43623db
--- /dev/null
+++ b/roles/pcc-api/defaults/main.yml
@@ -0,0 +1,30 @@
+---
+# defaults file for pcc
+
+
+## Privileged user for pcc
+#
+pcc_api_user: pcc_api
+pcc_api_group: pcc_api
+
+# Directories
+#
+pcc_api_root_dir: /opt/pcc-api
+pcc_api_conf_dir: /etc/pcc-api/conf.d
+pcc_api_logs_dir: /var/log/pcc-api
+
+# MySQL Database
+mysql:
+ user: pcc_api_admin
+ password: pcc_api_admin
+ host: localhost
+ db: pccdb
+
+hrls:
+ username: user
+ password: password
+ database_ip: database_ip
+ database_port: database_port
+ database_name: database_name
+ database_username: database_username
+ database_password: database_password
diff --git a/roles/pcc-api/handlers/main.yml b/roles/pcc-api/handlers/main.yml
new file mode 100644
index 00000000..774e9bb8
--- /dev/null
+++ b/roles/pcc-api/handlers/main.yml
@@ -0,0 +1,30 @@
+---
+# handlers file for pcc
+
+
+- name: restart rsyslog
+ service:
+ name: rsyslog
+ state: restarted
+ enabled: true
+
+
+- name: Reload the systemd daemon
+ systemd:
+ daemon_reload: yes
+
+
+- name: pcc api service restart and enable
+ service:
+ name: pcc-api.service
+ state: restarted
+ enabled: true
+
+- name: Wait a few seconds for the service to wake up
+ become: no
+ wait_for:
+ timeout: 10
+ delegate_to: localhost
+
+- name: restart mysql
+ service: name=mysqld state=restarted
diff --git a/roles/pcc-api/meta/main.yml b/roles/pcc-api/meta/main.yml
new file mode 100644
index 00000000..f3b4b7f3
--- /dev/null
+++ b/roles/pcc-api/meta/main.yml
@@ -0,0 +1,53 @@
+galaxy_info:
+ author: Anastasios Lisgaras
+ description: DevOps Engineer
+ company: GRNET
+
+ # If the issue tracker for your role is not on github, uncomment the
+ # next line and provide a value
+ # issue_tracker_url: http://example.com/issue/tracker
+
+ # Choose a valid license ID from https://spdx.org - some suggested licenses:
+ # - BSD-3-Clause (default)
+ # - MIT
+ # - GPL-2.0-or-later
+ # - GPL-3.0-only
+ # - Apache-2.0
+ # - CC-BY-4.0
+ license: license (GPL-2.0-or-later, MIT, etc)
+
+ min_ansible_version: 2.9
+
+ # If this a Container Enabled role, provide the minimum Ansible Container version.
+ # min_ansible_container_version:
+
+ #
+ # Provide a list of supported platforms, and for each platform a list of versions.
+ # If you don't wish to enumerate all versions for a particular platform, use 'all'.
+ # To view available platforms and versions (or releases), visit:
+ # https://galaxy.ansible.com/api/v1/platforms/
+ #
+ # platforms:
+ # - name: Fedora
+ # versions:
+ # - all
+ # - 25
+ # - name: SomePlatform
+ # versions:
+ # - all
+ # - 1.0
+ # - 7
+ # - 99.99
+
+ galaxy_tags: []
+ # List tags for your role here, one per line. A tag is a keyword that describes
+ # and categorizes the role. Users find roles by searching for tags. Be sure to
+ # remove the '[]' above, if you add tags to this list.
+ #
+ # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
+ # Maximum 20 tags per role.
+
+dependencies: []
+ # List your role dependencies here, one per line. Be sure to remove the '[]' above,
+ # if you add dependencies to this list.
+
diff --git a/roles/pcc-api/tasks/main.yml b/roles/pcc-api/tasks/main.yml
new file mode 100644
index 00000000..cf72d792
--- /dev/null
+++ b/roles/pcc-api/tasks/main.yml
@@ -0,0 +1,242 @@
+---
+# tasks file for pcc api
+
+
+- name: Ensure group "{{ pcc_api_group }}" exists
+ group:
+ name: "{{ pcc_api_group }}"
+ state: present
+ tags:
+ - pcc-api
+ - pcc-api-user
+
+- name: Add user "{{ pcc_api_user }}"
+ user:
+ name: "{{ pcc_api_user }}"
+ groups: "{{ pcc_api_group }}"
+ append: yes
+ create_home: no
+ shell: /sbin/nologin
+ comment: pcc api nologin user
+ tags:
+ - pcc-api
+ - pcc-api-user
+
+- name: Install Java 11
+ yum:
+ name: "{{ packages }}"
+ state: latest
+ vars:
+ packages:
+ - java-11-openjdk
+ - java-11-openjdk-devel
+ tags:
+ - pcc-api
+ - pcc-api-packages
+ - pcc-api-java
+ - pcc-api-maven
+
+- name: Download maven 3.8.6 and unarchive in /opt/
+ unarchive:
+ src: https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.tar.gz
+ dest: /opt
+ remote_src: yes
+ validate_certs: no
+ tags:
+ - pcc-api
+ - pcc-api-maven
+
+- name: Maven (mvn) symbolic link
+ file:
+ src: /opt/apache-maven-3.8.6/bin/mvn
+ dest: '/usr/local/bin/mvn'
+ owner: "{{ pcc_api_user }}"
+ group: "{{ pcc_api_group }}"
+ state: link
+ force: yes
+ tags:
+ - pcc-api
+ - pcc-api-maven
+ - pcc-api-maven
+ - pcc-api-maven-link
+
+- name: install MariaDB client
+ yum:
+ name: MariaDB-client
+ state: latest
+ tags:
+ - pcc-api
+ - pcc-api-mysql
+ - pcc-api-mysql-install
+
+- name: install MariaDB Server
+ yum:
+ name: MariaDB-server
+ state: latest
+ tags:
+ - pcc-api
+ - pcc-api-mysql
+ - pcc-api-mysql-install
+
+- name: run MySQL
+ service:
+ name: mariadb
+ state: started
+ enabled: yes
+ tags:
+ - pcc-api
+ - pcc-api-mysql
+ - pcc-api-mysql-service
+
+- name: install required python MySQLdb lib to create databases and users
+ yum:
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - gcc-c++
+ - MySQL-python
+ tags:
+ - pcc-api
+ - pcc-api-mysql
+ - pcc-api-mysql-xf
+
+- name: create db user
+ mysql_user: name={{mysql.user}} password={{mysql.password}} priv=*.*:ALL host={{mysql.host}} state=present
+ tags:
+ - pcc-api
+ - pcc-api-mysql
+ - pcc-api-mysql-user
+
+- name: create mysql database
+ mysql_db: name={{mysql.db}} state=present
+ tags:
+ - pcc-api
+ - pcc-api-mysql
+ - pcc-api-mysql-db
+
+- name: Create systemd file for PCC API
+ template:
+ src: pcc_api.service.j2
+ dest: /etc/systemd/system/pcc-api.service
+ owner: root
+ group: root
+ mode: '0644'
+ notify:
+ - Reload the systemd daemon
+ - pcc api service restart and enable
+ - Wait a few seconds for the service to wake up
+ tags:
+ - pcc-api
+ - pcc-api-service-file
+
+
+- name: "Create {{ pcc_api_root_dir }}, {{ pcc_api_conf_dir }} directories if it does not exist"
+ file:
+ path: "{{ item }}"
+ state: directory
+ owner: "{{ pcc_api_user }}"
+ group: "{{ pcc_api_group }}"
+ mode: '0755'
+ loop:
+ - "{{ pcc_api_root_dir }}"
+ - "{{ pcc_api_conf_dir }}"
+ tags:
+ - pcc-api
+ - pcc-api-directories
+
+- name: "Create PCC API logs directory if it doesn't exist"
+ file:
+ path: "{{ pcc_api_logs_dir }}"
+ state: directory
+ owner: root
+ group: root
+ mode: '0700'
+ tags:
+ - pcc-api
+ - pcc-api-directories
+
+- name: Create rsyslog filter for PCC-API logs
+ template:
+ src: etc/rsyslog.d/71_pcc_api.conf.j2
+ dest: /etc/rsyslog.d/71_pcc_api.conf
+ backup: yes
+ owner: root
+ group: root
+ mode: '0644'
+ notify:
+ - restart rsyslog
+ tags:
+ - pcc-api
+ - pcc-api-logs
+ - pcc-api-rsyslog
+
+
+- meta: flush_handlers
+
+- name: Find the artifact of the last successful build
+ uri:
+ url: https://{{ jenkins.host }}/job/{{ jenkins.job }}/job/{{ jenkins.repository }}/job/{{ jenkins.branch }}/lastSuccessfulBuild/api/json
+ user: "{{ jenkins.user }}"
+ password: "{{ jenkins.password }}"
+ method: GET
+ force_basic_auth: yes
+ status_code: 200
+ register: _jenkins_results
+ tags:
+ - pcc-api
+ - pcc-api-jenkins
+ - pcc-api-jar
+ - pcc-api-update
+
+- name: Download the latest Jenkins artifact
+ get_url:
+ url: https://{{ jenkins.host }}/job/{{ jenkins.job }}/job/{{ jenkins.repository }}/job/{{ jenkins.branch }}/lastSuccessfulBuild/artifact/{{ _jenkins_results.json.artifacts[0].relativePath }}
+ dest: "{{ pcc_api_root_dir }}/pcc-api.jar"
+ username: "{{ jenkins.user }}"
+ password: "{{ jenkins.password }}"
+ force_basic_auth: yes
+ owner: "{{ pcc_api_user }}"
+ group: "{{ pcc_api_group }}"
+ mode: '0744'
+ backup: yes
+ notify:
+ - pcc api service restart and enable
+ - Wait a few seconds for the service to wake up
+ tags:
+ - pcc-api
+ - pcc-api-jar
+ - pcc-api-update
+
+- name: Recursively change ownership of the PCC directories
+ file:
+ path: "{{ item }}"
+ state: directory
+ recurse: yes
+ owner: "{{ pcc_api_user }}"
+ group: "{{ pcc_api_group }}"
+ loop:
+ - "{{ pcc_api_root_dir }}"
+ - "{{ pcc_api_conf_dir }}"
+ tags:
+ - pcc-api
+ - pcc-api-directories
+ - pcc-api-update
+
+- meta: flush_handlers
+
+- name: Restart pcc api
+ service:
+ name: pcc-api.service
+ state: restarted
+ enabled: true
+ tags:
+ - pcc-api
+ - pcc-api-update
+
+- name: More about PCC project.
+ debug:
+ msg:
+ - https://github.com/ARGOeu/pcc-api/tree/devel
+ tags:
+ - pcc-api
+ - pcc-api-check
diff --git a/roles/pcc-api/templates/etc/rsyslog.d/71_pcc_api.conf.j2 b/roles/pcc-api/templates/etc/rsyslog.d/71_pcc_api.conf.j2
new file mode 100644
index 00000000..93431fb8
--- /dev/null
+++ b/roles/pcc-api/templates/etc/rsyslog.d/71_pcc_api.conf.j2
@@ -0,0 +1,51 @@
+# {{ ansible_managed }}
+
+
+# accounting templates
+template(name="pcc-logs" type="string" string="/var/log/pcc-api/pcc-api.log")
+
+# Local logs
+if ($programname contains "pcc") then {
+ action(type="omfile"
+ name="accounting"
+ dynaFile="pcc-logs"
+ queue.type="LinkedList"
+ queue.filename="queue_pcc_backend"
+ queue.size="100000"
+ action.resumeRetryCount="-1"
+ queue.saveonshutdown="on"
+ )
+ & stop
+}
+
+
+# Send accounting logs.
+## https://www.rsyslog.com/doc/master/configuration/modules/imfile.html
+## https://www.rsyslog.com/doc/master/configuration/actions.html
+## https://www.rsyslog.com/doc/master/configuration/templates.html
+## https://www.rsyslog.com/doc/master/concepts/queues.html
+## https://www.rsyslog.com/doc/master/rainerscript/queue_parameters.html
+
+
+ruleset(name="fwdaccountingtocentrallog"){
+ action(type="omfwd"
+ name="pcc-api"
+ template="RSYSLOG_TraditionalForwardFormat"
+ queue.type="LinkedList" # In Memory Queue
+ queue.filename="fwd_q_accounting" # File name to be used for the queue files.
+ queue.size="100000" # The maximum size of the queue in number of messages.
+ action.resumeRetryCount="-1" # Sets how often an action is retried before it is considered to have failed. Failed actions discard messages. (-1 means eternal)
+ queue.saveonshutdown="on" # This parameter specifies if data should be saved at shutdown.
+ Target="{{ central_rsyslog.hostname }}" Port="{{ central_rsyslog.port }}" Protocol="tcp"
+ StreamDriver="gtls"
+ StreamDriverMode="1" # run driver in TLS-only mode
+ StreamDriverAuthMode="x509/name"
+ StreamDriverPermittedPeers="{{ central_rsyslog.permittedPeers }}"
+ )
+}
+
+input(type="imfile"
+ File="/var/log/pcc-api/*log"
+ Tag="accounting:"
+ ruleset="fwdaccountingtocentrallog"
+)
diff --git a/roles/pcc-api/templates/pcc_api.service.j2 b/roles/pcc-api/templates/pcc_api.service.j2
new file mode 100644
index 00000000..faad5c10
--- /dev/null
+++ b/roles/pcc-api/templates/pcc_api.service.j2
@@ -0,0 +1,33 @@
+[Unit]
+Description=PCC API.
+After=network.target remote-fs.target nss-lookup.target
+Documentation=https://github.com/ARGOeu/pcc-api/tree/devel
+
+[Service]
+#Type=simple
+User={{ pcc_api_user }}
+Group={{ pcc_api_group }}
+WorkingDirectory={{ pcc_api_root_dir }}
+ExecStart=/usr/bin/java -jar {{ pcc_api_root_dir }}/pcc-api.jar
+SyslogIdentifier=pcc-api
+Restart=on-failure
+RestartSec=5s
+SuccessExitStatus=143
+#KillMode=mixed
+Environment="QUARKUS_DATASOURCE_JDBC_URL=jdbc:mysql://localhost:3306/pccdb"
+Environment="QUARKUS_FLYWAY_SCHEMAS={{mysql.db}}"
+Environment="QUARKUS_DATASOURCE_USERNAME={{mysql.user}}"
+Environment="QUARKUS_DATASOURCE_PASSWORD={{mysql.password}}"
+Environment="HRLS_PASSWORD={{hrls.password}}"
+Environment="HRLS_USERNAME={{hrls.username}}"
+Environment="HRLS_DATABASE_IP={{hrls.database_ip}}"
+Environment="HRLS_DATABASE_PORT={{hrls.database_port}}"
+Environment="HRLS_DATABASE_NAME={{hrls.database_name}}"
+Environment="HRLS_DATABASE_USERNAME={{hrls.database_username}}"
+Environment="HRLS_DATABASE_PASSWORD={{hrls.database_password}}"
+Environment="PCC_API_PROFILE=prod"
+
+[Install]
+WantedBy=multi-user.target
+#Alias=pcc_api.service
+#Alias=pcc_apid.service
diff --git a/roles/pcc-ui/defaults/main.yml b/roles/pcc-ui/defaults/main.yml
new file mode 100644
index 00000000..03251d04
--- /dev/null
+++ b/roles/pcc-ui/defaults/main.yml
@@ -0,0 +1,5 @@
+---
+# defaults file for pcc-ui
+git_repo_url: https://github.com/ARGOeu/pcc-ui.git
+repo_path: /tmp/pcc-ui
+repo_branch: devel
\ No newline at end of file
diff --git a/roles/pcc-ui/handlers/main.yml b/roles/pcc-ui/handlers/main.yml
new file mode 100644
index 00000000..1731b8f8
--- /dev/null
+++ b/roles/pcc-ui/handlers/main.yml
@@ -0,0 +1,8 @@
+---
+# handlers file for argo_status_pages
+
+- name: restart httpd
+ service:
+ name: httpd
+ enabled: yes
+ state: restarted
\ No newline at end of file
diff --git a/roles/pcc-ui/tasks/deploy.yml b/roles/pcc-ui/tasks/deploy.yml
new file mode 100644
index 00000000..de133868
--- /dev/null
+++ b/roles/pcc-ui/tasks/deploy.yml
@@ -0,0 +1,92 @@
+---
+# tasks file for pcc-ui
+- name: Run the equivalent of "apt-get update" as a separate step
+ yum:
+ update_cache: true
+ tags:
+ - pcc-ui
+
+- name: Install reqired packages
+ yum:
+ name:
+ - git
+ - curl
+ - wget
+ tags:
+ - pcc-ui
+
+- name: Download npm
+ get_url:
+ url: https://rpm.nodesource.com/setup_17.x
+ dest: /tmp/setup_17.x
+ tags:
+ - pcc-ui
+
+- name: Install npm
+ shell:
+ bash /tmp/setup_17.x
+ tags:
+ - pcc-ui
+
+- name: Install NodeJs
+ yum:
+ name:
+ - nodejs
+ tags:
+ - pcc-ui
+
+- name: Check clone repo dest directory is absent
+ file:
+ state: absent
+ path: "{{ repo_path }}/"
+
+- name: Clone a private repository
+ git:
+ repo: "{{ git_repo_url }}"
+ dest: "{{ repo_path }}"
+ version: "{{ repo_branch }}"
+ force: true
+ accept_hostkey: true
+ tags:
+ - pcc-ui
+
+- name: Install packages based on package.json using the npm
+ npm:
+ path: "{{ repo_path }}"
+ state: present
+ tags:
+ - pcc-ui
+
+- name: Copy config
+ copy:
+ src: "private_files/{{ inventory_hostname }}/config.js"
+ dest: "{{ repo_path }}/src/config.js"
+ remote_src: false
+ tags:
+ - pcc-ui
+
+
+- name: Copy config
+ copy:
+ src: "private_files/{{ inventory_hostname }}/.htpasswd"
+ dest: "/etc/httpd/.htpasswd"
+ remote_src: false
+ tags:
+ - pcc-ui
+
+- name: Build app
+ command: npm run build
+ args:
+ chdir: "{{ repo_path }}"
+ tags:
+ - pcc-ui
+
+- name: Copy folder to /var/www
+ notify:
+ - restart httpd
+ copy:
+ src: "{{ repo_path }}/build/"
+ dest: "/var/www/{{inventory_hostname}}/"
+ remote_src: true
+ tags:
+ - pcc-ui
diff --git a/roles/pcc-ui/tasks/main.yml b/roles/pcc-ui/tasks/main.yml
new file mode 100644
index 00000000..a50363ee
--- /dev/null
+++ b/roles/pcc-ui/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+# tasks file for pcc-ui
+
+- include: '{{task}}.yml'
\ No newline at end of file
diff --git a/roles/private_hosts/templates/hosts.j2 b/roles/private_hosts/templates/hosts.j2
index b88e2e86..325d0180 100644
--- a/roles/private_hosts/templates/hosts.j2
+++ b/roles/private_hosts/templates/hosts.j2
@@ -1,6 +1,6 @@
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
-{% for host in groups[cluster_group] %}
+{% for host in groups['all'] %}
{{hostvars[host]['private']['ip']}} {{hostvars[host]['private']['hostname']}}
{% endfor %}
diff --git a/roles/push-server/defaults/main.yml b/roles/push-server/defaults/main.yml
index b0c1281f..fb71d924 100644
--- a/roles/push-server/defaults/main.yml
+++ b/roles/push-server/defaults/main.yml
@@ -1,2 +1,7 @@
---
# defaults file for push-server
+
+
+#push_ams_token: "5d....2d32"
+#push_ams_host: "push-server.example.com"
+
diff --git a/roles/push-server/handlers/main.yml b/roles/push-server/handlers/main.yml
index c95b030f..d68dfac5 100644
--- a/roles/push-server/handlers/main.yml
+++ b/roles/push-server/handlers/main.yml
@@ -3,3 +3,9 @@
- name: restart ams-push-server
service: name=ams-push-server state=restarted
+
+- name: restart rsyslog
+ service:
+ name: rsyslog
+ state: restarted
+
diff --git a/roles/push-server/tasks/push-server-setup.yml b/roles/push-server/tasks/push-server-setup.yml
index cf56f918..6c3d17ca 100644
--- a/roles/push-server/tasks/push-server-setup.yml
+++ b/roles/push-server/tasks/push-server-setup.yml
@@ -28,8 +28,8 @@
notify: restart ams-push-server
- name: Copy CA file
- copy: src=private_files/{{ inventory_hostname }}/DigiCertCA.crt
- dest=/var/www/ams-push-server/cas/DigiCertCA.pem
+ copy: src=private_files/{{ inventory_hostname }}/CA.crt
+ dest=/var/www/ams-push-server/cas/CA.pem
backup=yes
owner=ams-push-server group=ams-push-server mode=0644
tags: push_install
@@ -45,6 +45,23 @@
tags: push_install
notify: restart ams-push-server
+
+- name: Allow bind port 443
+ shell: setcap 'cap_net_bind_service=+ep' /var/www/ams-push-server/ams-push-server
+ tags: push_install
+
+
+- name: Configure argo-ams-push log(rsyslog)
+ template:
+ src: rsyslog_ams-push.conf.j2
+ dest: /etc/rsyslog.d/ams-push.conf
+ backup: true
+ notify: restart rsyslog
+ tags:
+ - push_install
+ - push_rsyslog
+
+
- name: Start the ams push server
service:
name: ams-push-server
diff --git a/roles/push-server/tasks/update.yml b/roles/push-server/tasks/update.yml
new file mode 100644
index 00000000..a8d5a481
--- /dev/null
+++ b/roles/push-server/tasks/update.yml
@@ -0,0 +1,20 @@
+---
+
+- name: Update ams-push-server package
+ yum:
+ name: ams-push-server
+ state: latest
+ enablerepo: "{{ repo_enabled_argo }}"
+ update_cache: true
+ tags: ams_push_server_update
+
+- name: Reload the systemd daemon
+ systemd:
+ daemon_reload: yes
+ tags: ams_push_server_update
+
+- name: restart ams-push-server
+ service:
+ name: ams-push-server
+ state: restarted
+ tags: ams_push_server_update
diff --git a/roles/push-server/templates/rsyslog_ams-push.conf.j2 b/roles/push-server/templates/rsyslog_ams-push.conf.j2
new file mode 100644
index 00000000..4b0e44be
--- /dev/null
+++ b/roles/push-server/templates/rsyslog_ams-push.conf.j2
@@ -0,0 +1,2 @@
+if $programname == 'ams_push_server' then /var/log/argo_ams_push_server/push.log
+& stop
diff --git a/roles/quarkus-api/README.md b/roles/quarkus-api/README.md
new file mode 100644
index 00000000..59107853
--- /dev/null
+++ b/roles/quarkus-api/README.md
@@ -0,0 +1,54 @@
+quarkus-api Role
+=========
+
+quarkus-api role sets up a quarkus api.
+
+Requirements
+------------
+
+Role Variables
+--------------
+
+* `quarkus_api.jar_name` : The jar name may express the name of your project e.g. `cat-api.jar`. Otherwise, choose your preferable name.
+
+* `quarkus_api.service_name` : The service name may express the name of your project e.g. `cat-api.service`. Otherwise, choose your preferable name.
+
+* `quarkus_api.repo_url` : The API git repository URL.
+
+* `quarkus_api.doc_url` : The API documentation URL.
+
+* `quarkus_api.description` : The API description.
+
+* `quarkus_api.log` : The API name used in jinja rsyslog template.
+
+* `environment_variables` : The environment variables that API needs to run.
+
+* `files` : You can use the following parameters to download a file from a specific URL and place it in a directory.
+ - `directory` : The directory where the file will be placed.
+ - `url` : The URL where the file is located.
+
+Example Playbook
+----------------
+
+Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
+
+```
+- hosts: server
+ become: yes
+ roles:
+ - { role: quarkus-api, task: quarkus-api, tags: quarkus-api }
+```
+* Deploy :
+```bash
+ansible-playbook -i cat-api-devel.ini argo-ansible/cat-api-playbook.yml --vault-password-file=../vaultARGO
+```
+
+* Update only:
+```bash
+ansible-playbook -i cat-api-devel.ini argo-ansible/cat-api-playbook.yml --vault-password-file=../vaultARGO --tags="quarkus-api-update"
+```
+
+License
+-------
+
+Apache License, Version 2.0
diff --git a/roles/quarkus-api/defaults/main.yml b/roles/quarkus-api/defaults/main.yml
new file mode 100644
index 00000000..fa852968
--- /dev/null
+++ b/roles/quarkus-api/defaults/main.yml
@@ -0,0 +1,14 @@
+---
+# defaults file for quarkus api
+
+
+## Privileged user quarkus api
+#
+quarkus_api_user: quarkus_api
+quarkus_api_group: quarkus_api
+
+
+# Directories
+#
+quarkus_api_root_dir: /opt/quarkus-api
+quarkus_api_logs_dir: /var/log/quarkus-api
diff --git a/roles/quarkus-api/handlers/main.yml b/roles/quarkus-api/handlers/main.yml
new file mode 100644
index 00000000..6307bac4
--- /dev/null
+++ b/roles/quarkus-api/handlers/main.yml
@@ -0,0 +1,28 @@
+---
+# handlers file for quarkus api
+
+
+- name: restart rsyslog
+ service:
+ name: rsyslog
+ state: restarted
+ enabled: true
+
+
+- name: Reload the systemd daemon
+ systemd:
+ daemon_reload: yes
+
+
+- name: quarkus api restart and enable
+ service:
+ name: "{{ quarkus_api.service_name }}"
+ state: restarted
+ enabled: true
+
+- name: Wait a few seconds for the service to wake up
+ become: no
+ wait_for:
+ timeout: 10
+ delegate_to: localhost
+
diff --git a/roles/quarkus-api/meta/main.yml b/roles/quarkus-api/meta/main.yml
new file mode 100644
index 00000000..f3b4b7f3
--- /dev/null
+++ b/roles/quarkus-api/meta/main.yml
@@ -0,0 +1,53 @@
+galaxy_info:
+ author: Anastasios Lisgaras
+ description: DevOps Engineer
+ company: GRNET
+
+ # If the issue tracker for your role is not on github, uncomment the
+ # next line and provide a value
+ # issue_tracker_url: http://example.com/issue/tracker
+
+ # Choose a valid license ID from https://spdx.org - some suggested licenses:
+ # - BSD-3-Clause (default)
+ # - MIT
+ # - GPL-2.0-or-later
+ # - GPL-3.0-only
+ # - Apache-2.0
+ # - CC-BY-4.0
+ license: license (GPL-2.0-or-later, MIT, etc)
+
+ min_ansible_version: 2.9
+
+ # If this a Container Enabled role, provide the minimum Ansible Container version.
+ # min_ansible_container_version:
+
+ #
+ # Provide a list of supported platforms, and for each platform a list of versions.
+ # If you don't wish to enumerate all versions for a particular platform, use 'all'.
+ # To view available platforms and versions (or releases), visit:
+ # https://galaxy.ansible.com/api/v1/platforms/
+ #
+ # platforms:
+ # - name: Fedora
+ # versions:
+ # - all
+ # - 25
+ # - name: SomePlatform
+ # versions:
+ # - all
+ # - 1.0
+ # - 7
+ # - 99.99
+
+ galaxy_tags: []
+ # List tags for your role here, one per line. A tag is a keyword that describes
+ # and categorizes the role. Users find roles by searching for tags. Be sure to
+ # remove the '[]' above, if you add tags to this list.
+ #
+ # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
+ # Maximum 20 tags per role.
+
+dependencies: []
+ # List your role dependencies here, one per line. Be sure to remove the '[]' above,
+ # if you add dependencies to this list.
+
diff --git a/roles/quarkus-api/tasks/main.yml b/roles/quarkus-api/tasks/main.yml
new file mode 100644
index 00000000..8b3ddd8c
--- /dev/null
+++ b/roles/quarkus-api/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+# tasks file for accounting
+
+- include: "{{task}}.yml"
diff --git a/roles/quarkus-api/tasks/quarkus-api.yml b/roles/quarkus-api/tasks/quarkus-api.yml
new file mode 100644
index 00000000..1c2982e5
--- /dev/null
+++ b/roles/quarkus-api/tasks/quarkus-api.yml
@@ -0,0 +1,181 @@
+---
+# tasks file for quarkus api installation
+
+
+- name: Ensure group "{{ quarkus_api_group }}" exists
+ group:
+ name: "{{ quarkus_api_group }}"
+ state: present
+ tags:
+ - quarkus-api
+ - quarkus-api-user
+
+- name: Add user "{{ quarkus_api_user }}"
+ user:
+ name: "{{ quarkus_api_user }}"
+ groups: "{{ quarkus_api_group }}"
+ append: yes
+ create_home: no
+ shell: /sbin/nologin
+ comment: quarkus-api nologin user
+ tags:
+ - quarkus-api
+ - quarkus-api-user
+
+
+- name: Install Java 11
+ yum:
+ name: "{{ packages }}"
+ state: latest
+ vars:
+ packages:
+ - java-11-openjdk
+ - java-11-openjdk-devel
+ tags:
+ - quarkus-api
+ - quarkus-api-packages
+ - quarkus-api-java
+ - quarkus-api-maven
+
+- name: Create systemd file for quarkus api
+ template:
+ src: quarkus_api.service.j2
+ dest: /etc/systemd/system/{{ quarkus_api.service_name }}
+ owner: root
+ group: root
+ mode: '0644'
+ notify:
+ - Reload the systemd daemon
+ - quarkus api restart and enable
+ - Wait a few seconds for the service to wake up
+ tags:
+ - quarkus-api
+ - quarkus-api-update
+ - quarkus-api-service_file
+
+
+- name: "Create {{ quarkus_api_root_dir }} directory if it does not exist"
+ file:
+ path: "{{ item }}"
+ state: directory
+ owner: "{{ quarkus_api_user }}"
+ group: "{{ quarkus_api_group }}"
+ mode: '0755'
+ loop:
+ - "{{ quarkus_api_root_dir }}"
+ tags:
+ - quarkus-api
+ - quarkus-api-directories
+
+- name: "Create quarkus api logs directory if it doesn't exist"
+ file:
+ path: "{{ quarkus_api_logs_dir }}"
+ state: directory
+ owner: root
+ group: root
+ mode: '0700'
+ tags:
+ - quarkus-api
+ - quarkus-api-directories
+
+- name: Create additional directories if they do not exist
+ file:
+ path: "{{ item.directory }}"
+ state: directory
+ owner: "{{ quarkus_api_user }}"
+ group: "{{ quarkus_api_group }}"
+ mode: '0755'
+ with_items: "{{ files }}"
+ when: files is defined
+ tags:
+ - quarkus-api
+ - quarkus-api-directories
+
+- name: Find the artifact of the last successful build
+ uri:
+ url: https://{{ jenkins.host }}/job/{{ jenkins.job }}/job/{{ jenkins.repository }}/job/{{ jenkins.branch }}/lastSuccessfulBuild/api/json
+ user: "{{ jenkins.user }}"
+ password: "{{ jenkins.password }}"
+ method: GET
+ force_basic_auth: yes
+ status_code: 200
+ register: _jenkins_results
+ tags:
+ - quarkus-api
+ - quarkus-api-jenkins
+ - quarkus-api-jar
+ - quarkus-api-update
+
+- name: Download the latest Jenkins artifact
+ get_url:
+ url: https://{{ jenkins.host }}/job/{{ jenkins.job }}/job/{{ jenkins.repository }}/job/{{ jenkins.branch }}/lastSuccessfulBuild/artifact/{{ _jenkins_results.json.artifacts[0].relativePath }}
+ dest: "{{ quarkus_api_root_dir }}/{{ quarkus_api.jar_name }}"
+ username: "{{ jenkins.user }}"
+ password: "{{ jenkins.password }}"
+ force_basic_auth: yes
+ owner: "{{ quarkus_api_user }}"
+ group: "{{ quarkus_api_group }}"
+ mode: '0744'
+ backup: yes
+ notify:
+ - quarkus api restart and enable
+ - Wait a few seconds for the service to wake up
+ tags:
+ - quarkus-api
+ - quarkus-api-jar
+ - quarkus-api-update
+
+- name: Download config files.
+ get_url:
+ url: "{{ item.1 }}"
+ dest: "{{ item.0.directory }}"
+ with_subelements:
+ - "{{ files }}"
+ - url
+ when: files is defined
+ tags:
+ - quarkus-api
+ - quarkus-api-config
+ - quarkus-api-update
+
+- name: Recursively change ownership of the quarkus api directories
+ file:
+ path: "{{ item }}"
+ state: directory
+ recurse: yes
+ owner: "{{ quarkus_api_user }}"
+ group: "{{ quarkus_api_group }}"
+ loop:
+ - "{{ quarkus_api_root_dir }}"
+ tags:
+ - quarkus-api
+ - quarkus-api-directories
+ - quarkus-api-update
+
+
+- name: Create rsyslog filter for quarkus api logs
+ template:
+ src: etc/rsyslog.d/71_quarkus_api.conf.j2
+ dest: /etc/rsyslog.d/71_quarkus_api.conf
+ backup: yes
+ owner: root
+ group: root
+ mode: '0644'
+ notify:
+ - restart rsyslog
+ tags:
+ - quarkus-api
+ - quarkus-api-logs
+ - quarkus-api-rsyslog
+
+
+- meta: flush_handlers
+
+
+- name: More about quarkus api.
+ debug:
+ msg:
+ - "{{ quarkus_api.repo_url }}"
+ tags:
+ - quarkus-api
+ - quarkus-api-check
diff --git a/roles/quarkus-api/templates/etc/rsyslog.d/71_quarkus_api.conf.j2 b/roles/quarkus-api/templates/etc/rsyslog.d/71_quarkus_api.conf.j2
new file mode 100644
index 00000000..3d2e1769
--- /dev/null
+++ b/roles/quarkus-api/templates/etc/rsyslog.d/71_quarkus_api.conf.j2
@@ -0,0 +1,53 @@
+# {{ ansible_managed }}
+
+
+# quarkus api templates
+template(name="quarkus-logs" type="string" string="/var/log/quarkus-api/{{ quarkus_api.log +'.log'}}")
+
+# Local logs
+if ($programname contains "{{ quarkus_api.log }}") then {
+ action(type="omfile"
+ name="{{ quarkus_api.log }}"
+ dynaFile="{{ quarkus_api.log + '-logs' }}"
+ queue.type="LinkedList"
+ queue.filename="queue_quarkus_api_backend"
+ queue.size="100000"
+ action.resumeRetryCount="-1"
+ queue.saveonshutdown="on"
+ )
+ & stop
+}
+
+
+# Send quarkus api logs.
+## https://www.rsyslog.com/doc/master/configuration/modules/imfile.html
+## https://www.rsyslog.com/doc/master/configuration/actions.html
+## https://www.rsyslog.com/doc/master/configuration/templates.html
+## https://www.rsyslog.com/doc/master/concepts/queues.html
+## https://www.rsyslog.com/doc/master/rainerscript/queue_parameters.html
+
+
+ruleset(name="fwdquarkusapitocentrallog"){
+ action(type="omfwd"
+ name="{{ quarkus_api.log }}"
+ template="RSYSLOG_TraditionalForwardFormat"
+ queue.type="LinkedList" # In Memory Queue
+ queue.filename="fwd_q_cat_api" # File name to be used for the queue files.
+ queue.size="100000" # The maximum size of the queue in number of messages.
+ action.resumeRetryCount="-1" # Sets how often an action is retried before it is considered to have failed. Failed actions discard messages. (-1 means eternal)
+ queue.saveonshutdown="on" # This parameter specifies if data should be saved at shutdown.
+ Target="{{ central_rsyslog.hostname }}" Port="{{ central_rsyslog.port }}" Protocol="tcp"
+ StreamDriver="gtls"
+ StreamDriverMode="1" # run driver in TLS-only mode
+ StreamDriverAuthMode="x509/name"
+ StreamDriverPermittedPeers="{{ central_rsyslog.permittedPeers }}"
+ )
+}
+
+input(type="imfile"
+ File="/var/log/{{ quarkus_api.log }}/*log"
+ Tag="{{ quarkus_api.log + ':'}}"
+ ruleset="fwdquarkusapitocentrallog"
+)
+
+
diff --git a/roles/quarkus-api/templates/quarkus_api.service.j2 b/roles/quarkus-api/templates/quarkus_api.service.j2
new file mode 100644
index 00000000..27be35c5
--- /dev/null
+++ b/roles/quarkus-api/templates/quarkus_api.service.j2
@@ -0,0 +1,23 @@
+[Unit]
+Description={{ quarkus_api.description }}
+After=network.target remote-fs.target nss-lookup.target
+Documentation={{ quarkus_api.doc_url }}
+
+[Service]
+#Type=simple
+User={{ quarkus_api_user }}
+Group={{ quarkus_api_group }}
+WorkingDirectory={{ quarkus_api_root_dir }}
+ExecStart=/usr/bin/java -jar {{ quarkus_api_root_dir }}/{{ quarkus_api.jar_name }}
+SyslogIdentifier=quarkus-api
+Restart=on-failure
+RestartSec=5s
+SuccessExitStatus=143
+#KillMode=mixed
+{% for var in environment_variables -%}
+Environment="{{ var }}={{ environment_variables[var] }}"
+{% endfor %}
+
+[Install]
+WantedBy=multi-user.target
+#Alias={{ quarkus_api.service_name }}
\ No newline at end of file
diff --git a/roles/rseval/.yamllint b/roles/rseval/.yamllint
new file mode 100644
index 00000000..3a2255e4
--- /dev/null
+++ b/roles/rseval/.yamllint
@@ -0,0 +1,13 @@
+extends: default
+
+rules:
+ braces:
+ max-spaces-inside: 1
+ level: error
+ brackets:
+ max-spaces-inside: 1
+ level: error
+ line-length: disable
+ # NOTE(retr0h): Templates no longer fail this lint rule.
+ # Uncomment if running old Molecule templates.
+ # truthy: disable
diff --git a/roles/rseval/README.md b/roles/rseval/README.md
new file mode 100644
index 00000000..97de1d58
--- /dev/null
+++ b/roles/rseval/README.md
@@ -0,0 +1,43 @@
+Role Name
+=========
+
+Role to setup rseval web service
+
+
+Requirements
+------------
+- OS: CentOS 7.x
+- certificate already issued
+- selinux disabled
+
+
+Role Variables
+--------------
+
+
+Dependencies
+------------
+
+Dependent on mongo role using repo_mongo_4x: true
+
+Example Playbook
+----------------
+
+Including an example of how to use your role (for instance, with variables
+passed in as parameters) is always nice for users too:
+
+- hosts: rseval
+ become: yes
+ roles:
+ - { role: mongodb }
+ - { role: rseval, task: deploy, tags: rseval }
+
+License
+-------
+
+Apache 2
+
+Author Information
+------------------
+
+GRNET
diff --git a/roles/rseval/defaults/main.yml b/roles/rseval/defaults/main.yml
new file mode 100644
index 00000000..133683a0
--- /dev/null
+++ b/roles/rseval/defaults/main.yml
@@ -0,0 +1,3 @@
+---
+
+streaming_jobs: []
\ No newline at end of file
diff --git a/roles/rseval/files/.env b/roles/rseval/files/.env
new file mode 100644
index 00000000..b582a9c5
--- /dev/null
+++ b/roles/rseval/files/.env
@@ -0,0 +1,6 @@
+RSEVAL_MONGO_URI=mongodb://localhost:27017/rsmetrics
+RSEVAL_METRIC_DESC_DIR=/var/www/rseval/data/metric_descriptions
+RSEVAL_SUPERVISOR_RPC_SERVER=http://localhost:9001/RPC2
+RSEVAL_STREAM_USER_ACTIONS_JOBNAME=stream-user-actions
+RSEVAL_STREAM_MP_DB_EVENTS_JOBNAME=stream-mp-db-events
+RSEVAL_STREAM_RECOMMENDATIONS_JOBNAME=stream-recommendations
diff --git a/roles/rseval/files/00-wsgi.conf b/roles/rseval/files/00-wsgi.conf
new file mode 100644
index 00000000..6760e314
--- /dev/null
+++ b/roles/rseval/files/00-wsgi.conf
@@ -0,0 +1 @@
+LoadModule wsgi_module /opt/rh/rh-python38/root/usr/lib64/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so
\ No newline at end of file
diff --git a/roles/rseval/files/app.wsgi b/roles/rseval/files/app.wsgi
new file mode 100644
index 00000000..a71884cd
--- /dev/null
+++ b/roles/rseval/files/app.wsgi
@@ -0,0 +1,9 @@
+import sys
+sys.path.insert(0, '/var/www/rseval')
+
+import os
+from dotenv import load_dotenv
+dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
+load_dotenv(dotenv_path)
+
+from app import app as application
\ No newline at end of file
diff --git a/roles/rseval/files/enable-python38.sh b/roles/rseval/files/enable-python38.sh
new file mode 100644
index 00000000..ae6983bb
--- /dev/null
+++ b/roles/rseval/files/enable-python38.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+source scl_source enable rh-python38
\ No newline at end of file
diff --git a/roles/rseval/files/supervisor.service b/roles/rseval/files/supervisor.service
new file mode 100644
index 00000000..2b086b7c
--- /dev/null
+++ b/roles/rseval/files/supervisor.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Process Monitoring and Control Daemon
+After=rc-local.service nss-user-lookup.target
+[Service]
+Type=forking
+ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/roles/rseval/handlers/main.yml b/roles/rseval/handlers/main.yml
new file mode 100644
index 00000000..cfda0f4d
--- /dev/null
+++ b/roles/rseval/handlers/main.yml
@@ -0,0 +1,12 @@
+---
+- name: restart httpd
+ service: name=httpd state=restarted enabled=yes
+
+- name: reload firewalld
+ shell: firewall-cmd --reload
+
+- name: reload systemctl daemon
+ shell: systemctl daemon-reload
+
+- name: restart supervisor
+ shell: systemctl restart supervisor
diff --git a/roles/rseval/meta/main.yml b/roles/rseval/meta/main.yml
new file mode 100644
index 00000000..ba43fdd2
--- /dev/null
+++ b/roles/rseval/meta/main.yml
@@ -0,0 +1,58 @@
+---
+galaxy_info:
+ author: your name
+ description: your description
+ company: your company (optional)
+
+ # If the issue tracker for your role is not on github, uncomment the
+ # next line and provide a value
+ # issue_tracker_url: http://example.com/issue/tracker
+
+ # Some suggested licenses:
+ # - BSD (default)
+ # - MIT
+ # - GPLv2
+ # - GPLv3
+ # - Apache
+ # - CC-BY
+ license: license (GPLv2, CC-BY, etc)
+
+ min_ansible_version: 1.2
+
+ # If this a Container Enabled role, provide the minimum Ansible Container version.
+ # min_ansible_container_version:
+
+ # Optionally specify the branch Galaxy will use when accessing the GitHub
+ # repo for this role. During role install, if no tags are available,
+ # Galaxy will use this branch. During import Galaxy will access files on
+ # this branch. If Travis integration is configured, only notifications for this
+ # branch will be accepted. Otherwise, in all cases, the repo's default branch
+ # (usually master) will be used.
+ # github_branch:
+
+ #
+ # platforms is a list of platforms, and each platform has a name and a list of versions.
+ #
+ # platforms:
+ # - name: Fedora
+ # versions:
+ # - all
+ # - 25
+ # - name: SomePlatform
+ # versions:
+ # - all
+ # - 1.0
+ # - 7
+ # - 99.99
+
+ galaxy_tags: []
+ # List tags for your role here, one per line. A tag is a keyword that describes
+ # and categorizes the role. Users find roles by searching for tags. Be sure to
+ # remove the '[]' above, if you add tags to this list.
+ #
+ # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
+ # Maximum 20 tags per role.
+
+dependencies: []
+# List your role dependencies here, one per line. Be sure to remove the '[]' above,
+# if you add dependencies to this list.
diff --git a/roles/rseval/molecule/default/Dockerfile.j2 b/roles/rseval/molecule/default/Dockerfile.j2
new file mode 100644
index 00000000..19692c20
--- /dev/null
+++ b/roles/rseval/molecule/default/Dockerfile.j2
@@ -0,0 +1,14 @@
+# Molecule managed
+
+{% if item.registry is defined %}
+FROM {{ item.registry.url }}/{{ item.image }}
+{% else %}
+FROM {{ item.image }}
+{% endif %}
+
+RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
+ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
+ elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
+ elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
+ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
+ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
diff --git a/roles/rseval/molecule/default/INSTALL.rst b/roles/rseval/molecule/default/INSTALL.rst
new file mode 100644
index 00000000..3904805e
--- /dev/null
+++ b/roles/rseval/molecule/default/INSTALL.rst
@@ -0,0 +1,26 @@
+*******
+Docker driver installation guide
+*******
+
+Requirements
+============
+
+* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
+* Docker Engine
+* docker-py
+* docker
+
+Install
+=======
+
+Ansible < 2.6
+
+.. code-block:: bash
+
+ $ sudo pip install docker-py
+
+Ansible >= 2.6
+
+.. code-block:: bash
+
+ $ sudo pip install docker
diff --git a/roles/rseval/molecule/default/molecule.yml b/roles/rseval/molecule/default/molecule.yml
new file mode 100644
index 00000000..f5e3b111
--- /dev/null
+++ b/roles/rseval/molecule/default/molecule.yml
@@ -0,0 +1,20 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: instance
+ image: centos:7
+provisioner:
+ name: ansible
+ lint:
+ name: ansible-lint
+scenario:
+ name: default
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
diff --git a/roles/rseval/molecule/default/playbook.yml b/roles/rseval/molecule/default/playbook.yml
new file mode 100644
index 00000000..45aebc3b
--- /dev/null
+++ b/roles/rseval/molecule/default/playbook.yml
@@ -0,0 +1,5 @@
+---
+- name: Converge
+ hosts: all
+ roles:
+ - role: rseval
diff --git a/roles/rseval/molecule/default/tests/test_default.py b/roles/rseval/molecule/default/tests/test_default.py
new file mode 100644
index 00000000..eedd64a1
--- /dev/null
+++ b/roles/rseval/molecule/default/tests/test_default.py
@@ -0,0 +1,14 @@
+import os
+
+import testinfra.utils.ansible_runner
+
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
+
+
+def test_hosts_file(host):
+ f = host.file('/etc/hosts')
+
+ assert f.exists
+ assert f.user == 'root'
+ assert f.group == 'root'
diff --git a/roles/rseval/molecule/default/tests/test_default.pyc b/roles/rseval/molecule/default/tests/test_default.pyc
new file mode 100644
index 00000000..a4205e39
Binary files /dev/null and b/roles/rseval/molecule/default/tests/test_default.pyc differ
diff --git a/roles/rseval/tasks/deploy.yml b/roles/rseval/tasks/deploy.yml
new file mode 100644
index 00000000..5a9a4710
--- /dev/null
+++ b/roles/rseval/tasks/deploy.yml
@@ -0,0 +1,214 @@
+---
+
+- name: Enable scl
+ yum:
+ name: '{{ item }}'
+ loop:
+ - centos-release-scl
+ - scl-utils
+ - scl-utils-build
+
+- name: Install all needed packages including python3
+ yum:
+ name: '{{ item }}'
+ state: present
+ loop:
+ - rh-python38
+ - rh-python38-python-devel
+ - rh-python38-python-mod_wsgi
+ - httpd
+ tags: rseval
+
+- name: copy enable python script to profile.d
+ copy:
+ src: enable-python38.sh
+ dest: /etc/profile.d/enable-python38.sh
+
+- name: Enable python 3.8 by resetting ssh connection
+ meta: reset_connection
+
+- name: install the 'Development tools' package group
+ yum:
+ name: "@Development tools"
+ state: present
+
+- name: download rseval
+ tags: rseval
+ get_url:
+ url: 'https://github.com/argoeu/eosc-recommender-metrics/tarball/devel'
+ dest: /tmp/rseval.tar.gz
+
+- name: create folder /tmp/rseval
+ file:
+ path: /tmp/rseval
+ owner: root
+ group: root
+ mode: '0774'
+ state: directory
+
+- name: create folder /opt/rseval
+ file:
+ path: /opt/rseval
+ owner: root
+ group: root
+ mode: '0774'
+ state: directory
+
+
+- name: extract rseval
+ unarchive:
+ src: /tmp/rseval.tar.gz
+ dest: /tmp/rseval
+ extra_opts: [--strip-components=1]
+ remote_src: yes
+
+- name: Install Virtualenv
+ pip:
+ name: virtualenv
+ state: present
+ executable: pip3.8
+ tags: rseval
+
+- name: create virtualenv with specified requirements
+ pip:
+ requirements: /tmp/rseval/requirements.txt
+ virtualenv: /opt/rseval/venv
+
+- name: change ownership of virtualenv
+ file: dest=/opt/rseval owner=apache group=apache recurse=yes
+
+- name: Install Supervisor
+ pip:
+ name: supervisor
+ state: present
+ executable: pip3.8
+ tags: rseval
+ notify: restart supervisor
+
+- name: Create supervisor symlink
+ file:
+ src: "/opt/rh/rh-python38/root/usr/local/bin/supervisord"
+ dest: "/usr/bin/supervisord"
+ state: link
+ notify: restart supervisor
+
+- name: copy supervisor.service file
+ copy:
+ src: supervisor.service
+ dest: /etc/systemd/system/supervisor.service
+ notify:
+ - reload systemctl daemon
+ - restart supervisor
+
+- name: configure supervisor
+ template:
+ src: supervisord.conf.j2
+ dest: /etc/supervisord.conf
+ mode: 0444
+ notify: restart supervisor
+
+- name: copy supervisor.service file
+ copy:
+ src: supervisor.service
+ dest: /etc/systemd/system/supervisor.service
+ notify:
+ - reload systemctl daemon
+ - restart supervisor
+
+- name: copy rseval to /opt/rseval
+ copy:
+ src: /tmp/rseval/
+ dest: /opt/rseval/
+ remote_src: true
+
+- name: create templates folder
+ file:
+ path: /var/www/rseval/templates/
+ state: directory
+
+- name: copy templates
+ copy:
+ src: /tmp/rseval/webservice/templates/
+ dest: /var/www/rseval/templates/
+ remote_src: true
+
+- name: copy webservice app.py file
+ copy:
+ src: /tmp/rseval/webservice/app.py
+ dest: /var/www/rseval/app.py
+ remote_src: true
+ notify: restart httpd
+
+- name: copy .env
+ copy:
+ src: .env
+ dest: /var/www/rseval/.env
+ notify: restart httpd
+
+- name: copy app.wsgi
+ copy:
+ src: app.wsgi
+ dest: /var/www/rseval/app.wsgi
+ notify: restart httpd
+
+- name: create folder /var/www/rseval/data
+ file:
+ path: /var/www/rseval/data
+ owner: apache
+ group: apache
+ mode: '0774'
+ state: directory
+ notify: restart httpd
+
+- name: copy metric_descriptions
+ copy:
+ src: /tmp/rseval/metric_descriptions/
+ dest: /var/www/rseval/data/metric_descriptions
+ remote_src: true
+ with_fileglob: "*.yml"
+
+- name: Set template folder in app.py
+ lineinfile:
+ path: /var/www/rseval/app.py
+ regexp: '^app.*Flask.*RSEVAL'
+ line: "app = Flask('RSEVAL',template_folder='/var/www/rseval/templates', static_folder='/var/www/rseval/static')"
+ notify: restart httpd
+
+- name: create folder /var/run/default
+ file:
+ path: /var/www/default
+ owner: apache
+ group: apache
+ mode: '0774'
+ state: directory
+
+- name: create folder /var/logs/rseval-stream
+ file:
+ path: /var/log/rseval-stream/
+ owner: root
+ group: root
+ mode: '0775'
+ state: directory
+
+
+- name: enable and start supervisor
+ systemd:
+ name: supervisor
+ enabled: yes
+ state: started
+ masked: no
+
+- name: Remove document root from virtualhost file
+ lineinfile:
+ path: /etc/httpd/conf.d/{{inventory_hostname}}.conf
+ regexp: '^DocumentRoot'
+ line: ''
+ notify: restart httpd
+
+- name: copy load mod-wsgi
+ copy:
+ src: 00-wsgi.conf
+ dest: /etc/httpd/conf.modules.d
+ notify: restart httpd
+
+# vim: syntax=yaml ts=4 sw=4 sts=4 sr noet
diff --git a/roles/rseval/tasks/main.yml b/roles/rseval/tasks/main.yml
new file mode 100644
index 00000000..61776806
--- /dev/null
+++ b/roles/rseval/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+# tasks file for rseval
+
+- include: '{{task}}.yml'
diff --git a/roles/rseval/templates/supervisord.conf.j2 b/roles/rseval/templates/supervisord.conf.j2
new file mode 100644
index 00000000..c8ade39f
--- /dev/null
+++ b/roles/rseval/templates/supervisord.conf.j2
@@ -0,0 +1,181 @@
+; Sample supervisor config file.
+;
+; For more information on the config file, please see:
+; http://supervisord.org/configuration.html
+;
+; Notes:
+; - Shell expansion ("~" or "$HOME") is not supported. Environment
+; variables can be expanded using this syntax: "%(ENV_HOME)s".
+; - Quotes around values are not supported, except in the case of
+; the environment= options as shown below.
+; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
+; - Command will be truncated if it looks like a config file comment, e.g.
+; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
+;
+; Warning:
+; Paths throughout this example file use /tmp because it is available on most
+; systems. You will likely need to change these to locations more appropriate
+; for your system. Some systems periodically delete older files in /tmp.
+; Notably, if the socket file defined in the [unix_http_server] section below
+; is deleted, supervisorctl will be unable to connect to supervisord.
+
+[unix_http_server]
+file=/tmp/supervisor.sock ; the path to the socket file
+;chmod=0700 ; socket file mode (default 0700)
+;chown=nobody:nogroup ; socket file uid:gid owner
+;username=user ; default is no username (open server)
+;password=123 ; default is no password (open server)
+
+; Security Warning:
+; The inet HTTP server is not enabled by default. The inet HTTP server is
+; enabled by uncommenting the [inet_http_server] section below. The inet
+; HTTP server is intended for use within a trusted environment only. It
+; should only be bound to localhost or only accessible from within an
+; isolated, trusted network. The inet HTTP server does not support any
+; form of encryption. The inet HTTP server does not use authentication
+; by default (see the username= and password= options to add authentication).
+; Never expose the inet HTTP server to the public internet.
+
+[inet_http_server] ; inet (TCP) server disabled by default
+port=127.0.0.1:9001 ; ip_address:port specifier, *:port for all iface
+;username=user ; default is no username (open server)
+;password=123 ; default is no password (open server)
+
+[supervisord]
+logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
+logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
+logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
+loglevel=info ; log level; default info; others: debug,warn,trace
+pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
+nodaemon=false ; start in foreground if true; default false
+silent=false ; no logs to stdout if true; default false
+minfds=1024 ; min. avail startup file descriptors; default 1024
+minprocs=200 ; min. avail process descriptors;default 200
+;umask=022 ; process file creation umask; default 022
+;user=supervisord ; setuid to this UNIX account at startup; recommended if root
+;identifier=supervisor ; supervisord identifier, default is 'supervisor'
+;directory=/tmp ; default is not to cd during start
+;nocleanup=true ; don't clean up tempfiles at start; default false
+;childlogdir=/tmp ; 'AUTO' child log dir, default $TEMP
+;environment=KEY="value" ; key value pairs to add to environment
+;strip_ansi=false ; strip ansi escape codes in logs; def. false
+
+; The rpcinterface:supervisor section must remain in the config file for
+; RPC (supervisorctl/web interface) to work. Additional interfaces may be
+; added by defining them in separate [rpcinterface:x] sections.
+
+[rpcinterface:supervisor]
+supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
+
+; The supervisorctl section configures how supervisorctl will connect to
+; supervisord. configure it match the settings in either the unix_http_server
+; or inet_http_server section.
+
+[supervisorctl]
+serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
+;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
+;username=chris ; should be same as in [*_http_server] if set
+;password=123 ; should be same as in [*_http_server] if set
+;prompt=mysupervisor ; cmd line prompt (default "supervisor")
+;history_file=~/.sc_history ; use readline history if available
+
+; The sample program section below shows all possible program subsection values.
+; Create one or more 'real' program: sections to be able to control them under
+; supervisor.
+
+;[program:theprogramname]
+;command=/bin/cat ; the program (relative uses PATH, can take args)
+;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
+;numprocs=1 ; number of processes copies to start (def 1)
+;directory=/tmp ; directory to cwd to before exec (def no cwd)
+;umask=022 ; umask for process (default None)
+;priority=999 ; the relative start priority (default 999)
+;autostart=true ; start at supervisord start (default: true)
+;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
+;startretries=3 ; max # of serial start failures when starting (default 3)
+;autorestart=unexpected ; when to restart if exited after running (def: unexpected)
+;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0)
+;stopsignal=QUIT ; signal used to kill process (default TERM)
+;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
+;stopasgroup=false ; send stop signal to the UNIX process group (default false)
+;killasgroup=false ; SIGKILL the UNIX process group (def false)
+;user=chrism ; setuid to this UNIX account to run the program
+;redirect_stderr=true ; redirect proc stderr to stdout (default false)
+;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
+;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
+;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
+;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
+;stdout_events_enabled=false ; emit events on stdout writes (default false)
+;stdout_syslog=false ; send stdout to syslog with process name (default false)
+;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
+;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
+;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
+;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
+;stderr_events_enabled=false ; emit events on stderr writes (default false)
+;stderr_syslog=false ; send stderr to syslog with process name (default false)
+;environment=A="1",B="2" ; process environment additions (def no adds)
+;serverurl=AUTO ; override serverurl computation (childutils)
+
+; The sample eventlistener section below shows all possible eventlistener
+; subsection values. Create one or more 'real' eventlistener: sections to be
+; able to handle event notifications sent by supervisord.
+
+;[eventlistener:theeventlistenername]
+;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
+;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
+;numprocs=1 ; number of processes copies to start (def 1)
+;events=EVENT ; event notif. types to subscribe to (req'd)
+;buffer_size=10 ; event buffer queue size (default 10)
+;directory=/tmp ; directory to cwd to before exec (def no cwd)
+;umask=022 ; umask for process (default None)
+;priority=-1 ; the relative start priority (default -1)
+;autostart=true ; start at supervisord start (default: true)
+;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
+;startretries=3 ; max # of serial start failures when starting (default 3)
+;autorestart=unexpected ; autorestart if exited after running (def: unexpected)
+;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0)
+;stopsignal=QUIT ; signal used to kill process (default TERM)
+;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
+;stopasgroup=false ; send stop signal to the UNIX process group (default false)
+;killasgroup=false ; SIGKILL the UNIX process group (def false)
+;user=chrism ; setuid to this UNIX account to run the program
+;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners
+;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
+;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
+;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
+;stdout_events_enabled=false ; emit events on stdout writes (default false)
+;stdout_syslog=false ; send stdout to syslog with process name (default false)
+;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
+;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
+;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
+;stderr_events_enabled=false ; emit events on stderr writes (default false)
+;stderr_syslog=false ; send stderr to syslog with process name (default false)
+;environment=A="1",B="2" ; process environment additions
+;serverurl=AUTO ; override serverurl computation (childutils)
+
+; The sample group section below shows all possible group values. Create one
+; or more 'real' group: sections to create "heterogeneous" process groups.
+
+;[group:thegroupname]
+;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
+;priority=999 ; the relative start priority (default 999)
+
+; The [include] section can just contain the "files" setting. This
+; setting can list multiple files (separated by whitespace or
+; newlines). It can also contain wildcards. The filenames are
+; interpreted as relative to this file. Included files *cannot*
+; include files themselves.
+
+;[include]
+;files = relative/directory/*.ini
+
+{% for item in streaming_jobs %}
+
+[program:{{item.name}}]
+command={{item.command}}
+autostart=false
+autorestart=true
+stderr_logfile=/var/log/rseval-stream/{{item.name}}.err.log
+stdout_logfile=/var/log/rseval-stream/{{item.name}}.out.log
+
+{% endfor %}
diff --git a/roles/rseval/vars/main.yml b/roles/rseval/vars/main.yml
new file mode 100644
index 00000000..ae894940
--- /dev/null
+++ b/roles/rseval/vars/main.yml
@@ -0,0 +1,2 @@
+---
+# vars file for rseval
diff --git a/roles/swagger/README.md b/roles/swagger/README.md
index 94ff275b..84a922a3 100644
--- a/roles/swagger/README.md
+++ b/roles/swagger/README.md
@@ -24,7 +24,7 @@ Dependencies
Uses Httpd and Commons roles.
Following variables should be set-up for swagger http access (from role: commons, task: firewall)
```yaml
-firewall_services_zones:
+firewall_services_zones_extra:
- service: https
zone: public
- service: http
diff --git a/roles/swagger/files/var/www/html/index.html b/roles/swagger/files/var/www/html/index.html
index bddfc1e7..8a1a09a9 100644
--- a/roles/swagger/files/var/www/html/index.html
+++ b/roles/swagger/files/var/www/html/index.html
@@ -1,8 +1,8 @@
-
+
ARGO Availability and Reliability Monitoring - ARGO Documentation
-
+
@@ -10,12 +10,12 @@
-
+
-
+
-
+
@@ -42,12 +42,11 @@
-
+
@@ -71,13 +70,13 @@ ARGO APIs
-
+
Swagger UI with access to the ARGO web api.
-
+
Swagger UI with access to the ARGO Messaging api.
@@ -124,7 +123,7 @@
Open development