From a3a4b02f4aa5a4e23cee229381c077364ecbfd2e Mon Sep 17 00:00:00 2001
From: Pierre Kunzli <pierre.kuenzli@unige.ch>
Date: Mon, 12 Aug 2024 16:10:58 +0200
Subject: [PATCH] working on ansible deployment

---
 ansible/bootiful.yml          | 11 +++++++++++
 ansible/configure_app.yml     |  9 +++++++++
 ansible/configure_runtime.yml | 18 ++++++++++++++++++
 ansible/hosts                 |  2 ++
 ansible/run-ansible.sh        |  1 +
 ansible/vars.yml              |  3 +++
 6 files changed, 44 insertions(+)
 create mode 100644 ansible/bootiful.yml
 create mode 100644 ansible/configure_app.yml
 create mode 100644 ansible/configure_runtime.yml
 create mode 100644 ansible/hosts
 create mode 100644 ansible/run-ansible.sh
 create mode 100644 ansible/vars.yml

diff --git a/ansible/bootiful.yml b/ansible/bootiful.yml
new file mode 100644
index 0000000..b574ad2
--- /dev/null
+++ b/ansible/bootiful.yml
@@ -0,0 +1,11 @@
+---
+
+# Deploy bootiful server, tested on Debian 12
+
+- hosts: bootiful_server
+  gather_facts: true
+
+  tasks:
+    - include_vars: vars.yml
+    - import_tasks: configure_runtime.yml
+    - import_tasks: configure_app.yml
diff --git a/ansible/configure_app.yml b/ansible/configure_app.yml
new file mode 100644
index 0000000..288bfc3
--- /dev/null
+++ b/ansible/configure_app.yml
@@ -0,0 +1,9 @@
+
+- name: Git checkout bootiful project
+  become: false
+  ansible.builtin.git:
+    repo: "{{ git_repo }}"
+    dest: "{{ git_clone_dest }}"
+    version: "{{ git_branch }}"
+  register: git_checkout_result
+   
diff --git a/ansible/configure_runtime.yml b/ansible/configure_runtime.yml
new file mode 100644
index 0000000..8ee2711
--- /dev/null
+++ b/ansible/configure_runtime.yml
@@ -0,0 +1,18 @@
+---
+
+- name: Upgrade system
+  become: true
+  ansible.builtin.apt:
+    update_cache: true
+    upgrade: "yes"
+
+- name: Install system packages
+  become: true
+  ansible.builtin.apt:
+    pkg:
+      - python3-pip
+      - git
+      - build-essential
+      - docker.io
+      - docker-compose
+    state: latest
diff --git a/ansible/hosts b/ansible/hosts
new file mode 100644
index 0000000..37dbf69
--- /dev/null
+++ b/ansible/hosts
@@ -0,0 +1,2 @@
+[bootiful_server]
+bootiful_server_1 ansible_port=22 ansible_user=pierre ansible_host=bootiful-server
diff --git a/ansible/run-ansible.sh b/ansible/run-ansible.sh
new file mode 100644
index 0000000..7d260ac
--- /dev/null
+++ b/ansible/run-ansible.sh
@@ -0,0 +1 @@
+ansible-playbook bootiful.yml -i hosts -Kk
diff --git a/ansible/vars.yml b/ansible/vars.yml
new file mode 100644
index 0000000..b492a29
--- /dev/null
+++ b/ansible/vars.yml
@@ -0,0 +1,3 @@
+git_repo: "https://gitedu.hesge.ch/pierre.kunzli/bootiful.git"
+git_branch: master
+git_clone_dest: bootiful
-- 
GitLab