Adding Ubuntu support in Ansible - package-repository-check role 80/101480/9
authorJan Benedikt <j.benedikt@partner.samsung.com>
Mon, 10 Feb 2020 15:13:58 +0000 (16:13 +0100)
committerJan Benedikt <j.benedikt@partner.samsung.com>
Thu, 30 Apr 2020 11:08:12 +0000 (13:08 +0200)
Extending ansible playbooks of ubuntu support.
Creating new test with Ubuntu image for Molecule in package-repository-check role.

Issue-ID: OOM-1671
Signed-off-by: Jan Benedikt <j.benedikt@partner.samsung.com>
Change-Id: I9dcdbab00169ccfc13a10c1d9b6ec9cf10572688

ansible/roles/package-repository-check/tasks/Debian.yml [new file with mode: 0644]
ansible/roles/package-repository-check/tasks/main.yml

diff --git a/ansible/roles/package-repository-check/tasks/Debian.yml b/ansible/roles/package-repository-check/tasks/Debian.yml
new file mode 100644 (file)
index 0000000..8fb3784
--- /dev/null
@@ -0,0 +1,34 @@
+---
+- name: verify
+  block:
+    # Clean cache prior to refreshing
+    - name: Clean apt cache
+      command: apt clean && apt autoclean
+      args:
+        warn: false
+    # Refresh cache to ensure repo is reachable
+    - name: Update apt cache
+      apt:
+        update_cache: yes
+        state: latest
+      tags:
+        - skip_ansible_lint # Prevent '[403] Package installs should not use latest' ansible lint task rule
+  rescue:
+    - name: Fail if apt cache updating failed
+      fail:
+        msg: "Couldn't refresh apt cache, repositories not configured properly. Check ansible logs for details."
+  become: true
+
+- name: Install resolvconf
+  package:
+    name: resolvconf
+    state: present
+
+- name: Add a line to a file if the file does not exist, without passing regexp
+  lineinfile:
+    path: /etc/resolvconf/resolv.conf.d/head
+    line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}"
+    create: yes
+
+- name: Make DNS settings permanent
+  command: service resolvconf restart
index ac63ece..11fb329 100644 (file)
@@ -9,4 +9,3 @@
 
 #Set of tasks designated to failing fast if configured repos are not functioning properly
 - include_tasks: "{{ ansible_os_family }}.yml"
-  when: ansible_os_family == 'RedHat'