summaryrefslogtreecommitdiff
path: root/roles/vagrant-libvirt
diff options
context:
space:
mode:
Diffstat (limited to 'roles/vagrant-libvirt')
-rw-r--r--roles/vagrant-libvirt/files/Vagrantfile12
-rw-r--r--roles/vagrant-libvirt/files/config.boot41
-rw-r--r--roles/vagrant-libvirt/files/metadata.json1
-rw-r--r--roles/vagrant-libvirt/files/persistence.conf1
-rw-r--r--roles/vagrant-libvirt/tasks/build_image.yml122
-rw-r--r--roles/vagrant-libvirt/tasks/convert.yml21
-rw-r--r--roles/vagrant-libvirt/tasks/load_modules.yml2
-rw-r--r--roles/vagrant-libvirt/tasks/main.yml6
-rw-r--r--roles/vagrant-libvirt/tasks/release.yml27
-rw-r--r--roles/vagrant-libvirt/tasks/setup_iso.yml57
-rw-r--r--roles/vagrant-libvirt/tasks/unmount.yml66
-rw-r--r--roles/vagrant-libvirt/templates/boot/grub/device.map.j21
-rw-r--r--roles/vagrant-libvirt/templates/boot/grub/grub.cfg.j27
-rw-r--r--roles/vagrant-libvirt/vars/main.yml8
14 files changed, 0 insertions, 372 deletions
diff --git a/roles/vagrant-libvirt/files/Vagrantfile b/roles/vagrant-libvirt/files/Vagrantfile
deleted file mode 100644
index 7c89422..0000000
--- a/roles/vagrant-libvirt/files/Vagrantfile
+++ /dev/null
@@ -1,12 +0,0 @@
-Vagrant.configure("2") do |config|
- config.vm.synced_folder './', '/vagrant',
- type: "rsync",
- owner: 'vyos',
- group: 'users',
- mount_options: ['dmode=775,fmode=775']
- config.ssh.username = "vyos"
- config.ssh.password = "vyos"
- config.vm.provider :libvirt do |libvirt|
- libvirt.driver = "kvm"
- end
-end
diff --git a/roles/vagrant-libvirt/files/config.boot b/roles/vagrant-libvirt/files/config.boot
deleted file mode 100644
index f1ec4f5..0000000
--- a/roles/vagrant-libvirt/files/config.boot
+++ /dev/null
@@ -1,41 +0,0 @@
-service {
- ssh {
- port 22
- }
-}
-system {
- host-name vyos
- login {
- user vyos {
- authentication {
- encrypted-password "$6$MjV2YvKQ56q$QbL562qhRoyUu8OaqrXagicvcsNpF1HssCY06ZxxghDJkBCfSfTE/4FlFB41xZcd/HqYyVBuRt8Zyq3ozJ0dc."
- plaintext-password ""
- }
- level admin
- }
- }
- syslog {
- global {
- facility all {
- level notice
- }
- facility protocols {
- level debug
- }
- }
- }
- ntp {
- server "0.pool.ntp.org"
- server "1.pool.ntp.org"
- server "2.pool.ntp.org"
- }
- config-management {
- commit-revisions 100
- }
-}
-interfaces {
- ethernet eth0 {
- address dhcp
- }
- loopback lo
-}
diff --git a/roles/vagrant-libvirt/files/metadata.json b/roles/vagrant-libvirt/files/metadata.json
deleted file mode 100644
index a502c63..0000000
--- a/roles/vagrant-libvirt/files/metadata.json
+++ /dev/null
@@ -1 +0,0 @@
-{"format":"qcow2","provider":"libvirt","virtual_size":1}
diff --git a/roles/vagrant-libvirt/files/persistence.conf b/roles/vagrant-libvirt/files/persistence.conf
deleted file mode 100644
index f500aef..0000000
--- a/roles/vagrant-libvirt/files/persistence.conf
+++ /dev/null
@@ -1 +0,0 @@
-/ union
diff --git a/roles/vagrant-libvirt/tasks/build_image.yml b/roles/vagrant-libvirt/tasks/build_image.yml
deleted file mode 100644
index 135d8de..0000000
--- a/roles/vagrant-libvirt/tasks/build_image.yml
+++ /dev/null
@@ -1,122 +0,0 @@
-- name: Create the target disk image
- command: qemu-img create -f raw "{{ vyos_raw_img }}" 1G
-
-- name: Find loopback
- shell: losetup -f
- register: loopback
-
-- name: Loopback attach
- command: "losetup {{ loopback.stdout }} {{ vyos_raw_img }}"
-
-- name: Partition the target drive
- parted:
- device: "{{ loopback.stdout }}"
- state: present
- label: msdos
- number: 1
- part_type: primary
- part_start: 0%
- part_end: 100%
- align: optimal
- flags: [boot]
-
-- name: Create a filesystem on root partition
- filesystem:
- fstype: "{{ ROOT_FSTYPE }}"
- device: "{{ loopback.stdout }}"
- opts: "-L persistence"
-
-- name: Mount root partition
- mount:
- name: "{{ WRITE_ROOT }}"
- src: "{{ loopback.stdout }}"
- fstype: "{{ ROOT_FSTYPE }}"
- state: mounted
-
-# ---- Install image from ISO ----
-- name: Create {{ WRITE_ROOT }} directories
- file:
- path: "{{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/rw"
- state: directory
- register: RW_DIR
-
-- name: Create the work directory
- file:
- path: "{{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/work/work"
- state: directory
-
-- name: Copy squashfs image from ISO to root partition
- command: cp -p {{ SQUASHFS_IMAGE }} {{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/{{ version_string.stdout }}.squashfs
- args:
- creates: "{{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/{{ version_string.stdout }}.squashfs"
-
-- name: Copy boot files (kernel and initrd images) from ISO to root partition
- shell: find {{ CD_SQUASH_ROOT }}/boot -maxdepth 1 \( -type f -o -type l \) -print -exec cp -dp {} {{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/ \;
- args:
- creates: "{{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/vmlinuz"
-
-- name: Mount squashfs image from root partition
- mount:
- name: "{{ READ_ROOT }}"
- src: "{{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/{{ version_string.stdout }}.squashfs"
- fstype: squashfs
- opts: loop,ro
- state: mounted
-
-- name: Set up union root for post installation tasks
- mount:
- name: "{{ INSTALL_ROOT }}"
- src: none
- fstype: aufs
- opts: "noatime,dirs={{ RW_DIR.path }}=rw:{{ READ_ROOT }}=rr"
- state: mounted
-
-# ---- Post image installation tasks ----
-
-## ---- VyOS configuration ----
-- name: Make sure that config partition marker exists
- file:
- path: "{{ INSTALL_ROOT }}/opt/vyatta/etc/config/.vyatta_config"
- state: touch
-
-- name: Copy the default config for QEMU to the installed image
- copy:
- src: files/config.boot
- dest: "{{ INSTALL_ROOT }}/opt/vyatta/etc/config/config.boot"
- mode: 0755
-
-## ---- Install GRUB boot loader ----
-- name: Create GRUB directory
- file:
- path: "{{ WRITE_ROOT }}/boot/grub"
- state: directory
-
-# It is necessary to mount and bind /dev, /proc, /sys and /boot in order to execute grub-install
-# and install GRUB correctly within the {{ volume_drive }} using chroot
-
-# XXX: ansible mount module requires fstype so it cannot be used for binding an already
-# mounted location, we get to use mount directly at least for /boot
-- name: Mount and bind /dev /proc /sys and {{ WRITE_ROOT }}/boot to {{ INSTALL_ROOT }}
- shell: mount --bind /dev {{ INSTALL_ROOT }}/dev &&
- mount --bind /proc {{ INSTALL_ROOT }}/proc &&
- mount --bind /sys {{ INSTALL_ROOT }}/sys &&
- mount --bind {{ WRITE_ROOT }} {{ INSTALL_ROOT }}/boot
- args:
- warn: no
-
-- name: Install GRUB in the boot sector of {{ loopback.stdout }}
- command: chroot {{ INSTALL_ROOT }} grub-install --no-floppy --root-directory=/boot {{ loopback.stdout }} --force
- args:
- creates: "{{ INSTALL_ROOT }}/boot/grub/grubenv"
-
-- name: Configure GRUB
- template:
- src: templates/boot/grub/grub.cfg.j2
- dest: "{{ WRITE_ROOT }}/boot/grub/grub.cfg"
- mode: 0644
-
-- name: Create the persistence config
- copy:
- src: files/persistence.conf
- dest: "{{ WRITE_ROOT }}/persistence.conf"
- mode: 0644
diff --git a/roles/vagrant-libvirt/tasks/convert.yml b/roles/vagrant-libvirt/tasks/convert.yml
deleted file mode 100644
index ede229a..0000000
--- a/roles/vagrant-libvirt/tasks/convert.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-- name: Convert raw to qcow2
- command: qemu-img convert -f raw "{{ vyos_raw_img }}" -O qcow2 "{{ vyos_vagrant_libvirt_box_img }}"
-- name: Copy metadata.json
- become: false
- copy:
- src: "{{ vyos_vagrant_libvirt_metadata }}"
- dest: "{{ vyos_vagrant_libvirt_tmp_metadata }}"
-- name: Copy Vagrantfile
- become: false
- copy:
- src: "{{ vyos_vagrant_libvirt_vagrantfile }}"
- dest: "{{ vyos_vagrant_libvirt_tmp_vagrantfile }}"
-- name: Create Vagrant box
- become: false
- archive:
- path:
- - "{{ vyos_vagrant_libvirt_box_img }}"
- - "{{ vyos_vagrant_libvirt_tmp_metadata }}"
- - "{{ vyos_vagrant_libvirt_tmp_vagrantfile }}"
- dest: "{{ vyos_vagrant_libvirt_box }}"
- format: tar
diff --git a/roles/vagrant-libvirt/tasks/load_modules.yml b/roles/vagrant-libvirt/tasks/load_modules.yml
deleted file mode 100644
index 44295fe..0000000
--- a/roles/vagrant-libvirt/tasks/load_modules.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-- name: Load aufs module
- shell: modprobe aufs
diff --git a/roles/vagrant-libvirt/tasks/main.yml b/roles/vagrant-libvirt/tasks/main.yml
deleted file mode 100644
index c2a1b28..0000000
--- a/roles/vagrant-libvirt/tasks/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-- include_tasks: load_modules.yml
-- include_tasks: setup_iso.yml
-- include_tasks: build_image.yml
-- include_tasks: unmount.yml
-- include_tasks: convert.yml
-- include_tasks: release.yml
diff --git a/roles/vagrant-libvirt/tasks/release.yml b/roles/vagrant-libvirt/tasks/release.yml
deleted file mode 100644
index bfb9a63..0000000
--- a/roles/vagrant-libvirt/tasks/release.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-- name: Release image
- become: false
- copy:
- src: "{{ vyos_vagrant_libvirt_box }}"
- dest: "{{ vyos_images_dir }}/vyos-{{ version_string.stdout }}-vagrant-libvirt.box"
- when: vyos_images_dir is defined
-- name: Set box version
- set_fact:
- box_version: "{{ version_string.stdout.split('-')[2][0:8] }}.{{ version_string.stdout.split('-')[2][8:10] }}.{{ version_string.stdout.split('-')[2][10:12] }}"
- when: vyos_images_dir is defined and vyos_vagrant_box_base_url is defined
-- name: Create the box version
- uri:
- url: "https://app.vagrantup.com/api/v1/box/{{ vyos_vagrant_box_name }}/versions?access_token={{ vyos_vagrant_cloud_access_token }}"
- method: POST
- body: "version[version]={{ box_version }}"
- when: vyos_images_dir is defined and vyos_vagrant_box_base_url is defined and vyos_vagrant_cloud_access_token is defined
-- name: Create the box provider
- uri:
- url: "https://app.vagrantup.com/api/v1/box/{{ vyos_vagrant_box_name }}/version/{{ box_version }}/providers?access_token={{ vyos_vagrant_cloud_access_token }}"
- method: POST
- body: "provider[name]=libvirt&provider[url]={{ vyos_vagrant_box_base_url }}/vyos-{{ version_string.stdout }}-vagrant-libvirt.box"
- when: vyos_images_dir is defined and vyos_vagrant_box_base_url is defined and vyos_vagrant_cloud_access_token is defined
-- name: Release the box
- uri:
- url: "https://app.vagrantup.com/api/v1/box/{{ vyos_vagrant_box_name }}/version/{{ box_version }}/release?access_token={{ vyos_vagrant_cloud_access_token }}"
- method: PUT
- when: vyos_images_dir is defined and vyos_vagrant_box_base_url is defined and vyos_vagrant_cloud_access_token is defined
diff --git a/roles/vagrant-libvirt/tasks/setup_iso.yml b/roles/vagrant-libvirt/tasks/setup_iso.yml
deleted file mode 100644
index 18f1f5e..0000000
--- a/roles/vagrant-libvirt/tasks/setup_iso.yml
+++ /dev/null
@@ -1,57 +0,0 @@
-- name: Fetch VyOS ISO GPG signature
- uri:
- url: "{{ vyos_iso_url }}.asc"
- dest: "{{ vyos_iso_local }}.asc"
- status_code: 200,404,403
- tags: verify
- register: gpg_uri
-
-- name: Download VyOS ISO release
- get_url:
- url: "{{ vyos_iso_url }}"
- dest: "{{ vyos_iso_local }}"
-
-- name: Fetch the VyOS release GPG key
- get_url:
- url: "{{ vyos_key_url}}"
- dest: "{{ vyos_key_local }}"
- tags: verify
-
-- name: Install the VyOS release GPG key
- command: gpg --import {{ vyos_key_local }}
- when: gpg_uri.status == 200
- tags: verify
-
-- name: Validate ISO GPG signature
- command: gpg --verify {{ vyos_iso_local }}.asc {{ vyos_iso_local }}
- when: gpg_uri.status == 200
- tags: verify
-
-- name: Mount ISO
- mount:
- name: "{{ CD_ROOT }}"
- src: "{{ vyos_iso_local }}"
- fstype: iso9660
- opts: loop,ro
- state: mounted
-
-- name: Verify checksums of all the files in the ISO image
- command: md5sum -c md5sum.txt
- args:
- chdir: "{{ CD_ROOT }}"
- changed_when: False
-
-- name: Mount squashfs image from ISO
- mount:
- name: "{{ CD_SQUASH_ROOT }}"
- src: "{{ SQUASHFS_IMAGE }}"
- fstype: squashfs
- opts: loop,ro
- state: mounted
-
-- name: Read version string from iso packages
- shell: cat {{ CD_SQUASH_ROOT }}/opt/vyatta/etc/version | awk '{print $2}' | tr + -
- register: version_string
-
-- name: Debug version string as read from ISO
- debug: msg="This is version {{ version_string.stdout }}"
diff --git a/roles/vagrant-libvirt/tasks/unmount.yml b/roles/vagrant-libvirt/tasks/unmount.yml
deleted file mode 100644
index 39c3d52..0000000
--- a/roles/vagrant-libvirt/tasks/unmount.yml
+++ /dev/null
@@ -1,66 +0,0 @@
-# Unmount all mounts
-# If remove unmounted before absent, cannot unmount INSTALL_ROOT...
-- name: Unmount {{ INSTALL_ROOT }}/boot
- mount:
- name: "{{ INSTALL_ROOT }}/boot"
- src: "{{ WRITE_ROOT }}"
- fstype: none
- state: unmounted
-
-- name: Unmount {{ INSTALL_ROOT }}/boot
- mount:
- name: "{{ INSTALL_ROOT }}/boot"
- src: "{{ WRITE_ROOT }}"
- fstype: none
- state: absent
-
-- name: Unmount {{ INSTALL_ROOT }}/sys, {{ INSTALL_ROOT }}/proc, {{ INSTALL_ROOT }}/dev
- mount:
- name: "{{ INSTALL_ROOT }}/{{ item }}"
- src: "/{{ item }}"
- fstype: none
- state: unmounted
- with_items: [ 'sys', 'proc', 'dev' ]
-
-- name: Unmount {{ INSTALL_ROOT }}/sys, {{ INSTALL_ROOT }}/proc, {{ INSTALL_ROOT }}/dev
- mount:
- name: "{{ INSTALL_ROOT }}/{{ item }}"
- src: "/{{ item }}"
- fstype: none
- state: absent
- with_items: [ 'sys', 'proc', 'dev' ]
-
-- name: Unmount {{ INSTALL_ROOT }}
- mount:
- name: "{{ INSTALL_ROOT }}"
- src: overlayfs
- fstype: overlayfs
- state: absent
-
-- name: Unmount {{ READ_ROOT }}
- mount:
- name: "{{ READ_ROOT }}"
- src: "{{ WRITE_ROOT }}/boot/{{ version_string.stdout }}/{{ version_string.stdout }}.squashfs"
- fstype: squashfs
- state: absent
-
-- name: Unmount {{ WRITE_ROOT }}
- mount:
- name: "{{ WRITE_ROOT }}"
- src: "{{ loopback.stdout }}"
- fstype: "{{ ROOT_FSTYPE }}"
- state: absent
-
-- name: Unmount {{ CD_SQUASH_ROOT }}
- mount:
- name: "{{ CD_SQUASH_ROOT }}"
- src: "{{ SQUASHFS_IMAGE }}"
- fstype: squashfs
- state: absent
-
-- name: Unmount {{ CD_ROOT }}
- mount:
- name: "{{ CD_ROOT }}"
- src: "{{ vyos_iso_local }}"
- fstype: iso9660
- state: absent
diff --git a/roles/vagrant-libvirt/templates/boot/grub/device.map.j2 b/roles/vagrant-libvirt/templates/boot/grub/device.map.j2
deleted file mode 100644
index e14205e..0000000
--- a/roles/vagrant-libvirt/templates/boot/grub/device.map.j2
+++ /dev/null
@@ -1 +0,0 @@
-(hd0) /dev/sda
diff --git a/roles/vagrant-libvirt/templates/boot/grub/grub.cfg.j2 b/roles/vagrant-libvirt/templates/boot/grub/grub.cfg.j2
deleted file mode 100644
index cf126ab..0000000
--- a/roles/vagrant-libvirt/templates/boot/grub/grub.cfg.j2
+++ /dev/null
@@ -1,7 +0,0 @@
-set default=0
-set timeout=0
-
-menuentry "VyOS VM Image {{ version_string.stdout }}" {
- linux /boot/{{ version_string.stdout }}/vmlinuz boot=live selinux=0 vyos-union=/boot/{{ version_string.stdout }} console=tty1
- initrd /boot/{{ version_string.stdout }}/initrd.img
-}
diff --git a/roles/vagrant-libvirt/vars/main.yml b/roles/vagrant-libvirt/vars/main.yml
deleted file mode 100644
index 1fe0af8..0000000
--- a/roles/vagrant-libvirt/vars/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-vyos_raw_img: /tmp/vyos_raw_image.img
-vyos_vagrant_libvirt_box_img: /tmp/box.img
-vyos_vagrant_libvirt_box: /tmp/vyos_vagrant_libvirt_image.box
-vyos_vagrant_libvirt_metadata: files/metadata.json
-vyos_vagrant_libvirt_vagrantfile: files/Vagrantfile
-vyos_vagrant_libvirt_tmp_metadata: /tmp/metadata.json
-vyos_vagrant_libvirt_tmp_vagrantfile: /tmp/Vagrantfile
-vyos_vagrant_box_name: vyos/current