Parcourir la source

enhance installation process

nico il y a 8 ans
Parent
commit
036b48e818
3 fichiers modifiés avec 79 ajouts et 36 suppressions
  1. 5 2
      Docs/automated_install.md
  2. 71 31
      install/install.yml
  3. 3 3
      install/install_jarvis.sh

+ 5 - 2
Docs/automated_install.md

@@ -6,11 +6,14 @@ cd
 git clone https://repo/jarvis.git
 ```
 
-Run the install script with root privileges
+Run the install script.
 ```
-sudo ./jarvis/install/install_jarvis.sh
+./jarvis/install/install_jarvis.sh
 ```
 
+>**Note:** The install script must not be ran as root or with sudo. 
+You will be prompted to enter your sudo password during the installation process.
+
 You will be prompted to enter your sudo password during the installation process.
 
 Be sure you can record you voice, run the following command to capture audio from your microphone

+ 71 - 31
install/install.yml

@@ -2,36 +2,76 @@
 - hosts: localhost
   gather_facts: no
   connection: local
-  become: True
+  vars:
+    - git_url: "git@gitlab.pwit.fr:millionsfortomorrow/jarvis.git"
+    - temp_local_repo: "/tmp/jarvis_repo"
+
+  tasks:
+    - name: clone project in /tmp as standart user
+      git:
+        repo: "{{ git_url }}"
+        dest: /tmp/jarvis_repo
+        accept_hostkey: yes
+
 
+- hosts: localhost
+  gather_facts: no
+  connection: local
+  become: True
+  vars:
+    - git_url: "git@gitlab.pwit.fr:millionsfortomorrow/jarvis.git"
+    - temp_local_repo: "/tmp/jarvis_repo"
+    - jarvis_install_path: "/usr/lib/jarvis"
   tasks:
-  - name: Install packages
-    apt: name={{ item }} update_cache=yes
-    with_items:
-      - python-pip
-      - python-dev
-      - libsmpeg0
-      - libttspico-utils
-      - libsmpeg0
-      - flac
-      - dialog
-      - libffi-dev
-      - portaudio19-dev
-      - build-essential
-      - libssl-dev
-      - libffi-dev
-      - sox
-#
-  - name: Copy requirement
-    copy:
-      src: python_requirements.txt
-      dest: /tmp/requirements.txt
-
-  - name: Upgrade pip
-    pip:
-      name: pip
-      state: latest
-
-  - name: Install python libs
-    pip:
-      requirements=/tmp/requirements.txt
+    - name: Install packages
+      apt: name={{ item }} update_cache=yes
+      with_items:
+        - python-pip
+        - python-dev
+        - libsmpeg0
+        - libttspico-utils
+        - libsmpeg0
+        - flac
+        - dialog
+        - libffi-dev
+        - portaudio19-dev
+        - build-essential
+        - libssl-dev
+        - libffi-dev
+        - sox
+
+    - name: Copy requirement
+      copy:
+        src: python_requirements.txt
+        dest: /tmp/requirements.txt
+
+    - name: Upgrade pip
+      pip:
+        name: pip
+        state: latest
+
+    - name: Install python libs
+      pip:
+        requirements=/tmp/requirements.txt
+
+    - name: Check that the repo has been cloned
+      stat:
+        path: "{{ temp_local_repo }}"
+      register: git_repo_stat
+
+    - name: Remove old version if exist
+      file:
+        path: "{{ jarvis_install_path }}"
+        state: absent
+
+    - name: Move repo in /usr/lib
+      command: mv "{{ temp_local_repo }}" "{{ jarvis_install_path }}"
+      when: git_repo_stat.stat.exists
+
+    - name: Add entry in /usr/bin
+      file:
+        src: "{{ jarvis_install_path }}/jarvis.py"
+        dest: /usr/bin/jarvis
+        state: link
+        force: True
+

+ 3 - 3
install/install_jarvis.sh

@@ -1,11 +1,11 @@
 #!/usr/bin/env bash
 
 # install packages
-apt-get install python-pip
+sudo apt-get install python-pip
 
 # install ansible
-pip install ansible==2.1.1.0
+sudo pip install ansible==2.1.1.0
 
 # Install the project
 cd jarvis/install
-ansible-playbook install/install.yml -K
+ansible-playbook install.yml -K