« Koji/Installation » : différence entre les versions

De TartareFR
Aller à la navigation Aller à la recherche
 
(100 versions intermédiaires par le même utilisateur non affichées)
Ligne 2 : Ligne 2 :


== Présentation ==
== Présentation ==
Koji est une suite logicielle de construction de RPM. Il utilise Mock pour créer des environnements
{{class|Koji}} est une suite logicielle de construction de RPM. Il utilise [[RPM/Mock|mock]] pour créer des environnements
chrootés et y effectuer les builds.
chrootés et y effectuer les builds.


* '''Koji-Hub'''<br>koji-hub est le centre nerveux de toutes les opérations Koji. Il s'agit d'un serveur XML-RPC fonctionnant sous mod_python pour Apache. koji-hub est passif : il ne reçoit que les appels XML-RPC et s'appuie sur les autres outils de la suite pour la construction. koji-hub est le seul composant qui a un accès direct à la base de données et est l'un des deux composants qui ont un accès en écriture au système de fichiers.
[[Fichier:KojiArch.svg|441px|vignette|centré|Architecture du koji]]
* '''Kojid'''<br>kojid est le démon de compilation qui s'exécute sur chacune des machines de construction. Sa principale responsabilité est de scruter les demandes de construction entrantes et de les exécuter. Pour cela, kojid interroge koji-hub. Kojid est également responsable d'autres tâches que la construction : la création d'images d'installation par exemple. kojid utilise Mock pour la construction. Il crée également un buildroot vierge pour chaque génération. kojid est écrit en Python et communique avec koji-hub par l'intermédiaire de XML-RPC.
* '''Koji-Web'''<br>koji-web est un ensemble de scripts qui s'exécutent avec mod_python et utilise le moteur de templates Cheetah pour fournir une interface web à Koji. Il agit comme un client à koji-hub en offrant une interface d'aministration limitée. koji-Web expose un grand nombre d'informations et fournit également un moyen pour certaines opérations, telles que l'annulation de builds.
* '''Koji-client'''<br>koji-client est une CLI écrit en Python qui fournit de nombreux hooks à Koji. Il permetl'utilisateur d'interroger la plupart des données ainsi que d'effectuer des actions telles que l'ajout d'utilisateurs et de lancer la construction des demandes.
* '''Kojira'''<br>kojira est un démon qui garde la racine de construction repodata à jour. Il est responsable de l'enlèvement des racines redondantes et du nettoyage après une demande de construction est terminée.


Les composants de Koji peuvent être installés sur des serveurs différents. La seule obligation est d'autoriser la communication entre les différents composants de la suite.
* '''Koji-Hub'''<br>C'est le centre nerveux de toutes les opérations Koji. Il s'agit d'un serveur XML-RPC fonctionnant sous mod_python pour Apache. {{class|koji-hub}} est passif : il ne reçoit que les appels XML-RPC et s'appuie sur les autres outils de la suite pour la construction. {{class|koji-hub}} est le seul composant qui a un accès direct à la base de données et est l'un des deux composants qui ont un accès en écriture au système de fichiers.
* '''Kojid''' ou '''Koji-builder'''<br>C'est le démon de compilation qui s'exécute sur chacune des machines de construction. Sa principale responsabilité est de scruter les demandes de construction entrantes et de les exécuter. Pour cela, {{class|kojid}} interroge {{class|koji-hub}}. {{class|Kojid}} est également responsable d'autres tâches que la construction : la création d'images d'installation par exemple. kojid utilise Mock pour la construction. Il crée également un buildroot vierge pour chaque génération. kojid est écrit en Python et communique avec koji-hub par l'intermédiaire de XML-RPC.
* '''Koji-Web'''<br>C'est un ensemble de scripts qui s'exécutent avec mod_python et utilise le moteur de templates Cheetah pour fournir une interface web à {{class|Koji}}. Il agit comme un client à {{class|koji-hub}} en offrant une interface d'aministration limitée. {{class|koji-Web}} expose un grand nombre d'informations et fournit également un moyen pour certaines opérations, telles que l'annulation de builds.
* '''Koji-client'''<br>C'est une interface en ligne de commande ( CLI = Command Line Interface ) écrit en Python qui fournit de nombreux hooks à {{class|Koji}}. Il permet à l'utilisateur d'interroger la plupart des données ainsi que d'effectuer des actions telles que l'ajout d'utilisateurs et de lancer la construction des demandes.
* '''Kojira'''<br>C'est un démon qui garde la racine de construction repodata à jour. Il est responsable de l'enlèvement des racines redondantes et du nettoyage après une demande de construction est terminée.


Koji supporte nativement l'authentification par serveur Kerberos et par certificat SSL. Seul koji-client supporte l'authentification par mot de passe. De ce fait, l'authentification par mot de passe ne sera même pas abordée.
Les composants de {{class|Koji}} peuvent être installés sur des serveurs différents. La seule obligation est d'autoriser la communication entre les différents composants de la suite.
 
{{class|Koji}} supporte nativement l'authentification par serveur Kerberos et par certificat SSL. Seul {{class|koji-client}} supporte l'authentification par mot de passe. De ce fait, l'authentification par mot de passe ne sera même pas abordée.


La méthode d'authentification doit être choisie dès le début de l'installation. Dans la suite de ce document, nous mettrons en place la méthode SSL.
La méthode d'authentification doit être choisie dès le début de l'installation. Dans la suite de ce document, nous mettrons en place la méthode SSL.


Koji utilise beaucoup d'espace disque dans son répertoire primaire <path>/mnt/koji</path>. De plus Mock en utilisera beaucoup aussi sur les répertoires <path>/var/lib/mock</path> et <path>/var/cache/mock</path>. Il vaut mieux prévoir des partitions dédiées à ces répertoires ( les répertoires de Mock doivent appartenir au groupe mock et avoir les permissions 02755 ).
{{class|Koji}} utilise beaucoup d'espace disque dans son répertoire primaire <path>/mnt/koji</path>. De plus Mock en utilisera beaucoup aussi sur les répertoires <path>/var/lib/mock</path> et <path>/var/cache/mock</path>. Il vaut mieux prévoir des partitions dédiées à ces répertoires ( les répertoires de Mock doivent appartenir au groupe mock et avoir les permissions 02755 ).


== Knowledge Prerequisites  ==
Pour un aperçu rapide des outils utilisés : [[RPM/Yum|yum]], [[RPM/Mock|mock]], {{class|Koji}} (et tous ses composants), [[RPM/Mash|mash]], et comment ils fonctionnent ensemble, il existe une excellente présentation <ref>Présentation des outils de création/gestion des RPM [http://indico.cern.ch/event/55091 | Version online ]<br>Version offline: [[Fichier:MockKojiMash.pdf]] ( non mise à jour )</ref> créée par Steve Traylen du CERN.


* Basic understanding of SSL and authentication via certificates and/or Kerberos credentials
Le dépôt git de RussianFedora avec les fichiers de configuration de {{class|Koji}} <ref>https://github.com/RussianFedora/koji-setup</ref>
* Basic knowledge about creating a database in PostgreSQL and importing a schema
* Working with psql
* Basic knowledge about Apache configuration
* Basic knowledge about yum/createrepo/mock - else you'll not be able to debug problems!
* Basic knowledge about using command line
* Basic knowledge about RPM building
* Simple usage of the Koji client
* For an overview of yum, mock, Koji (and all its subcomponents), mash, and how they all work together, see the excellent slides <ref>[http://indico.cern.ch/event/55091| Slides about rpm build tools ]</ref> put together by Steve Traylen at CERN .


== Package Prerequisites ==
=== Connaissances requises ===
* Connaissances basiques de l'authentification par certificat SSL.
* Connaissances basiques de création de base de données PostgreSQL and d'importation de structure de base
* Connaissances basiques de l'outil psql
* Connaissances basiques de configuration d'Apache
* Connaissances basiques des outils yum/createrepo/mock
* Connaissances basiques de la ligne de commandes
* Connaissances basiques sur la construction de RPM


'''On the server (koji-hub/koji-web)'''
=== Dépendances ===
 
Sur le serveur ({{class|koji-hub}} / {{class|kojiweb}} )
* httpd
* httpd
* mod_ssl
* mod_ssl
* postgresql-server
* postgresql-server
* mod_python (>= 3.3.1 for Kerberos authentication)
* mod_wsgi
* MySQL-python


'''On the builder (koji-builder)'''
Sur les constructeurs ( {{class|kojid}} )
* mock
* mock
* setarch (for some archs you'll require a patched version)
* setarch
* rpm-build
* rpm-build
* createrepo
* createrepo


== A note on filesystem space ==
Si le mode d'authentification choisie est Kerberos, il faudra aussi que le réseau local ait un serveur DNS et une dépendance supplémentaire est à installer sur le serveur et les constructeurs.
Koji will consume copious amounts of disk space under the primary KojiDir directory (as set in the kojihub.conf file).  However, as koji makes use of mock on the backend to actually create build roots and perform the builds in those build roots, it might come to a surprise to users that a running koji server will consume large amounts of disk space under /var/lib/mock and /var/cache/mock as well. Users should either plan the disk and filesystem allocations for this, or plan to modify the default mock build directory in the kojid.conf file. If you change the location, ensure that the new directories are owned by the group "mock" and have 02755 permission.
* mod_auth_kerb
 
=== Espace disque ===
 
comme <class>Koji</class> utilise [[RPM/Mock|Mock]], les répertoires <path>/var/lib/mock</path> et <path>/var/cache/mock</path> grossiront mais une purge de ces répertoires est mise en place par Koji.
 
Les répertoires qui vont grossir au fur et à mesure de l'utilisation sont ceux de:
* Mock:
* La base de données: <path>/var/lib/psql</path>
* Le répertoire principal de Koji: <path>/mnt/koji</path>
* Le répertoire des dépôts: <path>/mnt/repo</path>
Il sera donc judicieux de leur attribuer une partition spécifique avec une taille dynamique (lvm)
 
== Génération des certificats SSL ==
 
Ces certificats serviront à l'authentification des éléments de Koji sur le {{class|koji-hub}}.


=== Setting up SSL Certificates for authentication ===
Création du répertoire des certificats
'''Certificate generation'''
* Create the '''/etc/pki/koji''' directory and copy-and-paste the ssl.cnf listed here, and save it in the new directory. This configuration file is used along with the '''openssl''' command to generate the SSL certificates for the various koji components.


'''ssl.cnf'''
<syntaxhighlight lang="bash">
mkdir /etc/pki/koji && cd /etc/pki/koji
</syntaxhighlight>
Création du fichier de configuration de nos futurs certificats
{{Admon/file|<path>/etc/pki/koji/ssl.cnf</path>|
<pre>
<pre>
HOME                    = .
HOME                    = .
Ligne 75 : Ligne 96 :
default_days            = 3650
default_days            = 3650
default_crl_days        = 30
default_crl_days        = 30
default_md              = md5
default_md              = sha256
preserve                = no
preserve                = no
policy                  = policy_match
policy                  = policy_match
Ligne 88 : Ligne 109 :


[req]  
[req]  
default_bits            = 1024
default_bits            = 4096
default_keyfile        = privkey.pem
default_keyfile        = privkey.pem
distinguished_name      = req_distinguished_name
distinguished_name      = req_distinguished_name
Ligne 101 : Ligne 122 :
countryName_max                = 2
countryName_max                = 2
stateOrProvinceName            = State or Province Name (full name)
stateOrProvinceName            = State or Province Name (full name)
stateOrProvinceName_default    = Paca
stateOrProvinceName_default    = Languedoc Roussilon
localityName                    = Locality Name (eg, city)
localityName                    = Locality Name (eg, city)
localityName_default            = Cavaillon
localityName_default            = Beaucaire
0.organizationName              = Organization Name (eg, company)
0.organizationName              = Organization Name (eg, company)
0.organizationName_default      = B2PWeb
0.organizationName_default      = Home
organizationalUnitName          = Organizational Unit Name (eg, section)
organizationalUnitName          = Organizational Unit Name (eg, section)
commonName                      = Common Name (eg, your name or your server\'s hostname)
commonName                      = Common Name (eg, your name or your server\'s hostname)
Ligne 128 : Ligne 149 :
authorityKeyIdentifier          = keyid:always,issuer:always
authorityKeyIdentifier          = keyid:always,issuer:always
basicConstraints                = CA:true
basicConstraints                = CA:true
</pre>
</pre>}}
{{Admon/note|Modification du fichier ssl.cnf|Bien que cela ne soit pas obligatoire, il est recommandé d'éditer les champs suffixés par '''_default''' dans la section '''[req_distinguished_name]''', afin de coller aux informations du serveur en cours d'installation<br>Cela vous permettra d'accepter directement les valeurs proposées par défaut à la génération des certificats.<br>Les autres sections n'ont pas besoin d'être éditées.}}


Although it is not required, it is recommended that you edit the default values in the '''[req_distinguished_name]''' section of the configuration to match the information for your own server. This will allow you to accept most of the default values when generating certificates later. The other sections can be left unedited.
=== Génération de l'autorité de certification ===


Toujours depuis le répertoire /etc/pki/koji, on initialise notre générateur et on génère l’autorité de certification. Celle-ci se compose d'une paire clé/certificat qui servira à signer tous les autres certificats.


'''Generate CA'''
Ici, le CN sera obligatoirement le nom d'hôte du serveur (FQDN), les autres renseignements ne sont pas bloquants pour la suite.
 
<syntaxhighlight lang="bash">
The CA is the Certificate Authority.  It's the key/cert pair used to sign all the other certificate requests.  When configuring the various koji components, both the client CA and the server CA will be a copy of the CA generated here. The CA certificate will be placed in the '''''/etc/pki/koji''''' directory and the certificates for the other components will be placed in the '''''/etc/pki/koji/certs''''' directory. The '''index.txt''' file which is created is a database of the certificates generated and can be used to view the information for any of the certificates simply by viewing the contents of '''index.txt'''.
 
<pre>
cd /etc/pki/koji/
cd /etc/pki/koji/
mkdir {certs,private,confs}
mkdir {certs,private,confs}
touch index.txt
touch index.txt
echo 01 > serial
echo 01 > serial
openssl genrsa -out private/koji_ca_cert.key 2048
openssl genrsa -out private/koji_ca_cert.key 4096
openssl req -config ssl.cnf -new -x509 -days 3650 -key private/koji_ca_cert.key \
openssl req -config ssl.cnf -new -x509 -days 3650 -key private/koji_ca_cert.key \
-out koji_ca_cert.crt -extensions v3_ca
-out koji_ca_cert.crt -extensions v3_ca
</pre>
</syntaxhighlight>


The last command above will ask you to confirm a number of items about the certificate you are generating. Presumably you already edited the defaults for the country, state/province, locale, and organization in the ssl.cnf file and you only needed to hit enter. It's the organizational unit and the common name that we will be changing in the various certs we create. For the CA itself, these fields don't have a hard requirement. One suggestion for this certificate is to use the FQDN of the server.
=== Générer les certificats des composants de Koji et le certificat de l'administrateur===


Chaque composant de Koji a besoin d'un certificat.
Kojihub et kojiweb ont besoin d'avoir le nome d'hôte pleinement qualifié (FQDN) en CN, on se servira de OU pour distinguer les certificats. Pour les autres certificats, le CN doit être le nom du composant ( kojira ), le login du compte administrateur ou le nom du builder qui sera définit avec koji-client.
Par simplicité, on va se servir de ces scripts pour générer les certificats des composants et les certificats web.


'''Generate the koji component certificates and the admin certificate'''
Script de génération des certificats
 
{{Admon/file|<path>/etc/pki/koji/generate-certificate.sh</path>|
Each koji component needs its own certificate to identify it. Two of the certificates (kojihub and kojiweb) are used as server side certificates that authenticate the server to the client. For this reason, you want the common name on both of those certs to be the fully qualified domain name of the web server they are running on so that clients don't complain about the common name and the server not being the same. You can set the OU for these two certificates to be kojihub and kojiweb for identification purposes.
 
For the other certificates (kojira, kojid, the initial admin account, and all user certificates), the cert is used to authenticate the client to the server. The common name for these certs should be set to the login name for that specific component. For example the common name for the kojira cert should be set to kojira so that it matches the username. The reason for this is that the common name of the cert will be matched to the corresponding user name in the koji database. If there is not a username in the database which matches the CN of the cert the client will not be authenticated and access will be denied.
 
When you later use ''koji add-host'' to add a build machine into the koji database, it creates a user account for that host even though the user account doesn't appear in the user list.  The user account created must match the common name of the certificate which that component uses to authenticate with the server. When creating the kojiweb certificate, you'll want to remember exactly what values you enter for each field as you'll have to regurgitate those into the /etc/koji-hub/hub.conf file as the ProxyDNs entry.
 
When you need to create multiple certificates it may be convenient to create a loop or a script like the on listed below and run the script to create the certificates. You can simply adjust the number of kojibuilders and the name of the admin account as you see fit. For much of this guide, the admin account is called "kojiadmin".
 
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
#!/bin/bash
#!/bin/bash
Ligne 176 : Ligne 191 :
echo "Generate certificates for \"${user}\""
echo "Generate certificates for \"${user}\""


openssl genrsa -out certs/${user}.key 2048
openssl genrsa -out certs/${user}.key 4096


cat ssl.cnf | sed 's/insert_hostname/'${user}'/'> ssl2.cnf
cat ssl.cnf | sed 's/insert_hostname/'${user}'/'> ssl2.cnf
Ligne 189 : Ligne 204 :
mv ssl2.cnf confs/${user}-ssl.cnf
mv ssl2.cnf confs/${user}-ssl.cnf


</syntaxhighlight>
</syntaxhighlight>}}


''' Generate a PKCS12 user certificate (for web browser)'''
Script de génération des certificats pour les navigateurs Web
This is only required for user certificates.
{{Admon/file|<path>/etc/pki/koji/generate-web-certificate.sh</path>|
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
#!/bin/bash
#!/bin/bash
Ligne 211 : Ligne 226 :
openssl pkcs12 -export -inkey certs/${user}.key -in certs/${user}.crt -CAfile ${caname}_ca_cert.crt \
openssl pkcs12 -export -inkey certs/${user}.key -in certs/${user}.crt -CAfile ${caname}_ca_cert.crt \
-out certs/${user}_browser_cert.p12
-out certs/${user}_browser_cert.p12
</syntaxhighlight>}}
On génère les certificats comme cela pour tous les composants et users du tableau récapitulatif:
<syntaxhighlight lang="bash">
cd /etc/pki/koji/
./generate-certificate.sh kojiweb
</syntaxhighlight>
</syntaxhighlight>
Le user choisi pour être le koji admin est le user didier.


When generating certs for a user, the user will need the ${user}.pem, the ${caname}_ca_cert.crt, and the ${user}_browser_cert.p12 files which were generated above.  The ${user}.pem file would normally be installed as ~/.fedora.cert, the ${caname}_ca_cert.crt file would be installed as both ~/.fedora-upload-ca.cert and ~/.fedora-server-ca.cert, and the user would import the ${user}_brower_cert.p12 into their web browser as a personal certificate.
De plus pour les utilisateurs (réels) de {{class|koji}}, on générera les certificats web comme ceci:
<syntaxhighlight lang="bash">
./generate-web-certificate.sh didier
</syntaxhighlight>


{| cellpadding="5" cellspacing="0" border="1"
{| class="wikitable"
! Nom du certificat
! Nom du certificat
! CN (commonName)
! CN (commonName)
Ligne 221 : Ligne 246 :
|-
|-
| kojihub
| kojihub
| didier.b2pweb.com (FQDN)
| koji.didier-linux.eu (FQDN)
| kojihub
| kojihub
|-
|-
| kojiweb
| kojiweb
| didier.b2pweb.com (FQDN)
| koji.didier-linux.eu (FQDN)
| kojiweb
| kojiweb
|-
|-
| kojira
| kojira
| kojira
| kojira
| SRS
| Admin
|-
|-
| didier ( utilisateur koji admin )
| didier ( utilisateur koji admin )
| didier@didier.b2pweb.com ( ici c'est le user et non le nom d'hôte de la machine et le domaine servira pour l'envoi d'email )
| didier ( ici c'est le user et non le nom d'hôte de la machine )
| SRS
| Admin
|-
| gilles ( utilisateur koji )
| gilles@didier.b2pweb.com ( le domaine servira pour l'envoi d'email )
| SRS
|-
| bastien ( utilisateur koji )
| bastien@didier.b2pweb.com ( le domaine servira pour l'envoi d'email )
| SRS
|-
| builder-didier
| builder-didier.b2pweb.com
| kojibuilder
|-
|-
| builder-gilles
| kojibuilder.didier-linux.eu
| builder-gilles.b2pweb.com
| kojibuilder.didier-linux.eu
| kojibuilder
| builder
|}
|}


'''Add Koji users to aliases'''
=== Copier les certificats dans le home de utilisateur admin ===
 
On copie le certificat correspondant à l'administrateur du {{class|Koji}}, et l'autorité de certification dans son home.
 
<syntaxhighlight lang="bash">
mkdir ~/.koji
cp /etc/pki/koji/didier.pem ~/.koji/client.crt
cp /etc/pki/koji/koji_ca_cert.crt ~/.koji/clientca.crt
cp /etc/pki/koji/koji_ca_cert.crt ~/.koji/serverca.crt
</syntaxhighlight>
{{Admon/note|Modification des paramètres par défaut|Pour modifier des paramètre d'un client sans modifier la configuration générale, il faut copier le fichier <path>/etc/koji.conf</path> dans le home de l'utilisateur <path>~/.koji/config</path> et y effectuer les modifications dans celui-ci.}}


Edition du fichier <path>/etc/aliases</path> for appairer les utilisateurs Koji aux véritables adresses mail.
==Mise en place des principals Kerberos==
<pre>
# Person who should get root's mail
root:          dfabert@b2pweb.com


didier:        dfabert@b2pweb.com
Le serveur Kerberos doit pouvoir être trouvé grâce au DNS. Le point final indique que l'hôte est pleinement qualifié (FQDN).
bastien:        bhermitte@b2pweb.com
<pre>_kerberos._udp    IN SRV  10 100 88 kerberos.didier-linux.eu.</pre>
gilles:        ggaudin@b2pweb.com
</pre>


'''Copy certificates into ~/.koji for kojiadmin'''
{| class="wikitable"
! Principal
! Utilisation
|-
| host/kojihub@DIDIER-LINUX.EU
| Utiliser par koji-hub pour communiquer avec le client koji
|-
| HTTP/kojiweb@DIDIER-LINUX.EU
| Utiliser par koji-web pour négotier une authentifiaction avec le navigateur web. C'est le principal pour l'authentification Apache <package>mod_auth_kerb</package>.
|-
| koji/kojiweb@DIDIER-LINUX.EU
| Utiliser par koji-web pour communiquer avec koji-hub. C'est le principal qui va authentifier koji-web sur Kerberos comme "koji/kojiweb@EXAMPLE.COM". Koji-web relayera aussi le nom d'utilisateur (authentification Apache) vers koji-hub (koji-hub config option '''''ProxyPrincipals''''').
|-
| koji/kojira@DIDIER-LINUX.EU
| Utiliser par kojira pour communiquer avec koji-hub
|-
| compile/builder1@DIDIER-LINUX.EU
| Utiliser par le constructeur koji pour communiquer avec koji-hub
|}


==Ajout des utilisateurs Koji aux alias du serveur de mail local==


You're going to want to be able to send admin commands to the kojihub. In order to do so, you'll need to use the newly created certificates to authenticate with the hub. Create the kojiadmin user then copy the certificates for the koji CA and the kojiadmin user to ~/.koji:
Bien évidemment, un serveur [[Mail/MTA/Sendmail|sendmail]] en local est déjà configuré et opérationnel.


Appairer les utilisateurs Koji aux véritables adresses mail.
{{Admon/file|<path>/etc/aliases</path>|
<pre>
<pre>
kojiadmin@localhost$ mkdir ~/.koji
# Person who should get root's mail
kojiadmin@localhost$ cp /etc/pki/koji/kojiadmin.pem ~/.koji/client.crt
root:          didier@didier-linux.eu
kojiadmin@localhost$ cp /etc/pki/koji/koji_ca_cert.crt ~/.koji/clientca.crt
didier:        didier@didier-linux.eu
kojiadmin@localhost$ cp /etc/pki/koji/koji_ca_cert.crt ~/.koji/serverca.crt
</pre>}}
</pre>


'''Note:''' See /etc/koji.conf for the current system wide koji client configuration.  Copy /etc/koji.conf to ~/.koji/config if you wish to change the config on a per user basis.
Puis lancer la régénération des alias
  # newaliases


== PostgreSQL Server ==
== Serveur PostgreSQL ==
Once the authentication scheme has been setup your will need to install and configure a PostgreSQL server and prime the database which will be used to hold the koji users.
Une fois l'autentification mise en place, nous avons besoin d'installer un serveur [[DBMS/PostgreSQL/Brief|PostgreSQL]], de le configurer et de mettre en place la structure de la base de données pour {{class|Koji}}.
 
'''Fichiers de Configuration :'''
'''Configuration Files:'''


* /var/lib/pgsql/data/pg_hba.conf
* /var/lib/pgsql/data/pg_hba.conf
* /var/lib/pgsql/data/postgresql.conf
* /var/lib/pgsql/data/postgresql.conf


'''Install PostgreSQL:'''
===Installation du serveur PostgreSQL===
<pre>
<pre>
root@localhost$ yum install postgresql-server
yum install postgresql-server
</pre>
</pre>


'''Initialize PostgreSQL DB:'''
===Initialisation de la base de données PostgreSQL===


The following commands will initialize PostgreSQL and will start the database service
Les commandes suivantes initialise le serveur [[DBMS/PostgreSQL/Brief|PostgreSQL]] et le démarre.
<pre>
Le script d'init a été converti à systemd sur les distributions Fedora 16 et supérieures et la cible '''initdb''' du script d'init a été supprimée. On initialise directement avec les commandes du SGBD.
root@localhost$ service postgresql initdb
<syntaxhighlight lang="bash">
root@localhost$ service postgresql start
su - postgres -c "PGDATA=/var/lib/pgsql/data initdb"
</pre>
systemctl start postgresql.service
</syntaxhighlight>
{{admon/tip|Initialisation du SGBD sur les distributions sysVinit|<pre>service postgresql initdb && service postgresql start</pre>}}


{{admon/note|initdb on Fedora 16|The PostgreSQL init script has been converted to systemd in Fedora 16, so the initdb function has been removed.  To run initdb directly:  <pre>su - postgres -c "PGDATA=/var/lib/pgsql/data initdb"</pre>}}
=== Compte utilisateur ===


'''Setup User Accounts:'''
Mise en place du compte '''koji''' sur le système (utilisateur unix) et mise en place d'un mot de passe.
<syntaxhighlight lang="bash">
useradd koji
passwd koji
</syntaxhighlight>


The following commands will setup the '''koji''' account and assign it a password
=== Setup de PostgreSQL et import de la structure de la base ===
<pre>
root@localhost$ useradd koji
root@localhost$ passwd -d koji
</pre>


'''Setup PostgreSQL and populate schema:'''
Création de l'utilisateur PostgreSQL '''koji''' et création de sa base de données, puis import de la structure.
 
{{Admon/bug|Import de la structure|Il est important laisser le joker (*) afin de ne pas se restreindre à une version particulière de Koji. Durant des test, il a été découvert que la restriction à une version spécifique de Koji ne créé pas  correctement toutes les tables.}}
The following commands will create the '''koji''' user within PostgreSQL and will then create the koji database using the schema within the /usr/share/doc/koji*/docs/schema.sql directory
<syntaxhighlight lang="bash">
<pre>
su - postgres
root@localhost$ su - postgres
createuser koji
postgres@localhost$ createuser koji
Shall the new role be a superuser? (y/n) n
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
postgres@localhost$ createdb -O koji koji
createdb -O koji koji
postgres@localhost$ logout
logout
root@localhost$ su - koji
</syntaxhighlight>
koji@localhost$ psql koji koji < /usr/share/doc/koji*/docs/schema.sql
<syntaxhighlight lang="bash">
koji@localhost$ exit
su - koji
</pre>
psql koji koji < /usr/share/doc/koji*/docs/schema.sql
exit
</syntaxhighlight>


'''NOTE:''' When issuing the command to import the psql schema into the new database it is important to ensure that the directory path /usr/share/doc/koji*/docs/schema.sql remains intact and is not resolved to a specific version of koji. In test it was discovered that when the path is resolved to a specific version of koji then not all of the tables were created correctly
=== Autorisation de Koji-web et Koji-hub aux resources===
''Dans cet exemple, Koji-web et Koji-hub sont démarrés sur localhost.''


 
Ces paramètres doivent être ajouter avant les autres.
'''Authorize Koji-web and Koji-hub resources:'''
Fichier <path>/var/lib/pgsql/data/pg_hba.conf</path>
''In this example, Koji-web and Koji-hub are running on localhost.''
{{Admon/file|<path>/var/lib/pgsql/data/pg_hba.conf</path>|
 
/var/lib/pgsql/data/pg_hba.conf:
''These settings need to be valid and inline with other services configurations.''
''Please note, the first matching auth line is used so this line must be above any other potential matches.''
''Add:''
<pre>
<pre>
host    koji        koji        127.0.0.1/32          trust
host    koji        koji        127.0.0.1/32          trust
host    koji        koji          ::1/128            trust
host    koji        koji          ::1/128            trust
</pre>
</pre>}}
''You can also use UNIX socket access. The DBHost variable must be unset to use this method.''
On peut aussi utiliser les sockets UNIX. La variable '''''DBHost''''' variable ne doit pas être renseigné avec cette méthode.
''Add:''
{{Admon/file|<path>/var/lib/pgsql/data/pg_hba.conf</path>|
<pre>
<pre>
local  koji        apache                            trust
local  koji        apache                            trust
Ligne 347 : Ligne 384 :
local  koji        apache        ::1/128            trust
local  koji        apache        ::1/128            trust
local  koji        koji                              trust
local  koji        koji                              trust
</pre>
</pre>}}


'''Make auth changes live:'''
=== Application des changements à chaud ===


The following commands let postgreSQL know that changes have been made and forces it to reload its configuration so that changes become active
Informer postgreSQL que les fichiers de configuration doivent être relus.
<pre>
<syntaxhighlight lang="bash">
root@localhost$ su - postgres
root@localhost$ su - postgres
postgres@localhost$ pg_ctl reload
postgres@localhost$ pg_ctl reload
postgres@localhost$ exit
postgres@localhost$ exit
</pre>
</syntaxhighlight>


'''Bootstrapping the initial koji admin user into the PostgreSQL database:'''
=== Ajout du premier administrateur du Koji à la base PostgreSQL ===


The initial admin user must be manually added to the user database using sql commands. Once they are added and given admin privilege, they may add additional users and change privileges of those users via the koji command line tool's administrative commands.  However, if you choose to use the simple user/pass method of authentication, then any password setting/changing must be done manually via sql commands as there is no password manipulation support exposed through the koji tools.
Le premier administrateur du <class>Koji</class> doit être ajouter à la main avec des commandes SQL. Une fois ajouté avec les droits administarteur, Il pourra gérer les autres utilisateurs de <class>Koji</class> avec l'outil d'administration en ligne de commande.


'''SSL Certificate authentication:''' there is no need for either a password or a Kerberos principal, so this will suffice:
Pour l'authentifiaction SSL ou Kerberos, il n'y a pas besoin de mettre un mot de passe.
 
<syntaxhighlight lang="bash">
<pre>
root@localhost$ su - koji
root@localhost$ su - koji
koji@localhost$ psql
koji@localhost$ psql
koji=> insert into users (name, status, usertype) values ('admin-user-name', 0, 0);
koji=> insert into users (name, status, usertype) values ('admin-user-name', 0, 0);
</pre>
</syntaxhighlight>


'''Give yourself admin permissions'''
=== Se donner les droits admin ===


The following command will give the user admin permissions. In order to do this you will need to know the ID of the user.
Commande permettant de se donner les droits administrateur. Pour la lancer, on doit connaitre l'ID de l'utilisateur.
<pre>
<pre>
koji=> insert into user_perms (user_id, perm_id, creator_id) values (<id of user inserted above>, 1, <id of user inserted above>);
koji=> insert into user_perms (user_id, perm_id, creator_id) values (<ID of user inserted above>, 1, <ID of user inserted above>);
</pre>
</pre>
 
{{Admon/tip|Connaitre l'ID des utilisateurs|Pour connaitre les IDs des utilisateurs du <class>Koji</class>, on doit lancer une commande SQL.
Note: If you do not know the ID of the admin user, you can get the ID by running the query:
<pre>
<pre>
koji=> select * from users;
koji=> select * from users;
</pre>
</pre>}}


You can't actually log in and perform any actions until kojihub is up and running in your web server.  In order to get to that point you still need to complete the authentication setup and the kojihub configuration.  If you wish to access koji via a web browser, you will also need to get kojiweb up and running.
A ce stade, aucune action ne peut être démarrée tant que le kojihub n'est pas configuré et le serveur web démarré.


== Koji Hub ==
== Koji Hub ==


Koji-hub is the center of all Koji operations. It is an XML-RPC server running under mod_python in Apache. koji-hub is passive in that it only receives XML-RPC calls and relies upon the build daemons and other components to initiate communication. Koji-hub is the only component that has direct access to the database and is one of the two components that have write access to the file system.
koji-hub est le centre nerveux de toutes les opérations Koji. Il s'agit d'un serveur XML-RPC fonctionnant sous mod_python pour Apache. koji-hub est passif : il ne reçoit que les appels XML-RPC et s'appuie sur les autres outils de la suite pour la construction. koji-hub est le seul composant qui a un accès direct à la base de données et est l'un des deux composants qui ont un accès en écriture au système de fichiers.  


 
'''Fichiers de Configuration'''
'''Configuration Files:'''


* /etc/httpd/conf/httpd.conf
* /etc/httpd/conf/httpd.conf
Ligne 395 : Ligne 429 :
* /etc/httpd/conf.d/ssl.conf (when using ssl auth)
* /etc/httpd/conf.d/ssl.conf (when using ssl auth)
* /etc/koji-hub/hub.conf
* /etc/koji-hub/hub.conf
* /etc/koji.conf


Le répertoire de travail sera <path>/mnt/koji</path>.
{{Admon/bug|Répertoire de travail de Koji|Si le répertoire de travail de Koji n'est pas <path>/mnt/koji</path>, il est impératif de créer un lien symbolique du répertoire de travail de Koji dans <path>/mnt</path>:
<pre>ln -s /path/to/koji/datadir /mnt/koji</pre>}}


'''Install koji-hub:'''
===Installation de {{class|koji-hub}}===
<pre>
<pre>
root@localhost$ yum install koji-hub httpd mod_ssl mod_python
yum install koji-hub httpd mod_ssl
</pre>
</pre>


==== Required Configuration ====
=== Configuration ===
 
'''/etc/httpd/conf/httpd.conf:'''


The apache web server has two places that it sets maximum requests a server will handle before the server restarts. The xmlrpc interface in kojihub is a python application, and mod_python can sometimes grow outrageously large when it doesn't reap memory often enough. As a result, it is strongly recommended that you set both instances of MaxRequestsPerChild in httpd.conf to something reasonable in order to prevent the server from becoming overloaded and crashing (at 100 the httpd processes will grow to about 75MB resident set size before respawning).


<pre>
On bride tout d'abord le nombre maximum de requête sur le serveur [[Webserver/Apache|apache]] à une valeur plus raisonnable afin de prévenir une saturation et/ou un crash du serveur web.
{{Admon/file|<path>/etc/httpd/conf/httpd.conf</path>|
<syntaxhighlight lang="apache">
<IfModule prefork.c>
<IfModule prefork.c>
...
...
Ligne 417 : Ligne 454 :
MaxRequestsPerChild  100
MaxRequestsPerChild  100
</IfModule>
</IfModule>
</pre>
</syntaxhighlight>}}
 
Le répertoire <path>/mnt/koji/packages</path> doit être accessible par HTTP. On ajoute donc un alias.


You'll need to make /mnt/koji/packages web-accessible, either here on the hub, or on koji-web, or on another web server altogether. This URL will later go into the builders' pkgurl config option.
{{Admon/file|<path>/etc/httpd/conf.d/kojipackages.conf</path>|
<pre>
<syntaxhighlight lang="apache">
Alias /packages/ /mnt/koji/packages/
Alias /packages "/mnt/koji/packages"
<Directory "/mnt/koji/packages">
<Directory "/mnt/koji/packages">
     Options Indexes
        Options Indexes
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>
</syntaxhighlight>}}
 
{{Admon/file|<path>/etc/httpd/conf.d/ssl.conf</path>|
<syntaxhighlight lang="apache">
LoadModule ssl_module modules/mod_ssl.so
 
Listen 443
 
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
 
SSLSessionCache        shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout  300
 
SSLMutex default
 
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
 
SSLCryptoDevice builtin
 
<VirtualHost _default_:443>
  ErrorLog logs/ssl_error_log
  TransferLog logs/ssl_access_log
  LogLevel warn
 
  SSLEngine on
  SSLProtocol all -SSLv2
  SSLCipherSuite RC4-SHA:AES128-SHA:ALL:!ADH:!EXP:!LOW:!MD5:!SSLV2:!NULL
 
  SSLCertificateFile /etc/pki/koji/certs/kojihub.crt
  SSLCertificateKeyFile /etc/pki/koji/certs/kojihub.key
  SSLCertificateChainFile /etc/pki/koji/koji_ca_cert.crt
  SSLCACertificateFile /etc/pki/koji/koji_ca_cert.crt
  SSLVerifyClient require
  SSLVerifyDepth  10
 
  <Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
  </Files>
  <Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
  </Directory>
 
  SetEnvIf User-Agent ".*MSIE.*" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
 
  CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
</syntaxhighlight>}}
 
{{Admon/file|<path>/etc/httpd/conf.d/kojihub.conf</path>|
<syntaxhighlight lang="apache">
Alias /kojihub /usr/share/koji-hub/kojixmlrpc.py
 
<Directory "/usr/share/koji-hub">
    Options ExecCGI
    SetHandler wsgi-script
    Order allow,deny
    Allow from all
</Directory>
 
Alias /kojifiles "/mnt/koji/"
 
<Directory "/mnt/koji">
     Options Indexes SymLinksIfOwnerMatch
     AllowOverride None
     AllowOverride None
     Order allow,deny
     Order allow,deny
     Allow from all
     Allow from all
</Directory>
</Directory>
</pre>


'''/etc/koji-hub/hub.conf:'''
<Location /kojihub/ssllogin>
        SSLVerifyClient require
        SSLVerifyDepth  10
        SSLOptions +StdEnvVars
</Location>


This file contains the configuration information for the hub. You will need to edit this configuration to point Koji Hub to the database you are using and to setup Koji Hub to utilize the authentication scheme you selected in the beginning.
<Location /kojihub>
        SSLOptions +StdEnvVars
</Location>
</syntaxhighlight>}}


<pre>
{{Admon/file|<path>/etc/koji-hub/hub.conf</path>|
<syntaxhighlight lang="ini">
[hub]
DBName = koji
DBName = koji
DBUser = koji
DBUser = koji
DBHost = db.example.com
DBHost = localhost
KojiDir = /mnt/koji
KojiDir = /mnt/koji
LoginCreatesUser = On
KojiWebURL = http://kojiweb.example.com/koji
</pre>


/etc/koji-hub/hub.conf:
''If using SSL auth, these settings need to be valid and inline with other services configurations for kojiweb to allow logins.
ProxyDNs should be set to the DN of the kojiweb certificate.''
<pre>
DNUsernameComponent = CN
DNUsernameComponent = CN
ProxyDNs = /C=US/ST=Massachusetts/O=Example Org/OU=Example User/CN=example/emailAddress=example@example.com
ProxyDNs = C=FR,ST=Languedoc Roussillon,L=Beaucaire,O=Home,OU=kojiweb,CN=koji.didier-linux.eu,emailAddress=root@didier-linux.eu
</pre>
 
/etc/httpd/conf.d/kojihub.conf:
LoginCreatesUser = On
''If using SSL auth, uncomment these lines for kojiweb to allow logins."
KojiWebURL = http://koji.didier-linux.eu/koji
<pre>
EmailDomain = didier-linux.eu
<Location /kojihub>
NotifyOnSuccess = True
SSLOptions +StdEnvVars
</syntaxhighlight>}}
</Location>
</pre>


/etc/httpd/conf.d/ssl.conf:
{{Admon/file|<path>/etc/koji.conf</path>|
''If using SSL you will also need to add the needed SSL options for apache. These options should point to where the certificates are located on the hub.''
<syntaxhighlight lang="ini">
<pre>
[koji]
SSLCertificateFile /etc/pki/koji/certs/kojihub.crt
server = http://koji.didier-linux.eu/kojihub
SSLCertificateKeyFile /etc/pki/koji/certs/kojihub.key
weburl = http://koji.didier-linux.eu/koji
SSLCertificateChainFile /etc/pki/koji/koji_ca_cert.crt
topurl = http://koji.didier-linux.eu/kojifiles
SSLCACertificateFile /etc/pki/koji/koji_ca_cert.crt
topdir = /mnt/koji
SSLVerifyClient require
cert = ~/.koji/client.crt
SSLVerifyDepth  10
ca = ~/.koji/clientca.crt
</pre>
serverca = ~/.koji/serverca.crt
</syntaxhighlight>}}


==== SELinux Configuration ====
=== Configuration de [[Security/SELinux|SELinux]] ===
If running in Enforcing mode, you will need to allow apache to connect to the postgreSQL server. Even if you are not running currently running in Enforcing mode it is still recommended to run the following command to ensure that there are no future issues with SELinux if Enforcing mode is later enabled.
Si le mode enforcing est utilisé, on doit autoriser [[Webserver/Apache|apache]] à acceder au serveur [[SGBD/PostgreSQL]]. Même si le mode est permissive, il est recommandé de lancer la commande suivante afin de se prémunir d'un changement de mode de [[Security/SELinux|SELinux]].


<pre>
<pre>
root@localhost$ setsebool -P httpd_can_network_connect_db 1
setsebool -P httpd_can_network_connect_db 1
</pre>
</pre>


==== Koji filesystem skeleton ====
=== Squelette des fichiers Koji ===


Above in the kojihub.conf file we set KojiDir to /mnt/koji.  For certain reasons, if you change this, you should make a symlink from /mnt/koji to the new location (note: this is a bug and should be fixed eventually).  However, before other parts of koji will operate properly, we need to create a skeleton filesystem structure for koji as well as make the file area owned by apache so that the xmlrpc interface can write to it as needed.
Avant que les autres composants de Koji puissent fonctionner correctement, On doit créer la structure et modifié les droits de celui-ci.


<pre>
<syntaxhighlight lang="bash">
cd /mnt
cd /mnt
mkdir koji
mkdir koji
Ligne 486 : Ligne 596 :
mkdir {packages,repos,work,scratch}
mkdir {packages,repos,work,scratch}
chown apache.apache *
chown apache.apache *
</pre>
</syntaxhighlight>


At this point, you can now restart apache and you should have at least minimal operation.  The admin user should be able to connect via the command line client, add new users, etc.  It's possible at this time to undertake initial administrative steps such as adding users and hosts to the koji database.
Ici, [[Webserver/Apache|apache]] peut être redémarré et on peut effectuer des opérations minimales sur notre serveur Koji via le client en ligne de commande: gestion des utilisateurs et des constructeurs.


Ensure that your client is configured to work with your server. The system-wide koji client configuration file is ''/etc/koji.conf'', and the user-specific one is in ''~/.koji/config''. You may also use the "-c" option when using the Koji client to specify an alternative configuration file. The following command will test your login to the hub:
Il faut s'assurer que le client est configuré par défaut ( fichier <path>/etc/koji.conf</path> et que les certificats sont en place dans le home de l'administrateur.


{{Admon/note|Fichier de configuration alternatif|Si un fichier de configuration personnel autre que <path>~/.koji/config</path> est utilisé, il faut utilisé la commande koji avec l'option '''-c'''.}}
La commande suivante teste le login administrateur sur le serveur Koji.
  koji call getLoggedInUser
  koji call getLoggedInUser


If you are using SSL for authentication, you will need to edit the Koji client configuration to tell it which URLs to use for the various Koji components and where their SSL certificates can be found.
{{Admon/important|Droit des daemons|Kojira a besoin du privilège '''repo''' avant le lancement du daemon. C'est pourquoi il est vivement recommandé de créer cet utilisateur maintenant et de lui ajouter le privilège
 
<pre>
[koji]
 
;url of XMLRPC server
server = http://hongkong.proximity.on.ca/kojihub
 
;url of web interface
weburl = http://hongkong.proximity.on.ca/koji
 
;url of package download site
pkgurl = http://hongkong.proximity.on.ca/packages
 
;path to the koji top directory
topdir = /mnt/koji
 
;configuration for SSL athentication
;client certificate
cert = ~/.koji/client.crt
 
;certificate of the CA that issued the client certificate
ca = ~/.koji/clientca.crt
 
;certificate of the CA that issued the HTTP server certificate
serverca = ~/.koji/serverca.crt
</pre>
 
It is important to note that the kojira component needs repo privileges, but if you just let the account get auto created the first time you run kojira, it won't have that privilege, so you should pre-create the account and grant it the repo privilege now.


<pre>
<pre>
kojiadmin@localhost$ koji add-user kojira
koji add-user kojira
kojiadmin@localhost$ koji grant-permission repo kojira
koji grant-permission repo kojira
</pre>
</pre>


For similar technical reasons, you need to add-host each build host prior to starting kojid on that host the first time and could also do that now.
Pour des raisons similaires, les hôtes de constructions doivent être ajoutés avant le démarrage du daemon kojid.


<pre>
<pre>
kojiadmin@localhost$ koji add-host kojibuilder1 x86_64 i386
koji add-host kojibuilder1 x86_64 i386
kojiadmin@localhost$ koji add-host kojibuilder2 ppc ppc64
koji add-host kojibuilder2 ppc ppc64
kojiadmin@localhost$ koji add-host kojibuilder3 ia64
koji add-host kojibuilder3 ia64
</pre>
</pre>}}


== Koji Web - Interface for the Masses ==
== Koji Web - Interface for the Masses ==


Koji-web is a set of scripts that run in mod_python and use the Cheetah templating engine to provide an web interface to Koji. koji-web exposes a lot of information and also provides a means for certain operations, such as cancelling builds.
Koji-web est un jeu de scripts qui tournent avec mod_wsgi et qui utilise le moteur de modèle Cheetah pour fournir une interface web à Koji. Koji-web affiche beaucoup d'informations et propose même quelques opérations comme l'abandon de tâche.
 
'''Configuration Files:'''


'''Fichiers de Configuration:'''
* /etc/kojiweb/web.conf
* /etc/httpd/conf.d/kojiweb.conf
* /etc/httpd/conf.d/kojiweb.conf
* /etc/httpd/conf.d/ssl.conf
* /etc/httpd/conf.d/ssl.conf


'''Install Koji-Web:'''
'''Installation de Koji-Web:'''
<pre>
<pre>
root@localhost$ yum install koji-web mod_ssl
yum install koji-web mod_ssl
</pre>
</pre>


==== Required Configuration ====
==== Configuration obligatoire ====
/etc/httpd/conf.d/kojiweb.conf: You will need to edit the kojiweb configuration file to tell kojiweb which URLs it should use to access the hub, the koji packages and its own web interface. You will also need to tell kojiweb where it can find the SSL certificates for each of these components. If you are using SSL authentication, the "PythonOption WebCert" line below must contain both the public ''and'' private key. You will also want to change the last line in the example below to a unique password.
 
La configuration doit fournir à Koji-web les URLs d'accès à Koji-hub, aux paquets koji (builds) et à sa propre interface. Il est judicieux de modifier aussi le secret (directive ''PythonOption Secret''.
 
Avec l'authentification SSL, elle doit aussi fournir le nom des certificats à utiliser et la directive ''PythonOption WebCert'' doit contenir '''la clé publique ET la clé privée'''.
{{Admon/file|<path>/etc/kojiweb/web.conf</path>|
<pre>
<pre>
PythonOption KojiHubURL http://hub.example.com/kojihub
[web]
PythonOption KojiWebURL http://www.example.com/koji
SiteName = koji
PythonOption KojiPackagesURL http://server.example.com/mnt/koji/packages
KojiTheme = didier


KojiHubURL http://koji.didier-linux.eu/kojihub
KojiFilesURL http://www.didier-linux.eu/kojifiles


PythonOption WebCert /etc/pki/koji/kojiweb.pem
WebCert /etc/pki/koji/kojiweb.pem
PythonOption ClientCA /etc/pki/koji/koji_ca_cert.crt
ClientCA /etc/pki/koji/koji_ca_cert.crt
PythonOption KojiHubCA /etc/pki/koji/koji_ca_cert.crt
KojiHubCA /etc/pki/koji/koji_ca_cert.crt


PythonOption LoginTimeout 72
LoginTimeout 72
PythonOption Secret CHANGE_ME
Secret CHANGE_ME
</pre>
 
LibPath = /usr/share/koji-web/lib
</pre>}}


==== Optional Configuration ====
==== Configuration Optionnelle ====


You will also need to edit the '''/etc/httpd/conf.d/kojiweb.conf''' to configure it for the authentication scheme you have selected at the beginning of the setup.  
Il faut éditer le fichier <path>/etc/httpd/conf.d/kojiweb.conf</path> pour configurer l'authentification choisie.


/etc/httpd/conf.d/kojiweb.conf:
{{Admon/file|<path>/etc/httpd/conf.d/kojiweb.conf</path>|
''If using SSL, these settings need to be valid and inline with other services configurations.''
<pre>
<pre>
<Location /koji/login>
<Location /koji/login>
SSLOptions +StdEnvVars
SSLOptions +StdEnvVars
</Location>
</Location>
</pre>
</pre>}}


/etc/httpd/conf.d/ssl.conf:
{{Admon/file|<path>/etc/httpd/conf.d/ssl.conf</path>|
''If you are using SSL you will need to add the needed SSL options for apache.''
<pre>
<pre>
SSLVerifyClient require
SSLVerifyClient require
SSLVerifyDepth  10
SSLVerifyDepth  10
</pre>
</pre>}}


==== Web interface now operational ====
==== Interface Web opérationnelle ====


At this point you should be able to point your web browser at the kojiweb URL and be presented with the koji interface.  Many operations should work in read only mode at this point, and any configured users should be able to log in.
L'interface Web du koji est maintenant accessible et la plupart des opérations de lecture doivent fonctionner et chaque utilisateur doit pouvoir se connecter.


== Koji Daemon - Builder ==
== Koji Daemon - Builder ==


Kojid is the build daemon that runs on each of the build machines. Its primary responsibility is polling for incoming build requests and handling them accordingly. Koji also has support for tasks other than building such as creating livecd images or raw disk images, and kojid is responsible for handling these tasks as well. kojid uses mock for creating pristine build environments and creates a fresh one for every build, ensuring that artifacts of build processes cannot contaminate each other. kojid is written in Python and communicates with koji-hub via XML-RPC.
Kojid est le daemon de construction qui tourne sur chaque constructeur. son rôle principale est de traiter les requêtes de construction. Koji ne se limite cependant pas aux tâches de construction puisqu'il peut aussi construire des images ISO, des disques virtuels (appliances). Kojid utilise mock pour créer des environnements de construction minimaliste et en créé pour chaque construction. Ceci permet le compartimentage des constructions et les constructions ne peuvent pas se gêner les unes les autres. Kojid est écrit en python et communique avec le hub via XML-RPC.
 
'''Configuration Files:'''


* /etc/kojid/kojid.conf - Koji Daemon Configuration
'''fichiers de Configuration'''
* /etc/sysconfig/kojid - Koji Daemon Switches
* Configuration du daemon Kojira: /etc/kojid/kojid.conf
* Variables de lancement du daemon: /etc/sysconfig/kojid


'''Install kojid:'''
'''Installation de kojid:'''
<pre>
<pre>
root@localhost$ yum install koji-builder
yum install koji-builder
</pre>
</pre>


==== Required Configuration ====
==== Configuration générale ====


/etc/kojid/kojid.conf:
Le fichier de configuration de chaque constructeur doit être édité afin que la directive ''server'' pointe sur l'hôte supportant le Koji-hub. La directive ''user'' doit contenir le nom d'hôte du constructeur.
''The configuration file for each koji builder must be edited so that the line below points to the URL for the koji hub. The user tag must also be edited to point to the username used to add the koji builder.''
{{Admon/file|<path>/etc/kojid/kojid.conf</path>|
<pre>
<pre>
; The URL for the xmlrpc server
; The URL for the xmlrpc server
Ligne 615 : Ligne 704 :
; in this example follow as below
; in this example follow as below
user = kojibuilder1.example.com
user = kojibuilder1.example.com
</pre>
</pre>}}


''This item may be changed, but may not be the same as KojiDir on the kojihub.conf file (although it can be something under KojiDir, just not the same as KojiDir)''
La directive ''workdir'' peut être différente entre les constructeurs mais elle ne doit pas être le répertoire de travail du Koji (<path>/mnt/koji</path>)
{{Admon/file|<path>/etc/kojid/kojid.conf</path>|
<pre>
<pre>
; The directory root for temporary storage
; The directory root for temporary storage
workdir=/tmp/koji
workdir=/tmp/koji
</pre>
</pre>}}


==== Optional Configuration (SSL certificates) ====
==== Configuration des certificats SSL ====


/etc/kojid/kojid.conf:
Ces entrées doivent être éditées pour pointer sur les bons certificats générés précédemment.
''If you are using SSL, these settings need to be edited to point to the certificates you generated at the beginning of the setup process.''
{{Admon/file|<path>/etc/kojid/kojid.conf</path>|
<pre>
<pre>
;client certificate
;client certificate
Ligne 638 : Ligne 728 :
;certificate of the CA that issued the HTTP server certificate
;certificate of the CA that issued the HTTP server certificate
serverca = /etc/kojid/koji_ca_cert.crt
serverca = /etc/kojid/koji_ca_cert.crt
</pre>
</pre>}}
{{Admon/important|Copie des certificats sur l'hôte|Les certificats SSL doivent être copiés depuis l'hôte abritant le Koji-hub sur les constructeurs dans le répertoire <path>/etc/kojid</path> pour que les constructeurs puissent s'authentifier.}}


It is important to note that if your builders are hosted on seperate machines from koji hub and koji web, you will need to scp the certificates mentioned in the above configuration file from the /etc/kojid/ directory on koji hub to the /etc/koji/ directory on the local machine so that the builder can be authenticated.
==== Ajout d'un hôte à la base de données des constructeurs ====


==== Add the host entry for the koji builder to the database ====
Il faut maintenant ajouter l'hôte à la base de données des constructeurs afin qu'il puisse être utilisé par Koji-hub.
You will now need to add the koji builder to the database so that they can be utilized by kojij hub. Make sure you do this before you start kojid for the first time,
{{Admon/important|L'ajout doit être fait avant le premier démarrage du daemon de construction|Sinon, il faudra purger les entrées à la main dans les tables ''sessions'' et ''users
or you'll need to manually remove entries from the sessions and users
'' avant de pouvoir démarrer avec succès le daemon.}}
table before it can be run successfully.  
<pre>
<pre>
kojiadmin@localhost$ koji add-host kojibuilder1.example.com i386 x86_64
koji add-host kojibuilder1.didier-linux.eu i386 x86_64
</pre>
</pre>
The first argument used after the ''add-host'' command should the username of the builder. The second argument is used to specify the architecture which the builder uses.
Le premier argument après la commande est le nom d'hôte du constructeur. Le second argument spécifie l'(les) architecture(s) utilisées par l'hôtes.


==== Add the host to the createrepo channel ====
==== Ajout de l'hôte au canal de création ====
Channels are a way to control which builders process which tasks.  By default
hosts are added to the ''default'' channel.  At least some build hosts also needs to be added
to the ''createrepo'' channel so there will be someone to process repo creation tasks initiated by kojira.


Les canaux sont un moyen de contrôler quel constructeur fait quoi. Par défaut les hôtes sont ajouté au canal ''default''. Il faut qu'au moins quelques uns (1 au minimum) soient ajoutés au canal ''createrepo'' pour pouvoir lancer les travaux kojira sur les dépôts.
<pre>
<pre>
kojiadmin@localhost$ koji add-host-to-channel kojibuilder1.example.com createrepo
koji add-host-to-channel kojibuilder1.didier.eu createrepo
</pre>
</pre>


==== A note on capacity ====
==== Capacité ====
The default capacity of a host added to the host database is 2.  This means that once the load average on that machine exceeds 2, kojid will not accept any additional tasks. This is separate from the maxjobs item in the configuration file. Before kojid will accept a job, it must pass both the test to ensure the load average is below capacity and that the current number of jobs it is already processing is less than maxjobs. However, in today's modern age of quad core and higher CPUs, a load average of 2 is generally insufficient to fully utilize hardware. As there is not an option to set the capacity of the host via the command line tools, it must be done manually in psql.
 
La capacité d'un hôte par défaut est de 2, ce qui veut dire que le daemond econstruction n'acceptera pas de travail supplémentaire si le load average est supérieur à 2. Ce paramètre est différent de celui du nombre maximal de travaux (fichier de configuration). Avant que ledaemon de construction n'accepte un nouveau travail, il s'assure que le load average est inférieur à la capacité et que le nombre de travaux est inférieur au nombre maximal. Toutefois, à l'ère des CPU multi-coeurs, un load average de 2 est insuffisant pour consommer 100% des ressources du système. Il n'y a pas d'option pour définir la capacité en ligne de commande, cela doit être fait en base (psql).


<pre>
<pre>
Ligne 668 : Ligne 757 :
               row               
               row               
--------------------------------
--------------------------------
  (1,kojibuilder1.example.com,2)
  (1,kojibuilder1.didier-linux.eu,2)
  (2,kojibuilder2.example.com,2)
  (2,kojibuilder2.didier-linux.eu,2)
(2 rows)
(2 rows)


Ligne 677 : Ligne 766 :
</pre>
</pre>


==== Start Kojid ====
==== Démarrage du daemon Kojid ====


Once the builder has been added to the database you must start kojira
Une fois le constructeur ajouté à la base de données, on peut démarrer son daemon de construction.
<pre>
<pre>
root@localhost$ /sbin/service kojid start
systemctl start kojid
</pre>
</pre>
Check /var/log/kojid.log to verify that kojid has started successfully. If the log does not show any errors then the koji builder should be up and ready. You can check this by pointing your web browser to the web interface and clicking on the hosts tab. This will show you a list of builders in the database and the status of each builder.
On vérifie dans le fichier <path>/var/log/kojid.log</path> qur le daemon a bien démarré. Si aucune erreur n'est rapportée, c'est que le daemon doit être correctement configuré et démarré. On peut le vérifier sur l'interface Koji-web dans l'onglet ''hôtes''. Cette page affiche le liste des constructeurs et leur status.


== Kojira - Yum repository creation and maintenance ==
== Kojira - Création et maintenance du dépôt ==
'''Configuration Files:'''
'''Fichiers de Configuration:'''
 
* Configuration du daemon Kojira: <path>/etc/kojira/kojira.conf</path>
* /etc/kojira/kojira.conf - Kojira Daemon Configuration
* Variables de lancement du daemon: <path>/etc/sysconfig/kojira</path>
* /etc/sysconfig/kojira - Kojira Daemon Switches
 
'''Install kojira'''
<pre>
root@localhost$ yum install koji-utils
</pre>


==== Required Configuration ====
'''Installation de kojira'''
yum install koji-utils


/etc/kojira/kojira.conf:
==== Configuration générale ====
''This needs to point at your koji-hub.''
La directive ''server'' a besoin de pointer sur le koji-hub.
{{Admon/file|<path>/etc/kojira/kojira.conf</path>|
<pre>
<pre>
; The URL for the xmlrpc server
; The URL for the xmlrpc server
server=http://hub.example.com/kojihub
server=http://koji.didier-linux.eu/kojihub
</pre>
</pre>}}
 
{{Admon/important|Note importante|
<br>
* Kojira a besoin d'un accès en lecture/écriture sur <path>/mnt/koji</path>.  
 
* Il ne devrait exister qu'une seule instance de {{class|kojira}} à la fois.
'''Additional Notes:'''
* Il n'est pas recommandé de lancer kojira sur les constructeurs, car ceux-ci n'ont besoin que d'un accès en lecture seule sur le répertoire <path>/mnt/koji</path>.}}
* Kojira needs read-write access to /mnt/koji.  
* There should only be one instance of kojira running at any given time.
* It is not recommended that kojira run on the builders, as builders only should require read-only access to /mnt/koji.


==== Optional Configuration ====
==== Configuration de l'authentification SSL ====


/etc/kojira/kojira.conf:
{{Admon/file|<path>/etc/kojira/kojira.conf</path>|
''If using SSL, these settings need to be valid.''
<pre>
<pre>
;client certificate
;client certificate
Ligne 726 : Ligne 807 :
;certificate of the CA that issued the HTTP server certificate
;certificate of the CA that issued the HTTP server certificate
serverca = /etc/pki/koji/koji_ca_cert.crt
serverca = /etc/pki/koji/koji_ca_cert.crt
</pre>
</pre>}}


/etc/sysconfig/kojira:
''The local user kojira runs as needs to be able to read and write to /mnt/koji/repos/.
''The local user kojira runs as needs to be able to read and write to /mnt/koji/repos/.
If the volume that directory resides on is root-squashed or otherwise unmodifiable
If the volume that directory resides on is root-squashed or otherwise unmodifiable
by root, you can set '''RUNAS=''' to a user that has the required privileges.''
by root, you can set '''RUNAS=''' to a user that has the required privileges.''


==== Add the user entry for the kojira user ====
{{Admon/file|<path>/etc/sysconfig/kojira</path>|
If you did not already do so above, create the kojira user, and grant it the '''repo''' permission.
<pre>
<pre>
kojiadmin@localhost$ koji add-user kojira
FORCE_LOCK=Y
kojiadmin@localhost$ koji grant-permission repo kojira
KOJIRA_DEBUG=N
KOJIRA_VERBOSE=Y
RUNAS=root
</pre>}}
 
==== Ajout de l'utilisateur kojira à Koji ====
Si cela n'a pas été déjà fait, création de l'utilisateur kojira et ajout du droit '''repo''' à celui-ci. Cela doit être fait avec le compte de l'administrateur de Koji.
<pre>
koji add-user kojira
koji grant-permission repo kojira
</pre>
</pre>


=== Start Kojira ===
=== Démarrage du deamon Kojira ===
<pre>
<pre>
root@localhost$ /sbin/service kojira start
systemctl start kojira.service
</pre>
On vérifie dans le fichier <path>/var/log/kojira/kojira.log</path> que {{class|kojira}} a bien démarré.
 
== SELinux ==
<pre>
semanage fcontext -a -t httpd_sys_rw_content_t '/mnt/koji(/.*)?'
restorecon -Rv /mnt/koji
</pre>
</pre>
Check /var/log/kojira/kojira.log to verify that kojira has started successfully.


==Notes==
==Notes==
<references />
<references />
[[Catégorie:RPM|Install Koji]]
[[Catégorie:Koji|Install]]
[[Catégorie:Server|Install Koji]]

Dernière version du 23 avril 2015 à 11:38

Mettre en place un système de construction de RPM Koji

Présentation

Koji est une suite logicielle de construction de RPM. Il utilise mock pour créer des environnements chrootés et y effectuer les builds.

Architecture du koji
  • Koji-Hub
    C'est le centre nerveux de toutes les opérations Koji. Il s'agit d'un serveur XML-RPC fonctionnant sous mod_python pour Apache. koji-hub est passif : il ne reçoit que les appels XML-RPC et s'appuie sur les autres outils de la suite pour la construction. koji-hub est le seul composant qui a un accès direct à la base de données et est l'un des deux composants qui ont un accès en écriture au système de fichiers.
  • Kojid ou Koji-builder
    C'est le démon de compilation qui s'exécute sur chacune des machines de construction. Sa principale responsabilité est de scruter les demandes de construction entrantes et de les exécuter. Pour cela, kojid interroge koji-hub. Kojid est également responsable d'autres tâches que la construction : la création d'images d'installation par exemple. kojid utilise Mock pour la construction. Il crée également un buildroot vierge pour chaque génération. kojid est écrit en Python et communique avec koji-hub par l'intermédiaire de XML-RPC.
  • Koji-Web
    C'est un ensemble de scripts qui s'exécutent avec mod_python et utilise le moteur de templates Cheetah pour fournir une interface web à Koji. Il agit comme un client à koji-hub en offrant une interface d'aministration limitée. koji-Web expose un grand nombre d'informations et fournit également un moyen pour certaines opérations, telles que l'annulation de builds.
  • Koji-client
    C'est une interface en ligne de commande ( CLI = Command Line Interface ) écrit en Python qui fournit de nombreux hooks à Koji. Il permet à l'utilisateur d'interroger la plupart des données ainsi que d'effectuer des actions telles que l'ajout d'utilisateurs et de lancer la construction des demandes.
  • Kojira
    C'est un démon qui garde la racine de construction repodata à jour. Il est responsable de l'enlèvement des racines redondantes et du nettoyage après une demande de construction est terminée.

Les composants de Koji peuvent être installés sur des serveurs différents. La seule obligation est d'autoriser la communication entre les différents composants de la suite.

Koji supporte nativement l'authentification par serveur Kerberos et par certificat SSL. Seul koji-client supporte l'authentification par mot de passe. De ce fait, l'authentification par mot de passe ne sera même pas abordée.

La méthode d'authentification doit être choisie dès le début de l'installation. Dans la suite de ce document, nous mettrons en place la méthode SSL.

Koji utilise beaucoup d'espace disque dans son répertoire primaire <path>/mnt/koji</path>. De plus Mock en utilisera beaucoup aussi sur les répertoires <path>/var/lib/mock</path> et <path>/var/cache/mock</path>. Il vaut mieux prévoir des partitions dédiées à ces répertoires ( les répertoires de Mock doivent appartenir au groupe mock et avoir les permissions 02755 ).

Pour un aperçu rapide des outils utilisés : yum, mock, Koji (et tous ses composants), mash, et comment ils fonctionnent ensemble, il existe une excellente présentation [1] créée par Steve Traylen du CERN.

Le dépôt git de RussianFedora avec les fichiers de configuration de Koji [2]

Connaissances requises

  • Connaissances basiques de l'authentification par certificat SSL.
  • Connaissances basiques de création de base de données PostgreSQL and d'importation de structure de base
  • Connaissances basiques de l'outil psql
  • Connaissances basiques de configuration d'Apache
  • Connaissances basiques des outils yum/createrepo/mock
  • Connaissances basiques de la ligne de commandes
  • Connaissances basiques sur la construction de RPM

Dépendances

Sur le serveur (koji-hub / kojiweb )

  • httpd
  • mod_ssl
  • postgresql-server
  • mod_wsgi
  • MySQL-python

Sur les constructeurs ( kojid )

  • mock
  • setarch
  • rpm-build
  • createrepo

Si le mode d'authentification choisie est Kerberos, il faudra aussi que le réseau local ait un serveur DNS et une dépendance supplémentaire est à installer sur le serveur et les constructeurs.

  • mod_auth_kerb

Espace disque

comme <class>Koji</class> utilise Mock, les répertoires <path>/var/lib/mock</path> et <path>/var/cache/mock</path> grossiront mais une purge de ces répertoires est mise en place par Koji.

Les répertoires qui vont grossir au fur et à mesure de l'utilisation sont ceux de:

  • Mock:
  • La base de données: <path>/var/lib/psql</path>
  • Le répertoire principal de Koji: <path>/mnt/koji</path>
  • Le répertoire des dépôts: <path>/mnt/repo</path>

Il sera donc judicieux de leur attribuer une partition spécifique avec une taille dynamique (lvm)

Génération des certificats SSL

Ces certificats serviront à l'authentification des éléments de Koji sur le koji-hub.

Création du répertoire des certificats

 mkdir /etc/pki/koji && cd /etc/pki/koji

Création du fichier de configuration de nos futurs certificats

TextFileIcon16.png <path>/etc/pki/koji/ssl.cnf</path>
HOME                    = .
RANDFILE                = .rand

[ca] 
default_ca              = ca_default

[ca_default] 
dir                     = .
certs                   = $dir/certs
crl_dir                 = $dir/crl
database                = $dir/index.txt
new_certs_dir           = $dir/newcerts
certificate             = $dir/%s_ca_cert.pem
private_key             = $dir/private/%s_ca_key.pem
serial                  = $dir/serial
crl                     = $dir/crl.pem
x509_extensions         = usr_cert
name_opt                = ca_default
cert_opt                = ca_default
default_days            = 3650
default_crl_days        = 30
default_md              = sha256
preserve                = no
policy                  = policy_match

[policy_match] 
countryName             = match
stateOrProvinceName     = match
organizationName        = match
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

[req] 
default_bits            = 4096
default_keyfile         = privkey.pem
distinguished_name      = req_distinguished_name
attributes              = req_attributes
x509_extensions         = v3_ca # The extentions to add to the self signed cert
string_mask             = MASK:0x2002

[req_distinguished_name] 
countryName                     = Country Name (2 letter code)
countryName_default             = FR
countryName_min                 = 2
countryName_max                 = 2
stateOrProvinceName             = State or Province Name (full name)
stateOrProvinceName_default     = Languedoc Roussilon
localityName                    = Locality Name (eg, city)
localityName_default            = Beaucaire
0.organizationName              = Organization Name (eg, company)
0.organizationName_default      = Home
organizationalUnitName          = Organizational Unit Name (eg, section)
commonName                      = Common Name (eg, your name or your server\'s hostname)
commonName_max                  = 64
emailAddress                    = Email Address
emailAddress_max                = 64

[req_attributes] 
challengePassword               = A challenge password
challengePassword_min           = 4
challengePassword_max           = 20
unstructuredName                = An optional company name

[usr_cert] 
basicConstraints                = CA:FALSE
nsComment                       = "OpenSSL Generated Certificate"
subjectKeyIdentifier            = hash
authorityKeyIdentifier          = keyid,issuer:always

[v3_ca] 
subjectKeyIdentifier            = hash
authorityKeyIdentifier          = keyid:always,issuer:always
basicConstraints                = CA:true
Note.png
Modification du fichier ssl.cnf
Bien que cela ne soit pas obligatoire, il est recommandé d'éditer les champs suffixés par _default dans la section [req_distinguished_name], afin de coller aux informations du serveur en cours d'installation
Cela vous permettra d'accepter directement les valeurs proposées par défaut à la génération des certificats.
Les autres sections n'ont pas besoin d'être éditées.

Génération de l'autorité de certification

Toujours depuis le répertoire /etc/pki/koji, on initialise notre générateur et on génère l’autorité de certification. Celle-ci se compose d'une paire clé/certificat qui servira à signer tous les autres certificats.

Ici, le CN sera obligatoirement le nom d'hôte du serveur (FQDN), les autres renseignements ne sont pas bloquants pour la suite.

cd /etc/pki/koji/
mkdir {certs,private,confs}
touch index.txt
echo 01 > serial
openssl genrsa -out private/koji_ca_cert.key 4096
openssl req -config ssl.cnf -new -x509 -days 3650 -key private/koji_ca_cert.key \
-out koji_ca_cert.crt -extensions v3_ca

Générer les certificats des composants de Koji et le certificat de l'administrateur

Chaque composant de Koji a besoin d'un certificat. Kojihub et kojiweb ont besoin d'avoir le nome d'hôte pleinement qualifié (FQDN) en CN, on se servira de OU pour distinguer les certificats. Pour les autres certificats, le CN doit être le nom du composant ( kojira ), le login du compte administrateur ou le nom du builder qui sera définit avec koji-client. Par simplicité, on va se servir de ces scripts pour générer les certificats des composants et les certificats web.

Script de génération des certificats

TextFileIcon16.png <path>/etc/pki/koji/generate-certificate.sh</path>
#!/bin/bash
#if you change your certificate authority name to something else you will need to change the caname value to reflect the change.
caname=koji

# user is equal to parameter one or the first argument when you actually run the script
user=$1

if [[ "$user" == "" ]]
then
	echo "Usage: $(basename $0) USER"
	exit
fi

echo "Generate certificates for \"${user}\""

openssl genrsa -out certs/${user}.key 4096

cat ssl.cnf | sed 's/insert_hostname/'${user}'/'> ssl2.cnf

openssl req -config ssl2.cnf -new -nodes -out certs/${user}.csr -key certs/${user}.key

openssl ca -config ssl2.cnf -keyfile private/${caname}_ca_cert.key -cert ${caname}_ca_cert.crt \
	-out certs/${user}.crt -outdir certs -infiles certs/${user}.csr

cat certs/${user}.crt certs/${user}.key > ${user}.pem

mv ssl2.cnf confs/${user}-ssl.cnf

Script de génération des certificats pour les navigateurs Web

TextFileIcon16.png <path>/etc/pki/koji/generate-web-certificate.sh</path>
#!/bin/bash
#if you change your certificate authority name to something else you will need to change the caname value to reflect the change.
caname=koji

# user is equal to parameter one or the first argument when you actually run the script
user=$1

if [[ "$user" == "" ]]
then
	echo "Usage: $(basename $0) USER"
	exit
fi

echo "Generate web certificates for \"${user}\""

openssl pkcs12 -export -inkey certs/${user}.key -in certs/${user}.crt -CAfile ${caname}_ca_cert.crt \
	-out certs/${user}_browser_cert.p12

On génère les certificats comme cela pour tous les composants et users du tableau récapitulatif:

cd /etc/pki/koji/
./generate-certificate.sh kojiweb

Le user choisi pour être le koji admin est le user didier.

De plus pour les utilisateurs (réels) de koji, on générera les certificats web comme ceci:

./generate-web-certificate.sh didier
Nom du certificat CN (commonName) OU (organizationalUnitName)
kojihub koji.didier-linux.eu (FQDN) kojihub
kojiweb koji.didier-linux.eu (FQDN) kojiweb
kojira kojira Admin
didier ( utilisateur koji admin ) didier ( ici c'est le user et non le nom d'hôte de la machine ) Admin
kojibuilder.didier-linux.eu kojibuilder.didier-linux.eu builder

Copier les certificats dans le home de utilisateur admin

On copie le certificat correspondant à l'administrateur du Koji, et l'autorité de certification dans son home.

mkdir ~/.koji
cp /etc/pki/koji/didier.pem ~/.koji/client.crt
cp /etc/pki/koji/koji_ca_cert.crt ~/.koji/clientca.crt
cp /etc/pki/koji/koji_ca_cert.crt ~/.koji/serverca.crt
Note.png
Modification des paramètres par défaut
Pour modifier des paramètre d'un client sans modifier la configuration générale, il faut copier le fichier <path>/etc/koji.conf</path> dans le home de l'utilisateur <path>~/.koji/config</path> et y effectuer les modifications dans celui-ci.

Mise en place des principals Kerberos

Le serveur Kerberos doit pouvoir être trouvé grâce au DNS. Le point final indique que l'hôte est pleinement qualifié (FQDN).

_kerberos._udp    IN SRV  10 100 88 kerberos.didier-linux.eu.
Principal Utilisation
host/kojihub@DIDIER-LINUX.EU Utiliser par koji-hub pour communiquer avec le client koji
HTTP/kojiweb@DIDIER-LINUX.EU Utiliser par koji-web pour négotier une authentifiaction avec le navigateur web. C'est le principal pour l'authentification Apache <package>mod_auth_kerb</package>.
koji/kojiweb@DIDIER-LINUX.EU Utiliser par koji-web pour communiquer avec koji-hub. C'est le principal qui va authentifier koji-web sur Kerberos comme "koji/kojiweb@EXAMPLE.COM". Koji-web relayera aussi le nom d'utilisateur (authentification Apache) vers koji-hub (koji-hub config option ProxyPrincipals).
koji/kojira@DIDIER-LINUX.EU Utiliser par kojira pour communiquer avec koji-hub
compile/builder1@DIDIER-LINUX.EU Utiliser par le constructeur koji pour communiquer avec koji-hub

Ajout des utilisateurs Koji aux alias du serveur de mail local

Bien évidemment, un serveur sendmail en local est déjà configuré et opérationnel.

Appairer les utilisateurs Koji aux véritables adresses mail.

TextFileIcon16.png <path>/etc/aliases</path>
# Person who should get root's mail
root:           didier@didier-linux.eu
didier:         didier@didier-linux.eu

Puis lancer la régénération des alias

# newaliases

Serveur PostgreSQL

Une fois l'autentification mise en place, nous avons besoin d'installer un serveur PostgreSQL, de le configurer et de mettre en place la structure de la base de données pour Koji. Fichiers de Configuration :

  • /var/lib/pgsql/data/pg_hba.conf
  • /var/lib/pgsql/data/postgresql.conf

Installation du serveur PostgreSQL

yum install postgresql-server

Initialisation de la base de données PostgreSQL

Les commandes suivantes initialise le serveur PostgreSQL et le démarre. Le script d'init a été converti à systemd sur les distributions Fedora 16 et supérieures et la cible initdb du script d'init a été supprimée. On initialise directement avec les commandes du SGBD.

su - postgres -c "PGDATA=/var/lib/pgsql/data initdb"
systemctl start postgresql.service
Idea.png
Initialisation du SGBD sur les distributions sysVinit
service postgresql initdb && service postgresql start

Compte utilisateur

Mise en place du compte koji sur le système (utilisateur unix) et mise en place d'un mot de passe.

useradd koji
passwd koji

Setup de PostgreSQL et import de la structure de la base

Création de l'utilisateur PostgreSQL koji et création de sa base de données, puis import de la structure.

Bug.png
Import de la structure
Il est important laisser le joker (*) afin de ne pas se restreindre à une version particulière de Koji. Durant des test, il a été découvert que la restriction à une version spécifique de Koji ne créé pas correctement toutes les tables.
su - postgres
createuser koji
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
createdb -O koji koji
logout
su - koji
psql koji koji < /usr/share/doc/koji*/docs/schema.sql
exit

Autorisation de Koji-web et Koji-hub aux resources

Dans cet exemple, Koji-web et Koji-hub sont démarrés sur localhost.

Ces paramètres doivent être ajouter avant les autres. Fichier <path>/var/lib/pgsql/data/pg_hba.conf</path>

TextFileIcon16.png <path>/var/lib/pgsql/data/pg_hba.conf</path>
host    koji        koji        127.0.0.1/32          trust
host    koji        koji          ::1/128             trust

On peut aussi utiliser les sockets UNIX. La variable DBHost variable ne doit pas être renseigné avec cette méthode.

TextFileIcon16.png <path>/var/lib/pgsql/data/pg_hba.conf</path>
local   koji        apache                            trust
local   koji        apache      127.0.0.1/32          trust
local   koji        apache        ::1/128             trust
local   koji        koji                              trust

Application des changements à chaud

Informer postgreSQL que les fichiers de configuration doivent être relus.

root@localhost$ su - postgres
postgres@localhost$ pg_ctl reload
postgres@localhost$ exit

Ajout du premier administrateur du Koji à la base PostgreSQL

Le premier administrateur du <class>Koji</class> doit être ajouter à la main avec des commandes SQL. Une fois ajouté avec les droits administarteur, Il pourra gérer les autres utilisateurs de <class>Koji</class> avec l'outil d'administration en ligne de commande.

Pour l'authentifiaction SSL ou Kerberos, il n'y a pas besoin de mettre un mot de passe.

root@localhost$ su - koji
koji@localhost$ psql
koji=> insert into users (name, status, usertype) values ('admin-user-name', 0, 0);

Se donner les droits admin

Commande permettant de se donner les droits administrateur. Pour la lancer, on doit connaitre l'ID de l'utilisateur.

koji=> insert into user_perms (user_id, perm_id, creator_id) values (<ID of user inserted above>, 1, <ID of user inserted above>);
Idea.png
Connaitre l'ID des utilisateurs
Pour connaitre les IDs des utilisateurs du <class>Koji</class>, on doit lancer une commande SQL.
koji=> select * from users;

A ce stade, aucune action ne peut être démarrée tant que le kojihub n'est pas configuré et le serveur web démarré.

Koji Hub

koji-hub est le centre nerveux de toutes les opérations Koji. Il s'agit d'un serveur XML-RPC fonctionnant sous mod_python pour Apache. koji-hub est passif : il ne reçoit que les appels XML-RPC et s'appuie sur les autres outils de la suite pour la construction. koji-hub est le seul composant qui a un accès direct à la base de données et est l'un des deux composants qui ont un accès en écriture au système de fichiers.

Fichiers de Configuration

  • /etc/httpd/conf/httpd.conf
  • /etc/httpd/conf.d/kojihub.conf
  • /etc/httpd/conf.d/ssl.conf (when using ssl auth)
  • /etc/koji-hub/hub.conf
  • /etc/koji.conf

Le répertoire de travail sera <path>/mnt/koji</path>.

Bug.png
Répertoire de travail de Koji
Si le répertoire de travail de Koji n'est pas <path>/mnt/koji</path>, il est impératif de créer un lien symbolique du répertoire de travail de Koji dans <path>/mnt</path>:
ln -s /path/to/koji/datadir /mnt/koji

Installation de koji-hub

yum install koji-hub httpd mod_ssl

Configuration

On bride tout d'abord le nombre maximum de requête sur le serveur apache à une valeur plus raisonnable afin de prévenir une saturation et/ou un crash du serveur web.

TextFileIcon16.png <path>/etc/httpd/conf/httpd.conf</path>
<IfModule prefork.c>
...
MaxRequestsPerChild  100
</IfModule>
<IfModule worker.c>
...
MaxRequestsPerChild  100
</IfModule>

Le répertoire <path>/mnt/koji/packages</path> doit être accessible par HTTP. On ajoute donc un alias.

TextFileIcon16.png <path>/etc/httpd/conf.d/kojipackages.conf</path>
Alias /packages "/mnt/koji/packages"
<Directory "/mnt/koji/packages">
        Options Indexes
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>
TextFileIcon16.png <path>/etc/httpd/conf.d/ssl.conf</path>
LoadModule ssl_module modules/mod_ssl.so

Listen 443

SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog

SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout  300

SSLMutex default

SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin

SSLCryptoDevice builtin

<VirtualHost _default_:443>
  ErrorLog logs/ssl_error_log
  TransferLog logs/ssl_access_log
  LogLevel warn

  SSLEngine on
  SSLProtocol all -SSLv2
  SSLCipherSuite RC4-SHA:AES128-SHA:ALL:!ADH:!EXP:!LOW:!MD5:!SSLV2:!NULL

  SSLCertificateFile /etc/pki/koji/certs/kojihub.crt
  SSLCertificateKeyFile /etc/pki/koji/certs/kojihub.key
  SSLCertificateChainFile /etc/pki/koji/koji_ca_cert.crt
  SSLCACertificateFile /etc/pki/koji/koji_ca_cert.crt
  SSLVerifyClient require
  SSLVerifyDepth  10

  <Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
  </Files>
  <Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
  </Directory>

  SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

  CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
TextFileIcon16.png <path>/etc/httpd/conf.d/kojihub.conf</path>
Alias /kojihub /usr/share/koji-hub/kojixmlrpc.py

<Directory "/usr/share/koji-hub">
    Options ExecCGI
    SetHandler wsgi-script
    Order allow,deny
    Allow from all
</Directory>

Alias /kojifiles "/mnt/koji/"

<Directory "/mnt/koji">
    Options Indexes SymLinksIfOwnerMatch
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Location /kojihub/ssllogin>
        SSLVerifyClient require
        SSLVerifyDepth  10
        SSLOptions +StdEnvVars
</Location>

<Location /kojihub>
        SSLOptions +StdEnvVars
</Location>
TextFileIcon16.png <path>/etc/koji-hub/hub.conf</path>
[hub]
DBName = koji
DBUser = koji
DBHost = localhost
KojiDir = /mnt/koji

DNUsernameComponent = CN
ProxyDNs = C=FR,ST=Languedoc Roussillon,L=Beaucaire,O=Home,OU=kojiweb,CN=koji.didier-linux.eu,emailAddress=root@didier-linux.eu

LoginCreatesUser = On
KojiWebURL = http://koji.didier-linux.eu/koji
EmailDomain = didier-linux.eu
NotifyOnSuccess = True
TextFileIcon16.png <path>/etc/koji.conf</path>
[koji]
server = http://koji.didier-linux.eu/kojihub
weburl = http://koji.didier-linux.eu/koji
topurl = http://koji.didier-linux.eu/kojifiles
topdir = /mnt/koji
cert = ~/.koji/client.crt
ca = ~/.koji/clientca.crt
serverca = ~/.koji/serverca.crt

Configuration de SELinux

Si le mode enforcing est utilisé, on doit autoriser apache à acceder au serveur SGBD/PostgreSQL. Même si le mode est permissive, il est recommandé de lancer la commande suivante afin de se prémunir d'un changement de mode de SELinux.

setsebool -P httpd_can_network_connect_db 1

Squelette des fichiers Koji

Avant que les autres composants de Koji puissent fonctionner correctement, On doit créer la structure et modifié les droits de celui-ci.

cd /mnt
mkdir koji
cd koji
mkdir {packages,repos,work,scratch}
chown apache.apache *

Ici, apache peut être redémarré et on peut effectuer des opérations minimales sur notre serveur Koji via le client en ligne de commande: gestion des utilisateurs et des constructeurs.

Il faut s'assurer que le client est configuré par défaut ( fichier <path>/etc/koji.conf</path> et que les certificats sont en place dans le home de l'administrateur.

Note.png
Fichier de configuration alternatif
Si un fichier de configuration personnel autre que <path>~/.koji/config</path> est utilisé, il faut utilisé la commande koji avec l'option -c.

La commande suivante teste le login administrateur sur le serveur Koji.

koji call getLoggedInUser
Important.png
Droit des daemons
Kojira a besoin du privilège repo avant le lancement du daemon. C'est pourquoi il est vivement recommandé de créer cet utilisateur maintenant et de lui ajouter le privilège
koji add-user kojira
koji grant-permission repo kojira

Pour des raisons similaires, les hôtes de constructions doivent être ajoutés avant le démarrage du daemon kojid.

koji add-host kojibuilder1 x86_64 i386
koji add-host kojibuilder2 ppc ppc64
koji add-host kojibuilder3 ia64

Koji Web - Interface for the Masses

Koji-web est un jeu de scripts qui tournent avec mod_wsgi et qui utilise le moteur de modèle Cheetah pour fournir une interface web à Koji. Koji-web affiche beaucoup d'informations et propose même quelques opérations comme l'abandon de tâche.

Fichiers de Configuration:

  • /etc/kojiweb/web.conf
  • /etc/httpd/conf.d/kojiweb.conf
  • /etc/httpd/conf.d/ssl.conf

Installation de Koji-Web:

yum install koji-web mod_ssl

Configuration obligatoire

La configuration doit fournir à Koji-web les URLs d'accès à Koji-hub, aux paquets koji (builds) et à sa propre interface. Il est judicieux de modifier aussi le secret (directive PythonOption Secret.

Avec l'authentification SSL, elle doit aussi fournir le nom des certificats à utiliser et la directive PythonOption WebCert doit contenir la clé publique ET la clé privée.

TextFileIcon16.png <path>/etc/kojiweb/web.conf</path>
[web]
SiteName = koji
KojiTheme = didier

KojiHubURL http://koji.didier-linux.eu/kojihub
KojiFilesURL http://www.didier-linux.eu/kojifiles

WebCert /etc/pki/koji/kojiweb.pem
ClientCA /etc/pki/koji/koji_ca_cert.crt
KojiHubCA /etc/pki/koji/koji_ca_cert.crt

LoginTimeout 72
Secret CHANGE_ME

LibPath = /usr/share/koji-web/lib

Configuration Optionnelle

Il faut éditer le fichier <path>/etc/httpd/conf.d/kojiweb.conf</path> pour configurer l'authentification choisie.

TextFileIcon16.png <path>/etc/httpd/conf.d/kojiweb.conf</path>
<Location /koji/login>
SSLOptions +StdEnvVars
</Location>
TextFileIcon16.png <path>/etc/httpd/conf.d/ssl.conf</path>
SSLVerifyClient require
SSLVerifyDepth  10

Interface Web opérationnelle

L'interface Web du koji est maintenant accessible et la plupart des opérations de lecture doivent fonctionner et chaque utilisateur doit pouvoir se connecter.

Koji Daemon - Builder

Kojid est le daemon de construction qui tourne sur chaque constructeur. son rôle principale est de traiter les requêtes de construction. Koji ne se limite cependant pas aux tâches de construction puisqu'il peut aussi construire des images ISO, des disques virtuels (appliances). Kojid utilise mock pour créer des environnements de construction minimaliste et en créé pour chaque construction. Ceci permet le compartimentage des constructions et les constructions ne peuvent pas se gêner les unes les autres. Kojid est écrit en python et communique avec le hub via XML-RPC.

fichiers de Configuration

  • Configuration du daemon Kojira: /etc/kojid/kojid.conf
  • Variables de lancement du daemon: /etc/sysconfig/kojid

Installation de kojid:

yum install koji-builder

Configuration générale

Le fichier de configuration de chaque constructeur doit être édité afin que la directive server pointe sur l'hôte supportant le Koji-hub. La directive user doit contenir le nom d'hôte du constructeur.

TextFileIcon16.png <path>/etc/kojid/kojid.conf</path>
; The URL for the xmlrpc server
server=http://hub.example.com/kojihub

; the username has to be the same as what you used with add-host
; in this example follow as below
user = kojibuilder1.example.com

La directive workdir peut être différente entre les constructeurs mais elle ne doit pas être le répertoire de travail du Koji (<path>/mnt/koji</path>)

TextFileIcon16.png <path>/etc/kojid/kojid.conf</path>
; The directory root for temporary storage
workdir=/tmp/koji

Configuration des certificats SSL

Ces entrées doivent être éditées pour pointer sur les bons certificats générés précédemment.

TextFileIcon16.png <path>/etc/kojid/kojid.conf</path>
;client certificate
; This should reference the builder certificate we created above, for
; kojibuilder1.example.com
cert = /etc/kojid/kojid.pem

;certificate of the CA that issued the client certificate
ca = /etc/kojid/koji_ca_cert.crt

;certificate of the CA that issued the HTTP server certificate
serverca = /etc/kojid/koji_ca_cert.crt
Important.png
Copie des certificats sur l'hôte
Les certificats SSL doivent être copiés depuis l'hôte abritant le Koji-hub sur les constructeurs dans le répertoire <path>/etc/kojid</path> pour que les constructeurs puissent s'authentifier.

Ajout d'un hôte à la base de données des constructeurs

Il faut maintenant ajouter l'hôte à la base de données des constructeurs afin qu'il puisse être utilisé par Koji-hub.

Important.png
L'ajout doit être fait avant le premier démarrage du daemon de construction
Sinon, il faudra purger les entrées à la main dans les tables sessions et users avant de pouvoir démarrer avec succès le daemon.
koji add-host kojibuilder1.didier-linux.eu i386 x86_64

Le premier argument après la commande est le nom d'hôte du constructeur. Le second argument spécifie l'(les) architecture(s) utilisées par l'hôtes.

Ajout de l'hôte au canal de création

Les canaux sont un moyen de contrôler quel constructeur fait quoi. Par défaut les hôtes sont ajouté au canal default. Il faut qu'au moins quelques uns (1 au minimum) soient ajoutés au canal createrepo pour pouvoir lancer les travaux kojira sur les dépôts.

koji add-host-to-channel kojibuilder1.didier.eu createrepo

Capacité

La capacité d'un hôte par défaut est de 2, ce qui veut dire que le daemond econstruction n'acceptera pas de travail supplémentaire si le load average est supérieur à 2. Ce paramètre est différent de celui du nombre maximal de travaux (fichier de configuration). Avant que ledaemon de construction n'accepte un nouveau travail, il s'assure que le load average est inférieur à la capacité et que le nombre de travaux est inférieur au nombre maximal. Toutefois, à l'ère des CPU multi-coeurs, un load average de 2 est insuffisant pour consommer 100% des ressources du système. Il n'y a pas d'option pour définir la capacité en ligne de commande, cela doit être fait en base (psql).

koji@localhost$ psql koji
koji=# select (id, name, capacity) from host;
              row               
--------------------------------
 (1,kojibuilder1.didier-linux.eu,2)
 (2,kojibuilder2.didier-linux.eu,2)
(2 rows)

koji=# update host set capacity = 16 where id = 1;
UPDATE 1
koji=# 

Démarrage du daemon Kojid

Une fois le constructeur ajouté à la base de données, on peut démarrer son daemon de construction.

systemctl start kojid

On vérifie dans le fichier <path>/var/log/kojid.log</path> qur le daemon a bien démarré. Si aucune erreur n'est rapportée, c'est que le daemon doit être correctement configuré et démarré. On peut le vérifier sur l'interface Koji-web dans l'onglet hôtes. Cette page affiche le liste des constructeurs et leur status.

Kojira - Création et maintenance du dépôt

Fichiers de Configuration:

  • Configuration du daemon Kojira: <path>/etc/kojira/kojira.conf</path>
  • Variables de lancement du daemon: <path>/etc/sysconfig/kojira</path>

Installation de kojira

yum install koji-utils

Configuration générale

La directive server a besoin de pointer sur le koji-hub.

TextFileIcon16.png <path>/etc/kojira/kojira.conf</path>
; The URL for the xmlrpc server
server=http://koji.didier-linux.eu/kojihub
Important.png
Note importante
  • Kojira a besoin d'un accès en lecture/écriture sur <path>/mnt/koji</path>.
  • Il ne devrait exister qu'une seule instance de kojira à la fois.
  • Il n'est pas recommandé de lancer kojira sur les constructeurs, car ceux-ci n'ont besoin que d'un accès en lecture seule sur le répertoire <path>/mnt/koji</path>.

Configuration de l'authentification SSL

TextFileIcon16.png <path>/etc/kojira/kojira.conf</path>
;client certificate
; This should reference the kojira certificate we created above
cert = /etc/pki/koji/kojira.pem

;certificate of the CA that issued the client certificate
ca = /etc/pki/koji/koji_ca_cert.crt

;certificate of the CA that issued the HTTP server certificate
serverca = /etc/pki/koji/koji_ca_cert.crt

The local user kojira runs as needs to be able to read and write to /mnt/koji/repos/. If the volume that directory resides on is root-squashed or otherwise unmodifiable by root, you can set RUNAS= to a user that has the required privileges.

TextFileIcon16.png <path>/etc/sysconfig/kojira</path>
FORCE_LOCK=Y
KOJIRA_DEBUG=N
KOJIRA_VERBOSE=Y
RUNAS=root

Ajout de l'utilisateur kojira à Koji

Si cela n'a pas été déjà fait, création de l'utilisateur kojira et ajout du droit repo à celui-ci. Cela doit être fait avec le compte de l'administrateur de Koji.

koji add-user kojira
koji grant-permission repo kojira

Démarrage du deamon Kojira

systemctl start kojira.service

On vérifie dans le fichier <path>/var/log/kojira/kojira.log</path> que kojira a bien démarré.

SELinux

semanage fcontext -a -t httpd_sys_rw_content_t '/mnt/koji(/.*)?'
restorecon -Rv /mnt/koji

Notes

  1. Présentation des outils de création/gestion des RPM | Version online
    Version offline:
    Erreur lors de la création de la vignette : /bin/bash: line 1: /usr/bin/gs: No such file or directory convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/580. convert: no images defined `/tmp/transform_397b5772152a.jpg' @ error/convert.c/ConvertImageCommand/3229.
    ( non mise à jour )
  2. https://github.com/RussianFedora/koji-setup