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 f4095dc commit 766cf66
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 59 deletions.
8 changes: 8 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ This folder contains configuration files and ansible playbooks for installing CS

Ansible documentation can be found at [https://docs.ansible.com/](https://docs.ansible.com/).

## Network topology for the installation

The network topology for a typical Ansible installation is shown in the figure below -- a user host runs Ansible and installs CSLE on a cluster of remote hosts.

<p align="center">
<img src="ansible_topology.png" width="600">
</p>

## Installing Ansible

Ansible can be installed by running the command:
Expand Down
Binary file added ansible/ansible_topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions ansible/group_vars/all/variables.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
user: "kim"
csle_git_repo_url: "https://github.com/Limmen/csle"
leader_ip: "172.31.212.82"
leader_ip: "164.92.81.86"
nginx_content_name: "nginx_configuration_content.txt"
web_port: 7777
postgres_version: "15"
Expand All @@ -10,7 +10,6 @@ anaconda_url: "https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.
anaconda_install_script: "Anaconda3-2022.10-Linux-x86_64.sh"
conda_environment_name: "base"
python_version: "3.9"
trusted_subnetwork: "172.31.212.0/24"
postgres_password: "postgres"
citus_port: 5432
csle_config:
Expand Down Expand Up @@ -57,15 +56,15 @@ csle_config:
postgresql_log_dir: "/var/log/postgresql/"
nginx_log_dir: "/var/log/nginx/"
default_log_dir: "/tmp/csle/"
metastore_ip: "172.31.212.82"
metastore_ip: "164.92.81.86"
metastore_user: "csle"
metastore_password: "csle"
metastore_database_name: "csle"
cluster_config:
cluster_nodes:
- ip: "172.31.212.82"
- ip: "164.92.81.86"
leader: true
cpus: 24
cpus: 4
gpus: 0
RAM: 64
RAM: 8
allow_registration: true
6 changes: 2 additions & 4 deletions ansible/install_emulation_system_leader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
executable: /bin/bash
register: docker_swarm_status
changed_when: false
ignore_errors: yes

- name: Check if the docker swarm has been initialized
set_fact:
swarm_initialized: "{{ active in docker_swarm_status.stdout }}"
swarm_initialized: "{{ docker_swarm_status.rc == 0 and active in docker_swarm_status.stdout }}"

- name: Initialize Docker Swarm
become: true
Expand All @@ -59,6 +60,3 @@
docker_swarm_join_command: "{{ docker_swarm_join_command_output.stdout | regex_search(stdout_regex, multiline=True)}}"
vars:
stdout_regex: 'docker swarm join --token (.*)'

- debug:
var: hostvars[leader_ip]['docker_swarm_join_command']
2 changes: 0 additions & 2 deletions ansible/install_management_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@
args:
executable: /bin/bash
when:
- nvm_installed.rc == 0
- npm_installed.rc == 0
- not web_app_installed.stat.exists
- not web_app_built.stat.exists
ignore_errors: true
Expand Down
43 changes: 0 additions & 43 deletions ansible/install_metastore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,49 +83,6 @@
become: true
shell: "sudo echo 'host\tall\tall\t127.0.0.0/8\ttrust' >> /etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"

# - name: Update the postgres configuration file
# become: true
# lineinfile:
# dest: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# line: |
# local all postgres trust
# local all all trust
# host all all 127.0.0.1/32 trust
# host all all ::1/128 trust
# local replication all trust
# host all all {{ trusted_subnetwork }} trust

# - name: Update local authentication method in postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# regexp: '^local\s+all\s+postgres\s+trust$'
# line: "local\tall\t\tpostgres\t\t\t\ttrust"
# state: present
#
# - name: Update 127.0.0.1 authentication method in postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# regexp: '^host\s+all\s+all\s+127.0.0.1/32\s+scram-sha-256$'
# line: "host\tall\t\tall\t\t127.0.0.1/32\t\ttrust"
# state: present
#
# - name: Update general authentication method in postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# regexp: '^host\s+all\s+all\s+::1/128\s+scram-sha-256$'
# line: "host\tall\t\tall\t\t::1/128\t\t\ttrust"
# state: present
#
# - name: Add trusted subnetwork to postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# line: "host\tall\t\tall\t\t{{ trusted_subnetwork }}\t\ttrust"
# insertafter: EOF
# state: present

- name: Restart postgres
become: true
Expand Down
2 changes: 1 addition & 1 deletion ansible/inventory
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[leader]
172.31.212.82
164.92.81.86

[worker]

8 changes: 8 additions & 0 deletions ansible/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

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:
Expand Down
2 changes: 1 addition & 1 deletion simulation-system/libs/csle-cli/src/csle_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@ def list_node_exporter() -> None:
f"ip:{node.ip}, port:{constants.COMMANDS.NODE_EXPORTER_PORT}",
bold=False)
else:
click.secho("Node exporter status: " + f" {click.style('[stopped],', fg='red')} ip:{node.ip}",
click.secho("Node exporter status: " + f" {click.style('[stopped]', fg='red')} ip:{node.ip}",
bold=False)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,8 @@ class COMMANDS:
POSTGRESQL_LOG_DIR = "/var/log/postgresql/"
NGINX_LOG_DIR = "/var/log/nginx/"
PROMETHEUS_PORT = 9090
START_PROMETHEUS = f"nohup prometheus --config.file={PROMETHEUS_CONFIG_FILE} " \
START_PROMETHEUS = f"nohup $CSLE_HOME/management-system/prometheus/prometheus " \
f"--config.file={PROMETHEUS_CONFIG_FILE} " \
"--storage.tsdb.retention.size=10GB " \
f"--storage.tsdb.retention.time=5d & > {PROMETHEUS_LOG_FILE} " \
f"&& echo $! > {PROMETHEUS_PID_FILE}"
Expand Down Expand Up @@ -952,7 +953,8 @@ class COMMANDS:
CSLE_MGMT_WEBAPP_PID_FILE = "/var/log/csle/csle_mgmt_webapp.pid"
NODE_EXPORTER_LOG_FILE = "/var/log/csle/node_exporter.log"
FLASK_LOG_FILE = "/var/log/csle/flask.log"
START_NODE_EXPORTER = f"nohup node_exporter & > {NODE_EXPORTER_LOG_FILE} && echo $! " \
START_NODE_EXPORTER = f"nohup $CSLE_HOME/management-system/node_exporter/node_exporter " \
f"& > {NODE_EXPORTER_LOG_FILE} && echo $! " \
f"> {NODE_EXPORTER_PID_FILE}"
BUILD_CSLE_MGMT_WEBAPP = f"cd ${CONFIG_FILE.CSLE_HOME_ENV_PARAM}/management-system/csle-mgmt-webapp && npm run " \
f"build"
Expand Down

0 comments on commit 766cf66

Please sign in to comment.