summaryrefslogtreecommitdiffstats
path: root/ansible/roles/package-repository-check/tasks/Debian.yml
blob: 45a2b1cfced5044d83f1228efe5b385d8df678be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
- 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
  service:
    name: resolvconf
    state: restarted