Skip to content

Commit

Permalink
ansible installation [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Limmen committed Mar 11, 2024
1 parent 31db1c1 commit 79cb15b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 58 deletions.
1 change: 1 addition & 0 deletions ansible/group_vars/all/variables.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
user: "kim"
csle_git_repo_url: "https://github.com/Limmen/csle"
leader_ip: "34.142.42.219"
leader_public_ip: "34.142.42.219"
nginx_content_name: "nginx_configuration_content.txt"
web_port: 7777
postgres_version: "15"
Expand Down
10 changes: 9 additions & 1 deletion ansible/install_management_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
lineinfile:
path: "/home/{{ user }}/csle/management-system/csle-mgmt-webapp/src/components/Common/serverIp.js"
regexp: '^const serverIp ='
line: 'const serverIp = "{{ ansible_host }}";'
line: 'const serverIp = "{{ leader_public_ip }}";'

- name: Modify serverPort.js file
lineinfile:
Expand All @@ -175,3 +175,11 @@
path: "/home/{{ user }}/.bashrc"
line: "export PATH=/home/{{ user }}/csle/management-system/node_exporter/:$PATH"
when: not node_exporter_path_configured

- name: CSLE init
shell: "source /home/{{ user }}/anaconda3/bin/activate {{ conda_environment_name }} && csle init"
args:
executable: /bin/bash
environment:
CSLE_HOME: "/home/{{ user }}/csle"
register: CSLE_init_output
10 changes: 1 addition & 9 deletions ansible/install_management_system_leader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,4 @@
args:
executable: /bin/bash
ignore_errors: true
when: not pg_admin_running

- name: CSLE init
shell: "source /home/{{ user }}/anaconda3/bin/activate {{ conda_environment_name }} && csle init"
args:
executable: /bin/bash
environment:
CSLE_HOME: "/home/{{ user }}/csle"
register: CSLE_init_output
when: not pg_admin_running
12 changes: 12 additions & 0 deletions ansible/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

csle stop clustermanager
sleep 2
csle start clustermanager
sleep 2
csle start cadvisor
csle start grafana
csle start prometheus
csle start node_exporter
csle start flask
csle start nginx
50 changes: 2 additions & 48 deletions ansible/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,7 @@

- hosts: all

vars:
cadvisor: "cadvisor"
grafana: "grafana"

tasks:

- name: List running docker containers
become: true
shell: "docker ps"
args:
executable: /bin/bash
register: docker_containers_list
changed_when: false

- name: Restart clustermanager
shell: "source /home/{{ user }}/.bashrc; source /home/{{ user }}/anaconda3/bin/activate {{ conda_environment_name }} && csle stop clustermanager && sleep 5; csle start clustermanager && sleep 10"
args:
executable: /bin/bash
environment:
CSLE_HOME: "/home/{{ user }}/csle"
register: CSLE_init_output

- name: Check if cadvisor is running
set_fact:
cadvisor_running: "{{ cadvisor in docker_containers_list.stdout }}"

- name: Start cadvisor
become: true
shell: "docker run -dt --volume=/:/rootfs:ro --volume=/var/run:/var/run:ro --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/dev/disk/:/dev/disk:ro --publish=8080:8080 --name=cadvisor gcr.io/cadvisor/cadvisor"
args:
executable: /bin/bash
when: not cadvisor_running

- name: Check if grafana is running
set_fact:
grafana_running: "{{ grafana in docker_containers_list.stdout }}"

- name: Start grafana
become: true
shell: "docker run -d -p 3000:3000 --name grafana grafana/grafana"
args:
executable: /bin/bash
when: not grafana_running

- name: CSLE start
shell: "source /home/{{ user }}/anaconda3/bin/activate {{ conda_environment_name }}; csle start nodeexporter; csle start prometheus; csle start flask; csle start nginx"
args:
executable: /bin/bash
environment:
CSLE_HOME: "/home/{{ user }}/csle"
- name: Start services
script: ./start.sh

0 comments on commit 79cb15b

Please sign in to comment.