LOC-18 Deploy server with ansible
LOC-18 Deploy server with ansible

It could do with some tidying and some conditionals, but it's now possible to deploy the server with the ansible playbook.

file:b/ansible/README.md (new)
--- /dev/null
+++ b/ansible/README.md
@@ -1,1 +1,9 @@
+LocalChat Ansible Playbook Instructions
+=========================================
 
+
+
+Dependancies
+----------------
+
+Requires ansible >= 2.2

--- a/ansible/group_vars/localchat-servers.yml
+++ b/ansible/group_vars/localchat-servers.yml
@@ -1,2 +1,3 @@
 ansible_user: ansible
+ansible_become: true
 

--- /dev/null
+++ b/ansible/localchat-servers.retry
@@ -1,1 +1,2 @@
+192.168.7.253
 

--- a/ansible/roles/localchat-server/defaults/main.yml
+++ b/ansible/roles/localchat-server/defaults/main.yml
@@ -1,3 +1,4 @@
-localchat_server_install_path: /usr/local/localchat
+localchat_server_install_path: /usr/local/src/localchat
+localchat_server_install_ver: 0.0.2.1
 
 

--- a/ansible/roles/localchat-server/handlers/main.yml
+++ b/ansible/roles/localchat-server/handlers/main.yml
@@ -7,9 +7,8 @@
 - name: Start service
   # See above.
   command: systemctl start localchat.service
-  become: true
 
 - name: reload systemd
   command: systemctl daemon-reload
-  become: true
 
+

--- a/ansible/roles/localchat-server/tasks/main.yml
+++ b/ansible/roles/localchat-server/tasks/main.yml
@@ -1,26 +1,46 @@
 ---
 
-- name: Install Dependancies
+- name: Install Utils
   apt: name={{item}} state=installed
   with_items:
-    - python-flask
-    - python-urllib3
+    - python-pip
     - python-sqlite
-    - python-bcrypt
-    - python-gnupg
-  become: true
+    - unzip
   tags: deps
+
+- name: Install Python Dependancies
+  pip: name={{item}} state=present
+  with_items:
+    - flask
+    - werkzeug
+    - bcrypt
+    - gnupg
+    - pyopenssl
+  tags: deps
+
+
+- name: Create install dir
+  file: path={{localchat_server_install_path}} state=directory
+  
+- name: Download and install Server
+  unarchive:
+    src: "https://github.com/bentasker/LocalChat/archive/v{{localchat_server_install_ver}}.zip"
+    dest: "{{localchat_server_install_path}}"
+    remote_src: yes
+  
+- name: Symlink latest
+  file:
+    src: "{{localchat_server_install_path}}/LocalChat-{{localchat_server_install_ver}}/server/LocalChat.py"
+    dest: "{{localchat_server_install_path}}/LocalChat.py"
+    state: link
     
+- name: Create Unit File
+  template: src=localchat.service dest=/etc/systemd/system/localchat.service
+  notify: reload systemd
 
-    
-    
-    
-    
-    
--   name: Create Unit File
-    template: src=localchat.service dest=/etc/systemd/system/localchat.service
-    notify: reload systemd
-    become: true
 
-    
+- name: Start server
+  command: systemctl start localchat
 
+
+

--- a/server/LocalChat.py
+++ b/server/LocalChat.py
@@ -758,7 +758,7 @@
         
         '''
 
-        crypted = self.gpg.encrypt(msg,None,passphrase=self.syskey,symmetric="AES256",armor=False)
+        crypted = self.gpg.encrypt(msg,None,passphrase=self.syskey,symmetric="AES256",armor=False,encrypt=False)
         return crypted.data.encode('base64')
 
 
@@ -821,5 +821,5 @@
     #
     # This will likely become a CLI argument later
     port = int(os.environ.get('PORT', 8090))
-    app.run(host='127.0.0.1', port=port,debug=True,ssl_context='adhoc')
-
+    app.run(host='127.0.0.1', port=port,ssl_context='adhoc',threaded=False)
+