Skip to content

Commit

Permalink
Add tasks to serve gating repo over content provider
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Kumar <[email protected]>
  • Loading branch information
raukadah committed May 31, 2024
1 parent abe75b6 commit 70886b3
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 2 deletions.
3 changes: 1 addition & 2 deletions hooks/playbooks/fetch_compute_facts.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
- name: Sync repos for controller to compute for periodic jobs
- name: Sync repos for controller to compute
hosts: computes
gather_facts: true
tasks:
- name: Copy repositories from controller to computes
when:
- zuul is defined
- "'periodic' in zuul.job"
become: true
ansible.builtin.copy:
dest: "/etc/yum.repos.d/"
Expand Down
1 change: 1 addition & 0 deletions roles/build_openstack_packages/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ cifmw_bop_timestamper_cmd: >-
cifmw_bop_branchless_projects:
- openstack-k8s-operators/tcib
- os-net-config/os-net-config

cifmw_bop_change_list: []

Expand Down
3 changes: 3 additions & 0 deletions roles/build_openstack_packages/tasks/create_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
priority=1
dest: "{{ cifmw_bop_gating_repo_dest }}/gating.repo"

- name: Serve gating repo
ansible.builtin.import_tasks: serve_gating_repo.yml

- name: Check for DLRN repo at the destination
ansible.builtin.stat:
path: "{{ cifmw_bop_gating_repo_dest }}/delorean.repo"
Expand Down
37 changes: 37 additions & 0 deletions roles/build_openstack_packages/tasks/serve_gating_repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- name: Install python-psutil
become: true
ansible.builtin.package:
name: python-psutil

- name: Getting process IDs of the process
community.general.pids:
pattern: "python -m http.server"
register: pids_of_python

- name: Printing the process IDs obtained
ansible.builtin.debug:
msg: "{{ pids_of_python.pids }}"

- name: Force kill the running process
ansible.builtin.command: "kill -9 {{ item }}"
loop: "{{ pids_of_python.pids }}"

- name: Open port 8766 to serve repos
become: true
ansible.builtin.command: "{{ item }}"
with_items:
- "nft add table ip filter"
- "nft add chain ip filter INPUT { type filter hook input priority 0 \\; }"
- "nft insert rule ip filter INPUT tcp dport 8766 counter accept"
changed_when: true

- name: Serve gating repos
become: true
ansible.builtin.shell:
cmd: >-
nohup python3 -m http.server 8766 1>{{ ansible_user_dir }}/pkg_mgr_mirror.log 2>{{ ansible_user_dir }}/pkg_mgr_mirror_error.log &
args:
chdir: "{{ cifmw_bop_gating_repo_dest }}"


3 changes: 3 additions & 0 deletions roles/repo_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
when: cifmw_repo_setup_enable_rhos_release | bool
- name: Update generated repos with mirror repos
ansible.builtin.import_tasks: ci_mirror.yml
- name: Add gating repo
ansible.builtin.import_tasks: populate_gating_repo.yml
when: content_provider_registry_ip is defined
- name: Sync generated repos to yum.repos.d
ansible.builtin.import_tasks: sync_repos.yml
31 changes: 31 additions & 0 deletions roles/repo_setup/tasks/populate_gating_repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: Check for gating.repo file on content provider
ansible.builtin.uri:
url: "http://{{ content_provider_registry_ip }}:8766/gating.repo"
register: _url_status
ignore_errors: true

- name: Construct gating repo
when: _url_status.status == 200
block:
- name: Populate gating repo from content provider ip
ansible.builtin.copy:
content: |
[gating-repo]
baseurl=http://{{ content_provider_registry_ip }}:8766/
enabled=1
gpgcheck=0
priority=1
dest: "{{ cifmw_repo_setup_output }}/gating.repo"

- name: Check for DLRN repo at the destination
ansible.builtin.stat:
path: "{{ cifmw_repo_setup_output }}/delorean.repo"
register: _dlrn_repo

- name: Lower the priority of DLRN repos to allow installation from gating repo
when: _dlrn_repo.stat.exists
ansible.builtin.replace:
path: "{{ cifmw_repo_setup_output }}/delorean.repo"
regexp: "priority=1"
replace: "priority=20"

0 comments on commit 70886b3

Please sign in to comment.