[AETHER-831] - Setup Jenkins process via Ansible playbook

Change-Id: I6a3ae4d3025b41d851219a9762436988201d4add
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
new file mode 100644
index 0000000..85ca137
--- /dev/null
+++ b/tasks/Debian.yml
@@ -0,0 +1,37 @@
+---
+# jenkins tasks/Debian.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Ensure dependencies are installed.
+  apt:
+    name:
+      - gnupg
+      - curl
+      - apt-transport-https
+      - openjdk-8-jdk
+    state: present
+    update_cache: true
+
+- name: Add Jenkins apt repo key
+  apt_key:
+    data: "{{ lookup('file','jenkins.io.key') }}"
+    state: "present"
+
+- name: Add Jenkins apt repo
+  apt_repository:
+    repo: "{{ jenkins_repo_url }}"
+    update_cache: true
+
+- name: Install Jenkins packages (Debian)
+  apt:
+    name: "jenkins"
+    state: "present"
+    update_cache: true
+    cache_valid_time: 3600
+
+- name: Enable Jenkins Service
+  service:
+    name: "{{ jenkins_service }}"
+    enabled: true
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..32b6c1b
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,24 @@
+---
+# jenkins 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: Initial the Jenkins
+  include_tasks: "settings.yml"
+
+- name: generate groovy for initializing local admin account
+  template:
+    src: init_admin.groovy.j2
+    dest: "{{ jenkins_home }}/init.groovy.d/basic-security.groovy"
+    owner: "{{ jenkins_process_user }}"
+    group: "{{ jenkins_process_group }}"
+    mode: 0775
+  notify:
+    - start-jenkins
diff --git a/tasks/settings.yml b/tasks/settings.yml
new file mode 100644
index 0000000..707e128
--- /dev/null
+++ b/tasks/settings.yml
@@ -0,0 +1,31 @@
+---
+- name: Configure proxy config for Jenkins
+  template:
+    src: proxy.xml
+    dest: "{{ jenkins_home }}/proxy.xml"
+    owner: "{{ jenkins_process_user }}"
+    group: "{{ jenkins_process_group }}"
+    mode: 0664
+  register: jenkins_proxy_config
+  when:
+    - jenkins_proxy_host | length > 0
+    - jenkins_proxy_port | length > 0
+
+- name: Modify variables in init file.
+  lineinfile:
+    dest: "{{ jenkins_init_file }}"
+    insertafter: '^{{ item.option }}='
+    regexp: '^{{ item.option }}=\"\${{ item.option }} '
+    line: '{{ item.option }}="${{ item.option }} {{ item.value }}"'
+    state: present
+    mode: 0644
+  with_items: "{{ jenkins_init_changes }}"
+  register: jenkins_init_prefix
+
+- name: Create custom init scripts directory.
+  file:
+    path: "{{ jenkins_home }}/init.groovy.d"
+    state: directory
+    owner: "{{ jenkins_process_user }}"
+    group: "{{ jenkins_process_group }}"
+    mode: 0775