-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
733 additions
and
541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
--- | ||
- import_playbook: install_setup.yml | ||
- import_playbook: install_metastore.yml | ||
- import_playbook: install_metastore_leader.yml | ||
- import_playbook: install_simulation_system.yml | ||
- import_playbook: install_simulation_system_leader.yml | ||
- import_playbook: install_emulation_system.yml | ||
- import_playbook: install_emulation_system_leader.yml | ||
- import_playbook: install_emulation_system_worker.yml | ||
- import_playbook: install_management_system.yml | ||
- import_playbook: install_management_system_leader.yml | ||
- import_playbook: start.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
|
||
- hosts: leader | ||
|
||
vars: | ||
active: "Active" | ||
|
||
tasks: | ||
|
||
- name: List installed emulation environments | ||
become: yes | ||
become_method: sudo | ||
become_user: postgres | ||
community.postgresql.postgresql_query: | ||
db: csle | ||
login_user: postgres | ||
login_password: "{{ postgres_password }}" | ||
query: "SELECT id FROM emulations;" | ||
register: emulations | ||
|
||
- name: Check if the emulation environments are installed | ||
set_fact: | ||
emulation_environments_installed: "{{ emulations.rowcount > 0 }}" | ||
|
||
- name: Installing the emulation environments on the leader node | ||
shell: "source /home/{{ user }}/anaconda3/bin/activate {{ conda_environment_name }}; cd /home/{{ user }}/csle/emulation-system/envs && make install" | ||
args: | ||
executable: /bin/bash | ||
when: not emulation_environments_installed | ||
|
||
- name: List docker swarm status | ||
become: true | ||
shell: "docker node ls" | ||
args: | ||
executable: /bin/bash | ||
register: docker_swarm_status | ||
changed_when: false | ||
|
||
- name: Check if the docker swarm has been initialized | ||
set_fact: | ||
swarm_initialized: "{{ active in docker_swarm_status.stdout }}" | ||
|
||
- name: Initialize Docker Swarm | ||
become: true | ||
command: docker swarm init --advertise-addr "{{ leader_ip }}" | ||
ignore_errors: yes | ||
when: not swarm_initialized | ||
|
||
- name: List docker swarm join command | ||
become: true | ||
shell: "docker swarm join-token worker" | ||
args: | ||
executable: /bin/bash | ||
register: docker_swarm_join_command_output | ||
changed_when: false | ||
|
||
- name: Extract join token | ||
set_fact: | ||
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
- hosts: worker | ||
|
||
tasks: | ||
|
||
- name: Join Docker Swarm | ||
become: true | ||
command: "{{ hostvars[leader_ip]['docker_swarm_join_command'] }}" | ||
ignore_errors: yes |
Oops, something went wrong.