From e425fbc82bdf2f657945834ad783c0df7e368d72 Mon Sep 17 00:00:00 2001 From: Fabian Arrotin Date: Tue, 8 Feb 2022 14:34:40 +0100 Subject: [PATCH] Automatic regen with all existing roles Signed-off-by: Fabian Arrotin --- adhoc-kojid-upgrade.yml | 13 +-- adhoc-ocp-create-pv.yml | 106 ++++++++++++++++++ requirements-dev.yml | 3 + requirements-production.yml | 2 + requirements-staging.yml | 3 + role-all.yml | 1 + role-debuginfod.yml | 24 ++++ templates/convert-stream-8 | 8 +- .../openshift/jenkins-ci-workspace.env.j2 | 2 + templates/pxeboot.j2 | 2 + 10 files changed, 155 insertions(+), 9 deletions(-) create mode 100644 adhoc-ocp-create-pv.yml create mode 100644 role-debuginfod.yml create mode 100644 templates/openshift/jenkins-ci-workspace.env.j2 diff --git a/adhoc-kojid-upgrade.yml b/adhoc-kojid-upgrade.yml index dcd4444..a5b6459 100644 --- a/adhoc-kojid-upgrade.yml +++ b/adhoc-kojid-upgrade.yml @@ -3,13 +3,10 @@ become: True gather_facts: False - pre_tasks: - - name: removing versionlock plugin - yum: - name: "*" - state: latest - update_cache: True + tasks: + - name: kojid is running + service: + name: kojid + state: restarted - roles: - - kojid diff --git a/adhoc-ocp-create-pv.yml b/adhoc-ocp-create-pv.yml new file mode 100644 index 0000000..8724aa4 --- /dev/null +++ b/adhoc-ocp-create-pv.yml @@ -0,0 +1,106 @@ +--- +# This playbook is to create a persistent volume for openshift CI namespace +# The node on which we'll run this should have the exported NFS volume mounted locally +# using variables from inventory: +# ocp_nfs_server: (like node.domain) +# ocp_nfs_export: ocp-staging + + +- hosts: "ocp-ci-management" + become: true + become_user: "{{ ocp_service_account }}" + vars_prompt: + - name: "ocp_project" + prompt: "Existing project/namespace in ocp we'll deploy jenkins to/for (has to exist before !) " + private: no + - name: "pv_name" + prompt: "Reason for PV (computed into uuid) " + private: no + - name: "pv_size" + prompt: "Persistent Volume size (example 10Gi) " + private: no + + + tasks: + - name: Generate a UUID + set_fact: + pv_uuid: "{{ (ocp_project + pv_claimref|default('noclaimref', true)) + pv_name | to_uuid }}" + tags: + - pv + - nfs + + - name: UUID Generated + debug: + var: pv_uuid + tags: + - pv + - nfs + + - name: Make a pv name + set_fact: + pv_name: "pv-{{ pv_size | lower }}-{{ pv_uuid }}" + tags: + - pv + - nfs + + - name: UUID Generated + debug: + var: pv_name + tags: + - pv + - nfs + + - name: See if the PV already exists + command: + cmd: "bin/oc get pv/{{ pv_name }}" + chdir: "/home/{{ ocp_service_account }}" + register: results + changed_when: false + failed_when: + - results.rc == 0 + tags: + - pv + + - block: + - name: Ensuring we have local mount point + file: + path: /mnt/ocp_store + state: directory + + - name: Ensuring nfs export is mounted on mgmt station + mount: + fstype: nfs + src: "{{ ocp_nfs_server }}:{{ ocp_nfs_export }}" + path: /mnt/ocp_store + state: mounted + + - name: make directories for each PV + file: + path: "/mnt/ocp_store/{{ pv_name }}" + owner: nobody + group: nobody + mode: 0777 + state: directory + become_user: root + tags: + - pv + - nfs + + - name: create json files for PV + template: + src: "templates/openshift-pv-storage/persistent-volume.json.j2" + dest: "/home/{{ ocp_service_account }}/pv_configs/{{ pv_name }}.json" + register: pv_init + tags: + - pv + + - name: apply the transformation + command: + cmd: "bin/oc create -f pv_configs/{{ pv_name }}.json" + chdir: "/home/{{ ocp_service_account }}" + when: pv_init is changed + tags: + - pv + + + diff --git a/requirements-dev.yml b/requirements-dev.yml index 1b84c87..e05ed75 100644 --- a/requirements-dev.yml +++ b/requirements-dev.yml @@ -23,6 +23,9 @@ - src: https://github.com/CentOS/ansible-role-certbot name: certbot version: staging +- src: https://github.com/CentOS/ansible-role-debuginfod + name: debuginfod + version: staging - src: https://github.com/CentOS/ansible-role-distgit-lookaside name: distgit-lookaside version: staging diff --git a/requirements-production.yml b/requirements-production.yml index 0c21a6b..48e6934 100644 --- a/requirements-production.yml +++ b/requirements-production.yml @@ -15,6 +15,8 @@ name: centos-backup - src: https://github.com/CentOS/ansible-role-certbot name: certbot +- src: https://github.com/CentOS/ansible-role-debuginfod + name: debuginfod - src: https://github.com/CentOS/ansible-role-distgit-lookaside name: distgit-lookaside - src: https://github.com/CentOS/ansible-role-duffy diff --git a/requirements-staging.yml b/requirements-staging.yml index 1b84c87..e05ed75 100644 --- a/requirements-staging.yml +++ b/requirements-staging.yml @@ -23,6 +23,9 @@ - src: https://github.com/CentOS/ansible-role-certbot name: certbot version: staging +- src: https://github.com/CentOS/ansible-role-debuginfod + name: debuginfod + version: staging - src: https://github.com/CentOS/ansible-role-distgit-lookaside name: distgit-lookaside version: staging diff --git a/role-all.yml b/role-all.yml index 32fcf45..0824c87 100644 --- a/role-all.yml +++ b/role-all.yml @@ -6,6 +6,7 @@ - import_playbook: role-centbot.yml - import_playbook: role-centos-backup.yml - import_playbook: role-certbot.yml +- import_playbook: role-debuginfod.yml - import_playbook: role-distgit-lookaside.yml - import_playbook: role-duffy.yml - import_playbook: role-fedmsg.yml diff --git a/role-debuginfod.yml b/role-debuginfod.yml new file mode 100644 index 0000000..7f4b46b --- /dev/null +++ b/role-debuginfod.yml @@ -0,0 +1,24 @@ +--- +- hosts: hostgroup-role-debuginfod + become: True + pre_tasks: + - name: Checking if no-ansible file is there + stat: + path: /etc/no-ansible + register: no_ansible + + - name: Verifying if we can run ansible or not + assert: + that: + - "not no_ansible.stat.exists" + msg: "/etc/no-ansible file exists so skipping ansible run on this node" + + roles: + - debuginfod + + post_tasks: + - name: Touching ansible-run (monitored by Zabbix) + file: + path: /var/log/ansible.run + state: touch + diff --git a/templates/convert-stream-8 b/templates/convert-stream-8 index 466d4a5..acb0091 100755 --- a/templates/convert-stream-8 +++ b/templates/convert-stream-8 @@ -2,7 +2,13 @@ logfile="/var/log/centos-convert-stream.log" rpm -q centos-stream-repos 2>&1 >/dev/null if [ "$?" -ne "0" ] ; then - dnf swap -y -d 0 -q centos-linux-repos centos-stream-repos >> $logfile && dnf distro-sync -y -q -d 0 >> $logfile 2>&1 + dnf swap -y -d 0 -q centos-linux-repos centos-stream-repos >> $logfile + if [ "$?" -ne "0" ] ;then + rpm -e --nodeps centos-linux-repos >> $logfile 2>&1 + rpm -Uvh http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-8-4.el8.noarch.rpm http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-4.el8.noarch.rpm >> $logfile 2>&1 + fi + dnf distro-sync -y -q -d 0 >> $logfile 2>&1 + fi if [ "$?" -ne "0" ] ;then echo "Error converting to Stream 8" >> $logfile exit 1 diff --git a/templates/openshift/jenkins-ci-workspace.env.j2 b/templates/openshift/jenkins-ci-workspace.env.j2 new file mode 100644 index 0000000..71db803 --- /dev/null +++ b/templates/openshift/jenkins-ci-workspace.env.j2 @@ -0,0 +1,2 @@ +DUFFY_API_KEY="{{ duffy_api_key }}" +DUFFY_SSH_KEY="{{ duffy_ssh_key }}" diff --git a/templates/pxeboot.j2 b/templates/pxeboot.j2 index aa1a49f..b74352e 100644 --- a/templates/pxeboot.j2 +++ b/templates/pxeboot.j2 @@ -1,6 +1,8 @@ # Merging CI and previous setup so different variables, let's merge +{% if centos_dist is defined %} {% set centos_version = centos_dist %} {% set arch = centos_arch %} +{% endif %} {% if pxe_boot_serial is defined and pxe_boot_serial %} # Let's setup for Serial console for CI and seamicro (no vga at all) SERIAL 0 9600