From cdc053718fa24e6c61a0ac5d0ec003a07828e747 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 15 Jul 2020 07:46:42 +0200 Subject: [PATCH] :rocket: Adding Ansible configuration (not tested) --- ansible/ansible.cfg | 14 ++++++++++++++ ansible/base.yml | 9 +++++++++ ansible/hosts | 5 +++++ ansible/roles/apt-basic/tasks/main.yml | 20 ++++++++++++++++++++ ansible/roles/nginx/tasks/main.yml | 19 +++++++++++++++++++ ansible/roles/nk20/tasks/main.yml | 12 ++++++++++++ ansible/roles/python-venv/tasks/main.yml | 10 ++++++++++ 7 files changed, 89 insertions(+) create mode 100644 ansible/ansible.cfg create mode 100644 ansible/base.yml create mode 100644 ansible/hosts create mode 100644 ansible/roles/apt-basic/tasks/main.yml create mode 100644 ansible/roles/nginx/tasks/main.yml create mode 100644 ansible/roles/nk20/tasks/main.yml create mode 100644 ansible/roles/python-venv/tasks/main.yml diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 00000000..e7a0537b --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,14 @@ +[defaults] +inventory = ./hosts +timeout = 42 + +[privilege_escalation] +become = True +become_ask_pass = True + +[ssh_connection] +pipelining = True +retries = 3 + +[diff] +always = yes diff --git a/ansible/base.yml b/ansible/base.yml new file mode 100644 index 00000000..79b9b932 --- /dev/null +++ b/ansible/base.yml @@ -0,0 +1,9 @@ +#!/usr/bin/env ansible-python +--- + +- hosts: beta-nk20 + roles: + - apt-basic + - nk20 + - python-venv + - nginx diff --git a/ansible/hosts b/ansible/hosts new file mode 100644 index 00000000..beafcc55 --- /dev/null +++ b/ansible/hosts @@ -0,0 +1,5 @@ +[server] +bde-nk20-beta.adh.crans.org + +[all:vars] +ansible_python_interpreter=/usr/bin/python3 diff --git a/ansible/roles/apt-basic/tasks/main.yml b/ansible/roles/apt-basic/tasks/main.yml new file mode 100644 index 00000000..03577640 --- /dev/null +++ b/ansible/roles/apt-basic/tasks/main.yml @@ -0,0 +1,20 @@ +--- +- name: Install basic APT packages + apt: + update_cache: true + name: + - nginx + - python3 + - python3-pip + - python3-dev + - uwsgi + - uwsgi-plugin-python3 + - python3-venv + - git + - acl + - texlive-latex-extra + - texlive-fonts-extra + - texlive-lang-french + register: pkg_result + retries: 3 + until: pkg_result is succedded diff --git a/ansible/roles/nginx/tasks/main.yml b/ansible/roles/nginx/tasks/main.yml new file mode 100644 index 00000000..08b005af --- /dev/null +++ b/ansible/roles/nginx/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: Update Nginx conf + replace: + path: /var/www/note_kfet/nginx_note.conf.example + dest: /var/www/note_kfet/nginx_note.conf + regexp: 'note.example.org' + replace: 'bde-nk20-beta.adh.crans.org' + +- name: Copy conf to Nginx + file: + path: /var/www/note_kfet/nginx_note.conf + dest: /etc/nginx/sites-enabled/nginx_note.conf + state: link + +- name: Copy conf to UWSGI + file: + path: /var/www/note_kfet/uwsgi_note.ini + dest: /etc/uwsgi/apps-enabled/uwsgi_note.ini + state: link diff --git a/ansible/roles/nk20/tasks/main.yml b/ansible/roles/nk20/tasks/main.yml new file mode 100644 index 00000000..cc2945df --- /dev/null +++ b/ansible/roles/nk20/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: Create note_kfet dir with good permissions + file: + path: /var/www + owner: www-data + group: foo + mode: u=rw,g=rws,o=r + +- name: Clone Note Kfet + git: + repo: https://gitlab.crans.org/bde/nk20.git + dest: /var/www/note_kfet diff --git a/ansible/roles/python-venv/tasks/main.yml b/ansible/roles/python-venv/tasks/main.yml new file mode 100644 index 00000000..386fb214 --- /dev/null +++ b/ansible/roles/python-venv/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: Install PIP basic dependencies + pip: + requirements: /var/www/note_kfet/requirements/base.txt + virtualenv: /var/www/note_kfet/env + +- name: Install PIP production dependencies + pip: + requirements: /var/www/note_kfet/requirements/production.txt + virtualenv: /var/www/note_kfet/env