]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
tests/setup: Use local mirror of centos 8 stream repo
authorDavid Galloway <dgallowa@redhat.com>
Wed, 13 Apr 2022 18:51:08 +0000 (14:51 -0400)
committerGuillaume Abrioux <gabrioux@redhat.com>
Thu, 21 Apr 2022 09:43:39 +0000 (11:43 +0200)
The mirrors provided by CentOS' mirrorlists are super slow

Signed-off-by: David Galloway <dgallowa@redhat.com>
tests/functional/setup.yml

index f8e2047d488a6561247c8aaf72a771d13233fae6..c72db297c9bc21d11b3eb8362515a26c7b53de06 100644 (file)
       set_fact:
         is_atomic: '{{ stat_ostree.stat.exists }}'
 
+    - name: List repo files
+      find:
+        paths: /etc/yum.repos.d/
+        file_type: file
+        patterns: 'CentOS-Stream-*.repo'
+      register: pre_stream_repo_files
+      when:
+        - ansible_facts['distribution'] == 'CentOS'
+        - ansible_facts['distribution_major_version'] | int > 7
+        - not is_atomic | bool
+
+    # From ansible docs: 'replace: If not set, matches are removed entirely.'
+    - name: Remove all mirrorlists
+      replace:
+        path: "{{ item.path }}"
+        regexp: '^mirrorlist=.*'
+      with_items: "{{ pre_stream_repo_files.files }}"
+      when:
+        - ansible_facts['distribution'] == 'CentOS'
+        - ansible_facts['distribution_major_version'] | int > 7
+        - not is_atomic | bool
+
+    - name: Uncomment baseurls
+      replace:
+        path: "{{ item.path }}"
+        regexp: '^mirrorlist=.*'
+        regexp: '^\s*#*\s*(baseurl=.*)'
+        replace: '\1'
+      with_items: "{{ pre_stream_repo_files.files }}"
+      when:
+        - ansible_facts['distribution'] == 'CentOS'
+        - ansible_facts['distribution_major_version'] | int > 7
+        - not is_atomic | bool
+
+    - name: Point baseurls to archive server
+      replace:
+        path: "{{ item.path }}"
+        regexp: 'mirror.centos.org/\$contentdir/\$stream'
+        replace: 'apt-mirror.front.sepia.ceph.com/centos/8-stream'
+      with_items: "{{ pre_stream_repo_files.files }}"
+      when:
+        - ansible_facts['distribution'] == 'CentOS'
+        - ansible_facts['distribution_major_version'] | int > 7
+        - not is_atomic | bool
+
     - name: update the system
       command: dnf update -y
       changed_when: false