Initial commit of Timesheets install role

Change-Id: I4a0b1f7aa05fc50bc3d88be001413a00be65f231
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
new file mode 100644
index 0000000..f3563ea
--- /dev/null
+++ b/tasks/Debian.yml
@@ -0,0 +1,25 @@
+---
+# timesheets tasks/Debian.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+#
+
+- name: Install Timesheets Prereqs
+  apt:
+    name:
+      - "git"
+    state: "present"
+    update_cache: true
+    cache_valid_time: 3600
+
+
+- name: Create systemd service unit files for timesheetsdb service
+  template:
+    src: "{{ item }}.j2"
+    dest: "/etc/systemd/system/{{ item }}"
+    owner: "root"
+    group: "root"
+    mode: "0644"
+  with_items:
+    - "timesheetsdb.service"
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..597d5f3
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,104 @@
+---
+# timesheets tasks/main.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: include OS-specific vars
+  include_vars: "{{ ansible_os_family }}.yml"
+
+- name: include OS-specific tasks
+  include_tasks: "{{ ansible_os_family }}.yml"
+
+- name: Create group for timesheets
+  group:
+    name: "{{ timesheets_groupname }}"
+
+- name: Create user for timesheets
+  user:
+    name: "{{ timesheets_username }}"
+    group: "{{ timesheets_groupname }}"
+    comment: "{{ timesheets_comment }}"
+    shell: "{{ timesheets_shell }}"
+    home: "{{ timesheets_dir }}"
+    create_home: no  # yamllint disable-line rule:truthy
+    system: true
+    password_lock: true
+
+- name: Create directory for timesheetsdb
+  file:
+    path: "{{ timesheets_dir }}/db"
+    state: directory
+    owner: "{{ timesheets_username }}"
+    group: "{{ timesheets_groupname }}"
+    mode: "0755"
+
+- name: Obtain timesheetsdb code with git
+  become: true
+  become_user: "{{ timesheets_username }}"
+  git:
+    repo: "{{ timesheetsdb_repo }}"
+    dest: "{{ timesheets_dir }}/db"
+    version: "{{ timesheetsdb_version }}"
+
+- name: Create timesheetsdb configuration file
+  template:
+    src: "timesheetsdb_config.json.j2"
+    dest: "{{ timesheets_dir }}/db/timesheetsdb_config.json"
+    owner: "root"
+    group: "{{ timesheets_groupname }}"
+    mode: "0640"
+  notify:
+    - "restart-timesheetsdb"
+
+- name: Install timesheetsdb
+  become: true
+  become_user: "{{ timesheets_username }}"
+  command:
+    chdir: "{{ timesheets_dir }}/db"
+    cmd: "npm install"
+    creates: "{{ timesheets_dir }}/db/node_modules"
+  notify:
+    - "start-timesheetsdb"
+
+- name: Build timesheetsdb
+  become: true
+  become_user: "{{ timesheets_username }}"
+  command:
+    chdir: "{{ timesheets_dir }}/db"
+    cmd: "npm run build"
+    creates: "{{ timesheets_dir }}/db/dist"
+  notify:
+    - "start-timesheetsdb"
+
+- name: Create directory for timesheetsui
+  file:
+    path: "{{ timesheets_dir }}/ui"
+    state: directory
+    owner: "{{ timesheets_username }}"
+    group: "{{ timesheets_groupname }}"
+    mode: "0755"
+
+- name: Obtain timesheetsui code with git
+  become: true
+  become_user: "{{ timesheets_username }}"
+  git:
+    repo: "{{ timesheetsui_repo }}"
+    dest: "{{ timesheets_dir }}/ui"
+    version: "{{ timesheetsui_version }}"
+
+- name: Install timesheetsui
+  become: true
+  become_user: "{{ timesheets_username }}"
+  command:
+    chdir: "{{ timesheets_dir }}/ui"
+    cmd: "npm install"
+    creates: "{{ timesheets_dir }}/ui/node_modules"
+
+- name: Build timesheetsui dist
+  become: true
+  become_user: "{{ timesheets_username }}"
+  command:
+    chdir: "{{ timesheets_dir }}/ui"
+    cmd: "npm run-script ng build --prod"
+    creates: "{{ timesheets_dir }}/ui/dist"