Skip to content

Latest commit

 

History

History
119 lines (110 loc) · 2.58 KB

how-to-create-a-packer-environment-silverblue.md

File metadata and controls

119 lines (110 loc) · 2.58 KB

How to create a packer environment (Silverblue)

Install virtualization (Silverblue)

rpm-ostree install \
  libguestfs-tools \
  libvirt-daemon-config-network \
  libvirt-daemon-kvm \
  qemu-kvm \
  virt-install \
  virt-manager \
  virt-viewer \
  ;

Create a Debian 11 VM

(
name=packer
curl -o preseed.cfg https://www.debian.org/releases/bullseye/example-preseed.txt
cat <<EOF >> preseed.cfg
d-i grub-installer/bootdev string default
d-i netcfg/get_hostname string debian11-$name
d-i passwd/root-login boolean false
d-i passwd/user-fullname string whs
d-i passwd/user-password password magic
d-i passwd/user-password-again password magic
d-i passwd/username string whs
d-i preseed/late_command string apt-install openssh-server
popularity-contest popularity-contest/participate boolean false
tasksel tasksel/first multiselect standard
EOF
virt-install \
  --disk size=20 \
  --initrd-inject preseed.cfg \
  --location https://deb.debian.org/debian/dists/bullseye/main/installer-amd64/ \
  --memory 2048 \
  --name debian11-$name \
  --network bridge:virbr0 \
  --os-variant debian11 \
  --vcpus 2 \
  ;
)

Install cguv (Debian 11)

sudo apt-get install -y \
  curl \
  git \
  unzip \
  vim \
  ;

Install pip (Debian 11)

sudo apt-get install -y python3-distutils
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc
source ~/.bashrc

Install ansible

pip install --upgrade ansible

Install packer

https://www.packer.io/downloads

cat <<EOF > install_packer.yaml
- name: Installer
  hosts: all
  tasks:
  - become: "yes"
    name: Install packer
    unarchive:
      creates: /usr/local/bin/packer
      dest: /usr/local/bin/
      remote_src: "yes"
      src: |-
        https://releases.hashicorp.com/packer/{{ version }}/packer_{{ version }}_linux_amd64.zip
EOF
ansible-playbook -ilocalhost, -clocal -eversion=1.8.2 install_packer.yaml -K

Install vagrant

https://www.vagrantup.com/downloads

cat <<EOF > install_vagrant.yaml
- name: Installer
  hosts: all
  tasks:
  - become: "yes"
    name: Install vagrant
    unarchive:
      creates: /usr/local/bin/vagrant
      dest: /usr/local/bin/
      remote_src: "yes"
      src: |-
        https://releases.hashicorp.com/vagrant/{{ version }}/vagrant_{{ version }}_linux_amd64.zip
EOF
ansible-playbook -ilocalhost, -clocal -eversion=2.2.19 install_vagrant.yaml -K

Install vagrant-libvirt (Silverblue)

rpm-ostree install \
  libvirt-devel \
  libxml2-devel \
  ruby-devel \
  ;
vagrant plugin install vagrant-libvirt