From 898d4673219d16a5dc19e523f94eba952365f0c1 Mon Sep 17 00:00:00 2001 From: spmfox Date: Tue, 28 May 2024 15:27:24 -0400 Subject: removing the base centos-bootc deployment, it caused problems with the final deployed image and did not save disk space --- README.md | 4 +-- deploy.yml | 52 ++++++++++++++++--------------------- templates/bootcblade-deploy.sh.j2 | 9 +++++++ templates/centos-bootc-deploy.sh.j2 | 9 ------- 4 files changed, 33 insertions(+), 41 deletions(-) create mode 100644 templates/bootcblade-deploy.sh.j2 delete mode 100644 templates/centos-bootc-deploy.sh.j2 diff --git a/README.md b/README.md index e10cf9d..adf79b4 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ This Ansible automation uses bootc to create "the perfect" KVM hypervisor with Z ## How It Works ### Deploy 1. A new or existing system must exist. This system should be as small as possible because its filesystem will persist in the resulting deployed machine -2. A "base" centos-bootc is used for the first deploy - the user SSH key is set for the root user now -3. Once the base is deployed, we use that to build and ```bootc switch``` into the final BootcBlade image +2. ```bootcblade.containerfile``` is copied to the existing system, then ```podman build``` is used to build the image +3. Once the image is built, the BootcBlade image is deployed to the system - then it is rebooted 4. Ansible creates the user with (or without) the password and adds the SSH key ### ISO diff --git a/deploy.yml b/deploy.yml index f4ef4f9..1d68839 100644 --- a/deploy.yml +++ b/deploy.yml @@ -5,12 +5,20 @@ ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" tasks: - - name: Block for deploy-base-bootc + - name: Block for deploy block: - - name: Create /root/centos-bootc-deploy.sh + - name: Make sure podman is installed + ansible.builtin.package: + name: "podman" + state: present + + - name: Create /root/bootcblade.containerfile and /root/bootcblade-deploy.sh ansible.builtin.template: - src: "centos-bootc-deploy.sh.j2" - dest: "/root/centos-bootc-deploy.sh" + src: "{{ item }}.j2" + dest: "/root/{{ item }}" + loop: + - bootcblade.containerfile + - bootcblade-deploy.sh - name: Create root ssh authorized keys ansible.posix.authorized_key: @@ -18,39 +26,23 @@ key: "{{ create_user_ssh_pub }}" state: present - - name: Run bootc deployment for basic centos-bootc environment - ansible.builtin.shell: "bash /root/centos-bootc-deploy.sh" - - - name: Reboot into basic centos-bootc environment - ansible.builtin.reboot: - reboot_timeout: 1 - ignore_errors: true - tags: deploy-base-bootc - - - name: Block for deploy-bootcblade - block: - - name: Wait for connectivity to basic centos-bootc environment - ansible.builtin.wait_for_connection: - - - name: Create /root/BootcBlade.containerfile - ansible.builtin.template: - src: "bootcblade.containerfile.j2" - dest: "/root/bootcblade.containerfile" - - name: Build BootcBlade container image ansible.builtin.shell: "podman build -t localhost/bootcblade -f /root/bootcblade.containerfile" - - name: Run bootc-switch into BootcBlade image - ansible.builtin.shell: "bootc switch --transport containers-storage localhost/bootcblade:latest" + - name: Deploy BootcBlade image + ansible.builtin.shell: "bash /root/bootcblade-deploy.sh" - name: Reboot into BootcBlade environment ansible.builtin.reboot: - vars: - ansible_user: "root" - tags: deploy-bootcblade + reboot_timeout: 1 + ignore_errors: true + tags: deploy - - name: Block for configure-bootcblade + - name: Block for configure block: + - name: Wait for connectivity after deployment + ansible.builtin.wait_for_connection: + - name: Create user ansible.builtin.user: name: "{{ create_user }}" @@ -105,5 +97,5 @@ - "bootc-fetch-apply-updates.service" vars: ansible_user: "root" - tags: configure-bootcblade + tags: configure diff --git a/templates/bootcblade-deploy.sh.j2 b/templates/bootcblade-deploy.sh.j2 new file mode 100644 index 0000000..ecd91e3 --- /dev/null +++ b/templates/bootcblade-deploy.sh.j2 @@ -0,0 +1,9 @@ +#!/bin/bash +podman run --rm --privileged \ + --pid=host --security-opt label=type:unconfined_t \ + --volume /dev:/dev \ + --volume /var/lib/containers:/var/lib/containers \ + --volume /:/target \ + --entrypoint bootc \ + localhost/bootcblade:latest \ + install to-filesystem --skip-fetch-check --replace=alongside /target --root-ssh-authorized-keys /target/root/.ssh/authorized_keys {{ '' if bootc_acknowledge is false else '--acknowledge-destructive' }} diff --git a/templates/centos-bootc-deploy.sh.j2 b/templates/centos-bootc-deploy.sh.j2 deleted file mode 100644 index 2083295..0000000 --- a/templates/centos-bootc-deploy.sh.j2 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -podman run --rm --privileged \ - --pid=host --security-opt label=type:unconfined_t \ - --volume /dev:/dev \ - --volume /var/lib/containers:/var/lib/containers \ - --volume /:/target \ - --entrypoint bootc \ - quay.io/centos-bootc/centos-bootc:{{ centos_bootc_tag if centos_bootc_tag is defined else 'stream9' }} \ - install to-filesystem --skip-fetch-check --replace=alongside /target --root-ssh-authorized-keys /target/root/.ssh/authorized_keys {{ '' if bootc_acknowledge is false else '--acknowledge-destructive' }} -- cgit