From b078f60c367824cf253408eb6bcf56d0d8c8e922 Mon Sep 17 00:00:00 2001
From: Remy Mudingay <remy.mudingay@esss.se>
Date: Tue, 17 Jul 2018 19:24:13 +0200
Subject: [PATCH] cleanup of role - epel repo points to artifactory and merging
 of tasks

---
 defaults/main.yml                             |  4 --
 handlers/main.yml                             |  1 -
 meta/main.yml                                 |  6 +-
 molecule/default/requirements.yml             |  1 +
 tasks/main.yml                                | 64 ++++---------------
 templates/{filter.j2 => filter}               |  0
 .../{tinyproxy.conf.j2 => tinyproxy.conf}     |  0
 7 files changed, 15 insertions(+), 61 deletions(-)
 create mode 100644 molecule/default/requirements.yml
 rename templates/{filter.j2 => filter} (100%)
 rename templates/{tinyproxy.conf.j2 => tinyproxy.conf} (100%)

diff --git a/defaults/main.yml b/defaults/main.yml
index b719a0d..5fdceee 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -27,7 +27,3 @@ tinyproxy_filtering:
     extended: "On"
     default_deny: "On"
     case_sensitive: "Off"
-
-epel_repo_url: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"
-epel_repo_gpg_key_url: "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}"
-epel_repofile_path: "/etc/yum.repos.d/epel.repo"
diff --git a/handlers/main.yml b/handlers/main.yml
index 5f90550..32bee26 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -1,6 +1,5 @@
 ---
 - name: restart tinyproxy
-  become: "yes"
   service:
     name: tinyproxy
     state: restarted
diff --git a/meta/main.yml b/meta/main.yml
index a563724..ea22b37 100644
--- a/meta/main.yml
+++ b/meta/main.yml
@@ -9,7 +9,5 @@ galaxy_info:
     - name: CentOS
       versions:
         - 7
-dependencies: []
-# List your role dependencies here, one per line.
-# Be sure to remove the '[]' above if you add dependencies
-# to this list.
+dependencies:
+  - ics-ans-role-repository
diff --git a/molecule/default/requirements.yml b/molecule/default/requirements.yml
new file mode 100644
index 0000000..104566f
--- /dev/null
+++ b/molecule/default/requirements.yml
@@ -0,0 +1 @@
+- src: git+https://gitlab.esss.lu.se/ics-ansible-galaxy/ics-ans-role-repository.git
diff --git a/tasks/main.yml b/tasks/main.yml
index 1469803..f9bf624 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,70 +1,30 @@
 ---
-- name: Check if EPEL repo is already configured.
-  stat:
-    path: "{{ epel_repofile_path }}"
-  register: epel_repofile_result
-
-- name: Install EPEL repo.
-  yum:
-    name: "{{ epel_repo_url }}"
-    state: present
-  register: result
-  when: not epel_repofile_result.stat.exists
-
-- name: Import EPEL GPG key.
-  rpm_key:
-    key: "{{ epel_repo_gpg_key_url }}"
-    state: present
-  when: not epel_repofile_result.stat.exists
-
 - name: Install tinyproxy
-  become: "yes"
   yum:
     name: tinyproxy
     state: present
 
 - name: Copy 400 error html files
-  become: "yes"
-  template:
-    src: ../templates/400.html
-    dest: /usr/share/tinyproxy/400.html
-
-- name: Copy 403 error html files
-  become: "yes"
   template:
-    src: ../templates/403.html
-    dest: /usr/share/tinyproxy/403.html
-
-- name: Copy 404 error html files
-  become: "yes"
-  template:
-    src: ../templates/404.html
-    dest: /usr/share/tinyproxy/404.html
-
-- name: Copy 503 error html files
-  become: "yes"
-  template:
-    src: ../templates/503.html
-    dest: /usr/share/tinyproxy/503.html
+    src: "{{ item }}"
+    dest: "/usr/share/tinyproxy/{{ item }}"
+  with_items:
+    - 400.html
+    - 403.html
+    - 404.html
+    - 503.html
 
 - name: Create url filter file for tinyproxy
-  become: "yes"
-  template:
-    src: ../templates/filter.j2
-    dest: /etc/tinyproxy/filter
-  notify:
-    - restart tinyproxy
-
-- name: Setup configuration file for tinyproxy
-  become: "yes"
   template:
-    src: ../templates/tinyproxy.conf.j2
-    dest: /etc/tinyproxy/tinyproxy.conf
+    src: "{{ item }}"
+    dest: "/etc/tinyproxy/{{ item }}"
+  with_items:
+    - filter
+    - tinyproxy.conf
   notify:
     - restart tinyproxy
 
 - name: Test that tinyproxy is up
-  become: "yes"
   service:
     enabled: "yes"
     name: tinyproxy
diff --git a/templates/filter.j2 b/templates/filter
similarity index 100%
rename from templates/filter.j2
rename to templates/filter
diff --git a/templates/tinyproxy.conf.j2 b/templates/tinyproxy.conf
similarity index 100%
rename from templates/tinyproxy.conf.j2
rename to templates/tinyproxy.conf
-- 
GitLab