diff --git a/.github/workflows/ci-demo.yml b/.github/workflows/ci-demo.yml index 6dfbd83..55738c8 100644 --- a/.github/workflows/ci-demo.yml +++ b/.github/workflows/ci-demo.yml @@ -11,8 +11,8 @@ jobs: - name: Show all environment variables run: printenv - # runner-beaker-arm: - # runs-on: [kite, aarch64, beaker, fedora-37] - # steps: - # - name: Show all environment variables - # run: printenv + runner-beaker-arm: + runs-on: [kite, aarch64, beaker, fedora-37] + steps: + - name: Show all environment variables + run: printenv diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..04b6c1f --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,32 @@ +--- + +yaml-files: + - '*.yaml' + - '*.yml' + - '.yamllint' + +rules: + braces: enable + brackets: enable + colons: enable + commas: enable + comments: + level: warning + comments-indentation: + level: warning + document-end: disable + document-start: + level: warning + empty-lines: enable + empty-values: disable + hyphens: enable + indentation: enable + key-duplicates: enable + key-ordering: disable + line-length: disable + new-line-at-end-of-file: enable + new-lines: enable + octal-values: disable + quoted-strings: disable + trailing-spaces: enable + truthy: disable diff --git a/tools/deploy_container.yaml b/tools/deploy_container.yaml index d01b427..f1bd2d4 100644 --- a/tools/deploy_container.yaml +++ b/tools/deploy_container.yaml @@ -76,7 +76,7 @@ groups: guest runner_name: "{{ instance_name }}" - - name: set private key permisson to 600 + - name: set private key permission to 600 file: path: key/ostree_key mode: "0600" diff --git a/tools/startup-script.sh b/tools/startup-script.sh index aad61bd..50cab19 100755 --- a/tools/startup-script.sh +++ b/tools/startup-script.sh @@ -8,4 +8,13 @@ source /etc/os-release if [[ "$ID" == "fedora" ]]; then growpart /dev/sda 5 btrfs filesystem resize 1:+70G / + dnf install -y python3 python3-dnf +fi + +# Enable CRB repo or powertools repo on Centos Stream 9 or 8 +if [[ "${ID}-${VERSION_ID}" == "centos-9" ]]; then + dnf config-manager --set-enabled crb +fi +if [[ "${ID}-${VERSION_ID}" == "centos-8" ]]; then + dnf config-manager --set-enabled powertools fi diff --git a/tools/upload_gcp_image.yml b/tools/upload_gcp_image.yml index b3029b7..77c485f 100644 --- a/tools/upload_gcp_image.yml +++ b/tools/upload_gcp_image.yml @@ -3,7 +3,6 @@ gather_facts: no become: no vars: - ci_env: "prod" gcp_storage_bucket_name: "{{ lookup('env', 'GCP_STORAGE_BUCKET_NAME') }}" gcp_service_account_file: "{{ lookup('env', 'GCP_SERVICE_ACCOUNT_FILE') }}" gcp_service_account_name: "{{ lookup('env', 'GCP_SERVICE_ACCOUNT_NAME') }}" @@ -11,19 +10,15 @@ os: "fedora-rawhide" image_url: fedora-rawhide: https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Cloud/x86_64/images + fedora-39: https://dl.fedoraproject.org/pub/fedora/linux/development/39/Cloud/x86_64/images fedora-38: https://dl.fedoraproject.org/pub/fedora/linux/releases/38/Cloud/x86_64/images fedora-37: https://dl.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/x86_64/images # image name must be a match of regex '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?|[1-9][0-9]{0,19}' gcp_image_name: - fedora-rawhide: - prod: "kite-image-fedora-rawhide" - stage: "kite-image-stage-fedora-rawhide" - fedora-38: - prod: "kite-image-fedora-38" - stage: "kite-image-stage-fedora-38" - fedora-37: - prod: "kite-image-fedora-37" - stage: "kite-image-stage-fedora-37" + fedora-rawhide: "kite-image-fedora-rawhide" + fedora-39: "kite-image-fedora-39" + fedora-38: "kite-image-fedora-38" + fedora-37: "kite-image-fedora-37" tasks: - name: get latest Fedora rawhide images @@ -37,6 +32,17 @@ - os == "fedora-rawhide" - result_file.changed + - name: get latest Fedora 39 images + shell: curl -s {{ image_url[os] }}/ | grep -ioE '>Fedora-Cloud-Base-GCP-39-.*.x86_64.tar.gz<' | tr -d '><' + register: result_file + when: os == "fedora-39" + + - set_fact: + image_file_name: "{{ result_file.stdout }}" + when: + - os == "fedora-39" + - result_file.changed + - name: get latest Fedora 38 images shell: curl -s {{ image_url[os] }}/ | grep -ioE '>Fedora-Cloud-Base-GCP-38-.*.x86_64.tar.gz<' | tr -d '><' register: result_file @@ -70,7 +76,7 @@ - name: create a bucket google.cloud.gcp_storage_bucket: name: "{{ gcp_storage_bucket_name }}" - project: virt-qe + project: "{{ gcp_project }}" auth_kind: serviceaccount service_account_file: "{{ gcp_service_account_file }}" state: present @@ -86,15 +92,15 @@ command: /usr/bin/gsutil -h Content-MD5:{{ md5_checksum }} cp /tmp/{{ image_file_name }} gs://{{ gcp_storage_bucket_name }} - name: create image for test - command: /usr/bin/gcloud compute images create {{ gcp_image_name[os][ci_env] }}-tmp --source-uri gs://{{ gcp_storage_bucket_name }}/{{ image_file_name }} --guest-os-features="UEFI_COMPATIBLE,GVNIC,SEV_CAPABLE,VIRTIO_SCSI_MULTIQUEUE" --project={{ gcp_project }} --labels=kite=kite-image-{{ gcp_image_name[os][ci_env] }} + command: /usr/bin/gcloud compute images create {{ gcp_image_name[os] }}-tmp --source-uri gs://{{ gcp_storage_bucket_name }}/{{ image_file_name }} --guest-os-features="UEFI_COMPATIBLE,GVNIC,SEV_CAPABLE,VIRTIO_SCSI_MULTIQUEUE" --project={{ gcp_project }} --labels=kite=kite-image-{{ gcp_image_name[os] }} # image test - block: - set_fact: - test_instance_name: "image-test-{{ gcp_image_name[os][ci_env] }}" + test_instance_name: "image-test-{{ gcp_image_name[os] }}" - name: create gcp instance - command: /usr/bin/gcloud compute instances create "{{ test_instance_name }}" --zone=us-central1-a --machine-type=n2-standard-4 --boot-disk-auto-delete --boot-disk-size=80GB --boot-disk-type=pd-ssd --metadata-from-file=ssh-keys="{{ playbook_dir }}/key/gcp_key",startup-script="{{ playbook_dir }}/startup-script.sh" --metadata=block-project-ssh-keys=TRUE --provisioning-model=SPOT --image="{{ gcp_image_name[os][ci_env] }}-tmp" --enable-nested-virtualization --service-account="{{ gcp_service_account_name }}" --project="{{ gcp_project }}" --format=json + command: /usr/bin/gcloud compute instances create "{{ test_instance_name }}" --zone=us-central1-a --machine-type=n2-standard-4 --boot-disk-auto-delete --boot-disk-size=80GB --boot-disk-type=pd-ssd --metadata-from-file=ssh-keys="{{ playbook_dir }}/key/gcp_key",startup-script="{{ playbook_dir }}/startup-script.sh" --metadata=block-project-ssh-keys=TRUE --provisioning-model=SPOT --image="{{ gcp_image_name[os] }}-tmp" --enable-nested-virtualization --service-account="{{ gcp_service_account_name }}" --project="{{ gcp_project }}" --format=json register: result_instance - set_fact: @@ -160,8 +166,8 @@ msg: "upload GCP image fail" always: - - name: "delete tmp image {{ gcp_image_name[os][ci_env] }}-tmp" - command: /usr/bin/gcloud compute images delete {{ gcp_image_name[os][ci_env] }}-tmp --quiet --project={{ gcp_project }} + - name: "delete tmp image {{ gcp_image_name[os] }}-tmp" + command: /usr/bin/gcloud compute images delete {{ gcp_image_name[os] }}-tmp --quiet --project={{ gcp_project }} - name: delete test instance command: /usr/bin/gcloud compute instances delete {{ test_instance_name }} --quiet --zone=us-central1-a --delete-disks=all --project={{ gcp_project }} @@ -169,18 +175,18 @@ - name: old image exists or not google.cloud.gcp_compute_image_info: filters: - - name = "{{ gcp_image_name[os][ci_env] }}" - project: virt-qe + - name = "{{ gcp_image_name[os] }}" + project: "{{ gcp_project }}" auth_kind: serviceaccount service_account_file: "{{ gcp_service_account_file }}" register: result_image - - name: "delete old image {{ gcp_image_name[os][ci_env] }}" - command: /usr/bin/gcloud compute images delete {{ gcp_image_name[os][ci_env] }} --project={{ gcp_project }} + - name: "delete old image {{ gcp_image_name[os] }}" + command: /usr/bin/gcloud compute images delete {{ gcp_image_name[os] }} --project={{ gcp_project }} when: result_image.resources != [] - - name: "create new {{ gcp_image_name[os][ci_env] }}" - command: /usr/bin/gcloud compute images create {{ gcp_image_name[os][ci_env] }} --source-uri gs://{{ gcp_storage_bucket_name }}/{{ image_file_name }} --guest-os-features="UEFI_COMPATIBLE,GVNIC,SEV_CAPABLE,VIRTIO_SCSI_MULTIQUEUE" --project={{ gcp_project }} --labels=kite=kite-image-{{ gcp_image_name[os][ci_env] }} + - name: "create new {{ gcp_image_name[os] }}" + command: /usr/bin/gcloud compute images create {{ gcp_image_name[os] }} --source-uri gs://{{ gcp_storage_bucket_name }}/{{ image_file_name }} --guest-os-features="UEFI_COMPATIBLE,GVNIC,SEV_CAPABLE,VIRTIO_SCSI_MULTIQUEUE" --project={{ gcp_project }} --labels=kite=kite-image-{{ gcp_image_name[os] }} - name: "delete {{ image_file_name }} from bucket {{ gcp_storage_bucket_name }}" command: /usr/bin/gsutil rm gs://{{ gcp_storage_bucket_name }}/{{ image_file_name }}