Blame docs/operations/ci/adding_cico_tenant/adding_cico_tenants.md

792b29
# CentOS CI - On-boarding
792b29
792b29
Note to users:
792b29
792b29
Please note that Infra space is for Fedora and CentOS related projects to
792b29
consume. Decision may take some time (often up to 2 weeks) as these are decided
792b29
by the whole team.
792b29
Once decided as go, we will create you a namespace in a openshift cluster where
792b29
you can configure your CI. We do provide a Jenkins template in case you want to be
792b29
able to consume vms/baremetal nodes to perform your CI.
792b29
792b29
Please answer the following questions so that we understand your requirement.
792b29
792b29
* How does your project relates to Fedora/CentOS?
792b29
* Describe your work flow and if you need any special permissions (other than
792b29
  admin access to namespace), please tell us and provide a reason for them.
792b29
* Do you need bare-metal/vms checkout capability? (we prefer your workflow
792b29
  containerized)
792b29
* Resources required
792b29
  * PVs:
792b29
792b29
```
792b29
Project_name:
792b29
Project_members:
792b29
 - user1@ACO_registered_email_address
792b29
 - user2@ACO_registered_email_address
792b29
```
792b29
792b29
## Steps
97a9dc
97a9dc
1. Create an entry in duffy db (with ssh key) - [follow adding-duffy-api-key.md](/operations/ci/adding_cico_tenant/adding    -duffy-api-key/)
97a9dc
2. Create an OpenShift namespace/project (done with ansible)
97a9dc
3. Create a PV(Persistent Volume) and deploy Jenkins instance (done with ansible)
97a9dc
97a9dc
## Create an entry in duffy db (with ssh key) - [follow adding-duffy-api-key.md](/operations/ci/adding_cico_tenant/adding-duffy-api-key/)
792b29
792b29
792b29
### Create an OpenShift namespace
792b29
97a9dc
!!! important 
97a9dc
    we don't use the previous specific git repo for projects, as it's now all using the `ocp-admin` ansible role, see below
97a9dc
97a9dc
To create the openshift namespace/project, just add edit the inventory/host_vars/<ocp_controller_node> and add the new project to the existin `ocp_projects_list` ansible list.
97a9dc
97a9dc
Example:
97a9dc
97a9dc
```
97a9dc
# Declaring projects that will be created in ocp.ci
97a9dc
ocp_projects_list:
97a9dc
  - name: ci-infra-test
97a9dc
    members:
97a9dc
      - ci-user1@centos.org
97a9dc
      - ci-user2@centos.org
97a9dc
97a9dc
```
97a9dc
c6f3b7
Once done, don't forget to commit/push and you can then apply remotely from central CI ansible node the role directly with a specific tag.
97a9dc
97a9dc
```
c6f3b7
 <user>  ~  ansible  CentOS_CI  ./filestore/remote_ansible_call                                        
c6f3b7
[+] 20220325-15:10 ansible-ara-run -> == Ansible Ara manual trigger ==
c6f3b7
Which ansible role you want to play ? (like haproxy, without -role) => ocp-admin-node
c6f3b7
List of possible tags for role ocp-admin-node : 
c6f3b7
 =>       TASK TAGS: [backup, certs, config, localstorage, projects, tls]
c6f3b7
Do you want to call specific tag[s] and which one[s] ? (can be empty) => projects
c6f3b7
Host/Group limits ? (default to whole group) => 
c6f3b7
[+] 20220325-15:11 ansible-ara-run -> Updating first inventory/pkistore/filestore
c6f3b7
[+] 20220325-15:11 ansible-ara-run -> Checking role [ocp-admin-node] is present and up2date ...
c6f3b7
[+] 20220325-15:11 ansible-ara-run -> Calling now ansible with ara reporting ...
c6f3b7
[+] 20220325-15:11 ansible-ara-run -> ansible-playbook playbooks/role-ocp-admin-node.yml  --tags projects -e ara_playbook_name=role-ocp-admin-node
97a9dc
97a9dc
PLAY [hostgroup-role-ocp-admin-node] *****************************************************************************
97a9dc
97a9dc
TASK [ocp-admin-node : Rendering template for projects] **********************************************************
c6f3b7
Friday 25 March 2022  15:11:08 +0000 (0:00:00.445)       0:00:00.445 ********** 
97a9dc
ok: [ocp-admin.ci.centos.org] => (item=ci-infra-test)
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=samba)
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=hyperscale)
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=networkmanager)
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=gluster)
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=pagure)
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=sp-augur)
792b29
97a9dc
TASK [ocp-admin-node : Creating/modifying project if needed] *****************************************************
c6f3b7
Friday 25 March 2022  15:11:11 +0000 (0:00:02.892)       0:00:03.337 ********** 
97a9dc
skipping: [ocp-admin.ci.centos.org] => (item=ci-infra-test) 
c6f3b7
skipping: [ocp-admin.ci.centos.org] => (item=samba) 
c6f3b7
skipping: [ocp-admin.ci.centos.org] => (item=hyperscale) 
c6f3b7
skipping: [ocp-admin.ci.centos.org] => (item=networkmanager) 
c6f3b7
skipping: [ocp-admin.ci.centos.org] => (item=gluster) 
c6f3b7
skipping: [ocp-admin.ci.centos.org] => (item=pagure) 
c6f3b7
skipping: [ocp-admin.ci.centos.org] => (item=sp-augur) 
c6f3b7
c6f3b7
TASK [ocp-admin-node : Deleting project[s] if needed] ************************************************************
c6f3b7
Friday 25 March 2022  15:11:12 +0000 (0:00:00.597)       0:00:03.935 ********** 
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=fedora-coreos)
c6f3b7
ok: [ocp-admin.ci.centos.org] => (item=coreos-ci)
792b29
97a9dc
PLAY RECAP *******************************************************************************************************
c6f3b7
n4-136.cloud.ci.centos.org : ok=0    changed=0    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0   
c6f3b7
ocp-admin.ci.centos.org    : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
c6f3b7
c6f3b7
Friday 25 March 2022  15:11:13 +0000 (0:00:01.320)       0:00:05.255 ********** 
c6f3b7
=============================================================================== 
c6f3b7
ocp-admin-node : Rendering template for projects  --------------------------------------------------------- 2.89s
c6f3b7
ocp-admin-node : Deleting project[s] if needed ------------------------------------------------------------ 1.32s
c6f3b7
ocp-admin-node : Creating/modifying project if needed ----------------------------------------------------- 0.60s
c6f3b7
Playbook run took 0 days, 0 hours, 0 minutes, 5 seconds
792b29
97a9dc
```
792b29
b762e3
!!! note
b762e3
    If you need to also modify members and/or email addresses, you can just follow the same process and replay the same playbook : that will reflect changes in openshift. If you need access to that private git repository (to be fixed and moved elsewhere in the official `centos` namespace, reach out to another infra team member
b762e3
792b29
9b3876
!!! important
9b3876
    If you have to instead delete/remove a project, you can just add the project name in the `ocp_projects_to_delete_list` ansible list and it will be deleted/removed on next ansible run
9b3876
97a9dc
## Deploy a PV (Persistent Volume) and Jenkins instance
792b29
97a9dc
!!! note
97a9dc
    In case you just need to create a PV *outside* of jenkins, follow [Persistent storage via NFS](https://docs.infra.centos.org/operations/ci/installation/persistant_storage_nfs/). 
f1ccc7
97a9dc
We have an ad-hoc ansible task (adhoc-ocp-deploy-jenkins-for-ci-tenant.yml) that will create the needed PV , create a template and apply it with the correct ssh keys and duffy api key so ensure that you followed previous steps so that you have the project keys into pkistore git repo (using project name) and also duffy api key ready (as script will ask you for it):
f1ccc7
97a9dc
```
97a9dc
ansible-playbook-ci playbooks/adhoc-ocp-deploy-jenkins-for-ci-tenant.yml
97a9dc
```
f1ccc7
97a9dc
Just answer the following questions (project has to exist first ! :
f1ccc7
97a9dc
```
97a9dc
Existing project/namespace in ocp we'll deploy jenkins to/for (has to exist before !) : samba
97a9dc
Persistent Volume size (example 10Gi) : 10Gi
97a9dc
Existing Duffy API key : <duffy_api_key>
97a9dc
97a9dc
```
792b29
97a9dc
Now you just have to wait for jenkins to be up and running 
792b29
97a9dc
!!! important
97a9dc
    We recently had an issue with the default jenkins image having outdated (and not working) [openshift sync plugin](https://plugins.jenkins.io/openshift-sync/) so be sure that you have at least 1.0.51 running in openshift. If not, update it first, and then configmap will be synced to jenkins, for the `cico-workspace` pod template