summaryrefslogtreecommitdiffstats
path: root/ansible/roles/package-repository/tasks/main.yml
blob: 3ccce081b3eb3a5333b7a1505c642fd7352382fa (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
- name: Get installed packages list
  package_facts:
    manager: "auto"

- name: Disable DNS management in Network Manager
  ini_file:
    path: /etc/NetworkManager/NetworkManager.conf
    state: present
    no_extra_spaces: true
    section: main
    option: dns
    value: none
    owner: root
    group: root
    mode: 0644
    backup: false
  when: ansible_os_family == 'RedHat' and 'NetworkManager' in ansible_facts.packages
  notify:
    - Restart NetworkManager

- name: Setup resolv.conf for node to find package repository by name from infra
  lineinfile:
    line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}"
    path: /etc/resolv.conf
    state: present
    insertbefore: BOF
    unsafe_writes: true

- name: Disable all default repositories
  block:
    - name: Find repo files names
      find:
        paths: "{{ repo_path[ansible_os_family] }}"
        pattern: "{{ repo_patern[ansible_os_family] }}"
      register: repo_files

    - name: Get all defined offline repo names
      set_fact: package_repositories_names="{{ package_repositories | selectattr('name', 'defined') | map(attribute='name') | list  }}"

    - name: Backup repo files
      copy:
        remote_src: true
        src: "{{ item.path }}"
        dest: "{{ item.path }}.disabled"
      loop: "{{ repo_files.files }}"
      when: "(item.path | basename | splitext)[0] not in package_repositories_names"

    - name: Remove disabled repo files
      file:
        path: "{{ item.path }}"
        state: absent
      loop: "{{ repo_files.files }}"
      when: "(item.path | basename | splitext)[0] not in package_repositories_names"

- include_tasks: "{{ ansible_os_family }}.yml"