LOC-18 Ansible playbook build
LOC-18 Ansible playbook build

Very early stages of the playbook, all we currently do for the server role is install deps and create a unit file

--- /dev/null
+++ b/ansible/group_vars/localchat-servers.yml
@@ -1,1 +1,2 @@
+ansible_user: ansible
 

--- /dev/null
+++ b/ansible/inventory/hosts
@@ -1,1 +1,4 @@
+[localchat-servers]
+192.168.7.253
 
+

--- /dev/null
+++ b/ansible/locaLchat.service
@@ -1,1 +1,15 @@
+[Unit]
+Description=LocalChat
+After=multi-user.target
 
+[Service]
+WorkingDirectory=/usr/local/localchat
+Type=idle
+ExecStart=/usr/bin/python LocalChat.py
+Restart=always
+RestartSec=3
+
+[Install]
+WantedBy=multi-user.target
+
+

--- /dev/null
+++ b/ansible/localchat-servers.yml
@@ -1,1 +1,7 @@
+---
 
+-   hosts: localchat-servers
+    roles:
+        - localchat-server
+
+

--- /dev/null
+++ b/ansible/roles/localchat-server/defaults/main.yml
@@ -1,1 +1,3 @@
+localchat_server_install_path: /usr/local/localchat
 
+

--- /dev/null
+++ b/ansible/roles/localchat-server/handlers/main.yml
@@ -1,1 +1,15 @@
+---
 
+# Handlers
+
+
+
+- name: Start service
+  # See above.
+  command: systemctl start localchat.service
+  become: true
+
+- name: reload systemd
+  command: systemctl daemon-reload
+  become: true
+

--- /dev/null
+++ b/ansible/roles/localchat-server/tasks/main.yml
@@ -1,1 +1,26 @@
+---
 
+- name: Install Dependancies
+  apt: name={{item}} state=installed
+  with_items:
+    - python-flask
+    - python-urllib3
+    - python-sqlite
+    - python-bcrypt
+    - python-gnupg
+  become: true
+  tags: deps
+    
+
+    
+    
+    
+    
+    
+-   name: Create Unit File
+    template: src=localchat.service dest=/etc/systemd/system/localchat.service
+    notify: reload systemd
+    become: true
+
+    
+

--- /dev/null
+++ b/ansible/roles/localchat-server/templates/localchat.service
@@ -1,1 +1,14 @@
+[Unit]
+Description=LocalChat
+After=multi-user.target
 
+[Service]
+WorkingDirectory={{localchat_server_install_path}}
+Type=idle
+ExecStart=/usr/bin/python LocalChat.py
+Restart=always
+RestartSec=3
+
+[Install]
+WantedBy=multi-user.target
+

file:b/ansible/site.yml (new)
--- /dev/null
+++ b/ansible/site.yml
@@ -1,1 +1,2 @@
+- include: localchat-servers.yml