Compare commits
2 Commits
4c3d0b2750
...
469410e4ab
Author | SHA1 | Date |
---|---|---|
Gasper Spagnolo | 469410e4ab | |
Gasper Spagnolo | d7a2181ab9 |
|
@ -0,0 +1 @@
|
||||||
|
.venv/
|
|
@ -0,0 +1,27 @@
|
||||||
|
# FAUST AD automated server install
|
||||||
|
|
||||||
|
|
||||||
|
## Dependencies:
|
||||||
|
- System:
|
||||||
|
```bash
|
||||||
|
python3
|
||||||
|
python3-pip
|
||||||
|
python3-venv
|
||||||
|
```
|
||||||
|
|
||||||
|
- Python:
|
||||||
|
```bash
|
||||||
|
python3 -m venv .venv
|
||||||
|
source ./.venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
- Ansible:
|
||||||
|
```bash
|
||||||
|
ansible-galaxy install -r requirements.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Start
|
||||||
|
Start at the root of repo and execute `<here_ans_command>` command.
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
- name: Setup FaustAD framework
|
||||||
|
hosts: faust_ad
|
||||||
|
become: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Install docker on machine
|
||||||
|
include_role:
|
||||||
|
name: docker
|
||||||
|
tasks_from: main
|
|
@ -1,2 +0,0 @@
|
||||||
[okeanos_server]
|
|
||||||
faust.ad
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import requests
|
||||||
|
|
||||||
|
SERVER_IP = '10.2.162.4'
|
||||||
|
ADMIN_USER = 'admin'
|
||||||
|
|
||||||
|
create_user_data = {
|
||||||
|
'userid': 'franco',
|
||||||
|
'password': 'francosafep',
|
||||||
|
}
|
||||||
|
|
||||||
|
ocs_required_headers = {
|
||||||
|
'OCS-APIRequest': 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_api_token():
|
||||||
|
response = requests.get(f'http://admin:admin@{SERVER_IP}/ocs/v2.php/core/getapppassword', headers=ocs_required_headers)
|
||||||
|
response = response.text.split('<apppassword>')[1]
|
||||||
|
response = response.split('</apppassword>')[0]
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
api_token = get_api_token()
|
||||||
|
#response = requests.post(f'http://{SERVER_IP}/ocs/v1.php/cloud/users',
|
||||||
|
# data=create_user_data,
|
||||||
|
# auth=(ADMIN_USER, api_token),
|
||||||
|
# headers=ocs_required_headers)
|
||||||
|
|
||||||
|
r = requests.post('http://localhost:8999', data=create_user_data, auth=(ADMIN_USER, api_token)) # nc -kl 8999
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
55
playbook.yml
55
playbook.yml
|
@ -1,55 +0,0 @@
|
||||||
---
|
|
||||||
- name: Setup faustAD platform
|
|
||||||
hosts: okeanos_server
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Update and upgrade system
|
|
||||||
apt:
|
|
||||||
name: '*'
|
|
||||||
state: latest
|
|
||||||
update_cache: yes
|
|
||||||
force_apt_get: yes
|
|
||||||
register: apt_update_status
|
|
||||||
|
|
||||||
- name: Remove packages not needed anymore
|
|
||||||
apt:
|
|
||||||
autoremove: yes
|
|
||||||
|
|
||||||
- name: Reboot when packages were updated
|
|
||||||
reboot:
|
|
||||||
post_reboot_delay: 60
|
|
||||||
when: apt_update_status.changed
|
|
||||||
|
|
||||||
- name: Install required packages for Docker
|
|
||||||
apt:
|
|
||||||
pkg:
|
|
||||||
- apt-transport-https
|
|
||||||
- ca-certificates
|
|
||||||
- curl
|
|
||||||
- software-properties-common
|
|
||||||
- python3-pip
|
|
||||||
- virtualenv
|
|
||||||
- python3-setuptools
|
|
||||||
state: latest
|
|
||||||
update_cache: true
|
|
||||||
|
|
||||||
- name: Add Docker GPG apt Key
|
|
||||||
apt_key:
|
|
||||||
url: https://download.docker.com/linux/ubuntu/gpg
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Add Docker Repository
|
|
||||||
apt_repository:
|
|
||||||
repo: deb https://download.docker.com/linux/ubuntu focal stable
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Update apt and install docker-ce
|
|
||||||
apt:
|
|
||||||
name: docker-ce
|
|
||||||
state: latest
|
|
||||||
update_cache: true
|
|
||||||
|
|
||||||
- name: Install Docker Module for Python
|
|
||||||
pip:
|
|
||||||
name: docker
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ansible-core==2.13.4
|
|
@ -0,0 +1,7 @@
|
||||||
|
# ansible-galaxy collection list
|
||||||
|
collections:
|
||||||
|
- name: community.docker
|
||||||
|
version: '3.1.0'
|
||||||
|
|
||||||
|
- name: community.general
|
||||||
|
version: '5.6.0'
|
|
@ -0,0 +1,42 @@
|
||||||
|
- name: Install required apt packages for Docker
|
||||||
|
apt:
|
||||||
|
pkg:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- software-properties-common
|
||||||
|
- python3-pip
|
||||||
|
- virtualenv
|
||||||
|
- python3-setuptools
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Add Docker GPG apt Key
|
||||||
|
apt_key:
|
||||||
|
url: 'https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg'
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add Docker Repository
|
||||||
|
apt_repository:
|
||||||
|
repo: 'deb https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable'
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install Docker
|
||||||
|
apt:
|
||||||
|
pkg:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-compose-plugin
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Install Docker Module for Python
|
||||||
|
pip:
|
||||||
|
name:
|
||||||
|
- docker
|
||||||
|
- docker-compose
|
||||||
|
|
||||||
|
- name: Check if Docker is up and running
|
||||||
|
service:
|
||||||
|
name: docker
|
||||||
|
state: started
|
||||||
|
enabled: true
|
Loading…
Reference in New Issue