Last active
February 26, 2020 06:39
-
-
Save intlabs/2d0bb330f42880488b0ca396b917621a to your computer and use it in GitHub Desktop.
airshipctl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo virsh destroy airshipctl | |
| sudo virsh undefine airshipctl | |
| sudo rm -rf /var/lib/libvirt/images/airshipctl.qcow2 /var/lib/libvirt/boot/airshipctl_config.iso | |
| sudo qemu-img create -f qcow2 -o \ | |
| backing_file=/var/lib/libvirt/images/base/bionic-server-cloudimg-amd64.qcow2 \ | |
| /var/lib/libvirt/images/airshipctl.qcow2 | |
| sudo qemu-img resize /var/lib/libvirt/images/airshipctl.qcow2 +250G | |
| cat > /tmp/script.sh <<'EOS' | |
| #!/bin/bash | |
| set -ex | |
| export DEBIAN_FRONTEND=noninteractive | |
| sudo apt-get update | |
| sudo apt-get upgrade -y | |
| sudo apt-get autoremove -y | |
| sudo apt-get -y --no-install-recommends install git docker.io ansible make | |
| cd ${HOME} | |
| git clone https://opendev.org/airship/airshipctl.git ${HOME}/airshipctl | |
| cd ${HOME}/airshipctl | |
| git fetch https://review.opendev.org/airship/airshipctl refs/changes/74/705874/17 | |
| git checkout FETCH_HEAD | |
| echo "primary ansible_connection=local" > "${HOME}/ansible_hosts" | |
| tee ${HOME}/.ansible.cfg <<EOF | |
| [defaults] | |
| roles_path = ${HOME}/airshipctl/roles | |
| EOF | |
| tee ${HOME}/ansible_vars.yaml <<EOF | |
| --- | |
| serve_dir: /srv/iso | |
| serve_port: 8099 | |
| local_src_dir: "${HOME}/airshipctl" | |
| ansible_user: root | |
| site_name: "test-bootstrap" | |
| remote_work_dir: "${HOME}/airshipctl" | |
| zuul: | |
| executor: | |
| log_root: "$(mktemp -d)" | |
| project: | |
| src_dir: "${HOME}/airshipctl" | |
| EOF | |
| cd ${HOME}/airshipctl | |
| SCRATCH=$(mktemp) | |
| mv roles/libvirt-install/tasks/main.yaml "${SCRATCH}" | |
| tac "${SCRATCH}" | sed '/meta: reset_connection/I,+1 d' | tac > roles/libvirt-install/tasks/main.yaml | |
| sudo ansible-playbook \ | |
| -i "${HOME}/ansible_hosts" \ | |
| --extra-vars=@${HOME}/ansible_vars.yaml \ | |
| "playbooks/airship-airshipctl-build-gate.yaml" | |
| sudo bash -c 'echo security_driver = \"none\" >> /etc/libvirt/qemu.conf' | |
| sudo systemctl restart libvirtd | |
| sudo ansible-playbook \ | |
| -i "${HOME}/ansible_hosts" \ | |
| --extra-vars=@${HOME}/ansible_vars.yaml \ | |
| "playbooks/airship-airshipctl-test-runner.yaml" | |
| EOS | |
| cat > /tmp/meta-data <<EOF | |
| instance-id: example | |
| EOF | |
| cat > /tmp/network-config <<EOF | |
| version: 2 | |
| ethernets: | |
| enp1s0: | |
| dhcp4: yes | |
| dhcp4-overrides: | |
| route-metric: 100 | |
| dhcp6: false | |
| accept-ra: no | |
| link-local: [ ] | |
| enp2s0: | |
| dhcp4: yes | |
| dhcp4-overrides: | |
| route-metric: 200 | |
| dhcp6: false | |
| accept-ra: no | |
| link-local: [ ] | |
| EOF | |
| cat > /tmp/user-data <<EOF | |
| #cloud-config | |
| ssh_authorized_keys: | |
| - $(cat ~/.ssh/id_rsa.pub) | |
| write_files: | |
| - path: /usr/local/airshipctl-dev-up | |
| permissions: '0755' | |
| owner: root:root | |
| content: | | |
| $(sed 's|^| |g' /tmp/script.sh) | |
| runcmd: | |
| - [ apt-get, update ] | |
| # - [ /bin/su, -s, /bin/bash, -c, /usr/local/airshipctl-dev-up, ubuntu ] | |
| power_state: | |
| delay: "now" | |
| mode: reboot | |
| message: Rebooting | |
| timeout: 30 | |
| condition: True | |
| EOF | |
| sudo genisoimage -o /var/lib/libvirt/boot/airshipctl_config.iso -V cidata -r -J /tmp/user-data /tmp/network-config /tmp/meta-data | |
| sudo virt-install --connect qemu:///system \ | |
| --os-variant ubuntu18.04 \ | |
| --name airshipctl \ | |
| --memory 131072 \ | |
| --memorybacking hugepages=on \ | |
| --network bridge=bridge0 \ | |
| --network network=default \ | |
| --cpu host-passthrough \ | |
| --vcpus 16,cpuset=4-7,12-32 \ | |
| --import \ | |
| --disk path=/var/lib/libvirt/images/airshipctl.qcow2 \ | |
| --disk path=/var/lib/libvirt/boot/airshipctl_config.iso,device=cdrom \ | |
| --nographics \ | |
| --noautoconsole | |
| sudo virsh domifaddr airshipctl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment