ansible-koji/roles/koji_bootstrap/tasks/add_host.yaml
Rénich Bon Ćirić fa97cba322
feat: Configurar Dist-Git como Lookaside Cache y corregir bootstrap
- Configurar rol dist_git como Lookaside Cache únicamente (sin git-daemon).
- Actualizar estructura de caché a 'rpms/pkg/file/algo/hash/file' compatible con upstream.
- Añadir scripts bin/sync-sources.bash y bin/sync-all-sources.bash para sincronizar fuentes desde CentOS Stream.
- Eliminar bin/import-srpm.bash obsoleto.
- Actualizar script mxos-get-sources.bash en kojid para usar la nueva estructura de URL.
- Corregir lógica de 'add-host' en koji_bootstrap para manejar reintentos limpiamente.
- Actualizar documentación (README.rst, docs/instalación.rst) reflejando los cambios.
- Correcciones menores en rutas de configuración y nombres de grupos en deploy.yaml.
2025-11-23 01:11:31 -06:00

47 lines
1.9 KiB
YAML

---
- name: Add Koji builder host {{ item }}
block:
- name: Try to add Koji builder host
ansible.builtin.command: >
sudo -u {{ koji_admin_user }} koji
--config={{ koji_hub_admin_user_koji_dir }}/config
add-host {{ item }} x86_64
register: koji_add_host_result
changed_when: "'Host added' in koji_add_host_result.stdout"
failed_when: "'is already in the database' not in koji_add_host_result.stderr and koji_add_host_result.rc != 0"
rescue:
- name: Get user ID of the non-host user
ansible.builtin.command: >
sudo -u postgres psql {{ koji_db_name }} -tAc
"SELECT id FROM users WHERE name = '{{ item }}' AND usertype = 0;"
register: non_host_user_id
delegate_to: "{{ koji_db_host }}"
changed_when: false
- name: Delete sessions for non-host user
ansible.builtin.command: >
sudo -u postgres psql {{ koji_db_name }} -c
"DELETE FROM sessions WHERE user_id = {{ non_host_user_id.stdout | trim }};"
when:
- non_host_user_id.stdout | trim | length > 0
- "'already exists and it is not a host' in koji_add_host_result.stderr"
delegate_to: "{{ koji_db_host }}"
changed_when: true
- name: Delete non-host user
ansible.builtin.command: >
sudo -u postgres psql {{ koji_db_name }} -c
"DELETE FROM users WHERE id = {{ non_host_user_id.stdout | trim }};"
when:
- non_host_user_id.stdout | trim | length > 0
- "'already exists and it is not a host' in koji_add_host_result.stderr"
delegate_to: "{{ koji_db_host }}"
changed_when: true
- name: Retry adding Koji builder host
ansible.builtin.command: >
sudo -u {{ koji_admin_user }} koji
--config={{ koji_hub_admin_user_koji_dir }}/config
add-host {{ item }} x86_64
when:
- "'already exists and it is not a host' in koji_add_host_result.stderr"