diff options
author | Kim Hagen <kim@sentrium.io> | 2020-05-04 16:36:43 -0500 |
---|---|---|
committer | Kim Hagen <kim@sentrium.io> | 2020-05-04 16:36:43 -0500 |
commit | ab0d98b7baa485959506bb75c28305d86a8f3b33 (patch) | |
tree | 1a2ccd8ec92426d92937ad8b4f26f1653c65e99f | |
parent | e025218641378434864f73cf0b7354ce5b97c6a9 (diff) | |
download | vyos-vm-images-ab0d98b7baa485959506bb75c28305d86a8f3b33.tar.gz vyos-vm-images-ab0d98b7baa485959506bb75c28305d86a8f3b33.zip |
simple vmware ova
-rw-r--r-- | hyperv.yml | 2 | ||||
-rw-r--r-- | qemu.yml | 2 | ||||
-rw-r--r-- | roles/download-iso/tasks/main.yml | 7 | ||||
-rw-r--r-- | roles/install-cloud-init-wrapper/tasks/main.yml | 6 | ||||
-rw-r--r-- | roles/install-cloud-init/defaults/main.yml | 1 | ||||
-rw-r--r-- | roles/install-cloud-init/tasks/main.yml | 3 | ||||
-rw-r--r-- | roles/install-config/templates/config.boot.j2 | 6 | ||||
-rw-r--r-- | roles/install-grub/tasks/main.yml | 14 | ||||
-rw-r--r-- | roles/install-open-vmdk/tasks/main.yml | 1 | ||||
-rw-r--r-- | roles/mount-iso/tasks/main.yml | 2 | ||||
-rw-r--r-- | roles/mount-root-fs/tasks/main.yml | 2 | ||||
-rw-r--r-- | roles/setup-root-partition/tasks/main.yml | 1 | ||||
-rw-r--r-- | roles/unmount-all/tasks/main.yml | 22 | ||||
-rw-r--r-- | roles/vmware-ova/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/vmware-ova/tasks/main.yml | 10 | ||||
-rw-r--r-- | roles/vmware-ova/templates/vyos_vmware_simple.ovf.j2 | 123 | ||||
-rw-r--r-- | vmware.yml | 2 |
17 files changed, 170 insertions, 36 deletions
@@ -8,7 +8,7 @@ vyos_format: vhdx vyos_hyperv_img: /tmp/vyos_hyperv_image.vhdx vyos_output_img: "{{ vyos_hyperv_img }}" - cloud_init: "false" + cloud_init: False cloud_init_ds_string: "{{ cloud_init_ds | default('NoCloud, ConfigDrive, None') }}" cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}" roles: @@ -7,7 +7,7 @@ vyos_format: qcow2 vyos_qemu_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-qemu.qcow2" vyos_output_img: "{{ vyos_qemu_img }}" - cloud_init: "false" + cloud_init: False cloud_init_ds_string: "{{ cloud_init_ds | default('NoCloud,ConfigDrive,None') }}" cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}" roles: diff --git a/roles/download-iso/tasks/main.yml b/roles/download-iso/tasks/main.yml index dc71771..252bd50 100644 --- a/roles/download-iso/tasks/main.yml +++ b/roles/download-iso/tasks/main.yml @@ -6,13 +6,13 @@ - name: set latest_iso as vyos_iso_url set_fact: vyos_iso_url: "{{ latest_iso_result.latest_iso }}" - when: latest_iso_result is defined + when: latest_iso_result is not skipped - name: Fetch VyOS ISO GPG signature uri: url: "{{ vyos_iso_url }}.asc" dest: "{{ vyos_iso_local }}.asc" - status_code: 200,404,403 + status_code: 200,304,404,403 tags: verify register: gpg_uri @@ -26,13 +26,16 @@ url: "{{ vyos_key_url}}" dest: "{{ vyos_key_local }}" tags: verify + when: latest_iso_result is not skipped - name: Install the VyOS release GPG key command: gpg --import {{ vyos_key_local }} when: gpg_uri.status == 200 tags: verify + when: latest_iso_result is not skipped - name: Validate ISO GPG signature command: gpg --verify {{ vyos_iso_local }}.asc {{ vyos_iso_local }} when: gpg_uri.status == 200 tags: verify + when: latest_iso_result is not skipped diff --git a/roles/install-cloud-init-wrapper/tasks/main.yml b/roles/install-cloud-init-wrapper/tasks/main.yml index 7ab9705..10b9a15 100644 --- a/roles/install-cloud-init-wrapper/tasks/main.yml +++ b/roles/install-cloud-init-wrapper/tasks/main.yml @@ -1,12 +1,12 @@ - name: Check if we need to install Cloud-Init include_role: name: install-cloud-init - when: cloud_init == "true" + when: cloud_init - name: Set Cloud-Init tag for image file name set_fact: ci_tag: "-cloud-init" - when: cloud_init == "true" + when: cloud_init # - name: Set empty Cloud-Init tag for image file name # set_fact: # ci_tag: "" -# when: cloud_init == "false" +# when: not cloud_init diff --git a/roles/install-cloud-init/defaults/main.yml b/roles/install-cloud-init/defaults/main.yml new file mode 100644 index 0000000..f3f4472 --- /dev/null +++ b/roles/install-cloud-init/defaults/main.yml @@ -0,0 +1 @@ +cloud_init_disable_config: False diff --git a/roles/install-cloud-init/tasks/main.yml b/roles/install-cloud-init/tasks/main.yml index 2ae314b..b9998cb 100644 --- a/roles/install-cloud-init/tasks/main.yml +++ b/roles/install-cloud-init/tasks/main.yml @@ -56,8 +56,7 @@ src: "files/90_disable_config_stage.cfg" dest: "{{ vyos_install_root }}/etc/cloud/cloud.cfg.d/90_disable_config_stage.cfg" when: - - cloud_init_disable_config is defined - - cloud_init_disable_config == "true" + - cloud_init_disable_config - name: restore original resolv.conf become: true command: mv /tmp/resolv.conf {{ vyos_install_root }}/etc/resolv.conf diff --git a/roles/install-config/templates/config.boot.j2 b/roles/install-config/templates/config.boot.j2 index 30506f8..f0f1e3d 100644 --- a/roles/install-config/templates/config.boot.j2 +++ b/roles/install-config/templates/config.boot.j2 @@ -3,7 +3,7 @@ system { login { user vyos { authentication { -{% if cloud_init == "true" and not ( keep_user is defined and keep_user == "true" ) %} +{% if cloud_init and not ( keep_user is defined and keep_user == "true" ) %} encrypted-password "*" {% else %} encrypted-password "$6$MjV2YvKQ56q$QbL562qhRoyUu8OaqrXagicvcsNpF1HssCY06ZxxghDJkBCfSfTE/4FlFB41xZcd/HqYyVBuRt8Zyq3ozJ0dc." @@ -33,7 +33,7 @@ system { } } interfaces { -{% if cloud_init == "true" and not ( empty_config is defined and empty_config == "true" ) %} +{% if cloud_init and not ( empty_config is defined and empty_config == "true" ) %} ethernet eth0 { address dhcp } @@ -41,7 +41,7 @@ interfaces { loopback lo { } } -{% if cloud_init == "true" and not ( empty_config is defined and empty_config == "true" ) %} +{% if cloud_init and not ( empty_config is defined and empty_config == "true" ) %} service { ssh { port 22 diff --git a/roles/install-grub/tasks/main.yml b/roles/install-grub/tasks/main.yml index f9cc772..d849075 100644 --- a/roles/install-grub/tasks/main.yml +++ b/roles/install-grub/tasks/main.yml @@ -22,10 +22,12 @@ - name: Mount EFI mount: - src: "{{ vyos_target_drive }}p2" - path: "{{ vyos_install_root }}/boot/efi" - fstype: vfat - state: mounted + src: "{{ vyos_target_drive }}p2" + path: "{{ vyos_install_root }}/boot/efi" + fstype: vfat + state: mounted + fstab: /tmp/fstab + become: true - name: Install GRUB in the boot sector of {{ vyos_target_drive }} become: true @@ -49,5 +51,5 @@ src: "{{ vyos_target_drive }}p2" path: "{{ vyos_install_root }}/boot/efi" fstype: vfat - state: absent - + state: unmounted + become: true diff --git a/roles/install-open-vmdk/tasks/main.yml b/roles/install-open-vmdk/tasks/main.yml index 8d19da4..101e939 100644 --- a/roles/install-open-vmdk/tasks/main.yml +++ b/roles/install-open-vmdk/tasks/main.yml @@ -24,6 +24,7 @@ target: install when: stat_result.stat.exists == False - name: Delete installation directory and archive + become: true file: path: "{{ item }}" state: absent diff --git a/roles/mount-iso/tasks/main.yml b/roles/mount-iso/tasks/main.yml index 6e6b09d..0e67132 100644 --- a/roles/mount-iso/tasks/main.yml +++ b/roles/mount-iso/tasks/main.yml @@ -5,6 +5,7 @@ src: "{{ vyos_iso_local }}" fstype: iso9660 opts: loop,ro + fstab: /tmp/fstab state: mounted - name: Verify checksums of all the files in the ISO image @@ -20,4 +21,5 @@ src: "{{ vyos_squashfs_image }}" fstype: squashfs opts: loop,ro + fstab: /tmp/fstab state: mounted diff --git a/roles/mount-root-fs/tasks/main.yml b/roles/mount-root-fs/tasks/main.yml index 67d036d..43b7dce 100644 --- a/roles/mount-root-fs/tasks/main.yml +++ b/roles/mount-root-fs/tasks/main.yml @@ -5,6 +5,7 @@ src: "{{ vyos_write_root }}/boot/{{ vyos_version }}/{{ vyos_version }}.squashfs" fstype: squashfs opts: loop,ro + fstab: /tmp/fstab state: mounted - name: Set up union root for post installation tasks @@ -14,4 +15,5 @@ src: none fstype: aufs opts: "noatime,dirs={{ vyos_write_root }}/boot/{{ vyos_version }}/rw=rw:{{ vyos_read_root }}=rr" + fstab: /tmp/fstab state: mounted diff --git a/roles/setup-root-partition/tasks/main.yml b/roles/setup-root-partition/tasks/main.yml index 5ba9cd8..991161d 100644 --- a/roles/setup-root-partition/tasks/main.yml +++ b/roles/setup-root-partition/tasks/main.yml @@ -51,4 +51,5 @@ name: "{{ vyos_write_root }}" src: "{{ vyos_target_drive }}p3" fstype: "{{ vyos_root_fstype }}" + fstab: /tmp/fstab state: mounted diff --git a/roles/unmount-all/tasks/main.yml b/roles/unmount-all/tasks/main.yml index 98d4cdd..ba9a3a5 100644 --- a/roles/unmount-all/tasks/main.yml +++ b/roles/unmount-all/tasks/main.yml @@ -1,5 +1,4 @@ # Unmount all mounts -# If remove unmounted before absent, cannot unmount vyos_install_root... - name: Unmount {{ vyos_install_root }}/boot become: true mount: @@ -8,21 +7,12 @@ fstype: none state: unmounted -- name: Unmount {{ vyos_install_root }}/boot - become: true - mount: - name: "{{ vyos_install_root }}/boot" - src: "{{ vyos_write_root }}" - fstype: none - state: absent - - name: Unmount {{ vyos_install_root }} become: true mount: name: "{{ vyos_install_root }}" - src: overlayfs - fstype: overlayfs - state: absent + fstype: aufs + state: unmounted - name: Unmount {{ vyos_read_root }} become: true @@ -30,7 +20,7 @@ name: "{{ vyos_read_root }}" src: "{{ vyos_write_root }}/boot/{{ vyos_version }}/{{ vyos_version }}.squashfs" fstype: squashfs - state: absent + state: unmounted - name: Unmount {{ vyos_write_root }} become: true @@ -38,7 +28,7 @@ name: "{{ vyos_write_root }}" src: "{{ vyos_target_drive }}" fstype: "{{ vyos_root_fstype }}" - state: absent + state: unmounted - name: Remove image partitions become: true @@ -50,7 +40,7 @@ name: "{{ vyos_cd_squash_root }}" src: "{{ vyos_squashfs_image }}" fstype: squashfs - state: absent + state: unmounted - name: Unmount {{ vyos_cd_root }} become: true @@ -58,4 +48,4 @@ name: "{{ vyos_cd_root }}" src: "{{ vyos_iso_local }}" fstype: iso9660 - state: absent + state: unmounted diff --git a/roles/vmware-ova/defaults/main.yml b/roles/vmware-ova/defaults/main.yml new file mode 100644 index 0000000..30bbe17 --- /dev/null +++ b/roles/vmware-ova/defaults/main.yml @@ -0,0 +1,2 @@ +--- +simple_ova: False diff --git a/roles/vmware-ova/tasks/main.yml b/roles/vmware-ova/tasks/main.yml index 0146a15..85fbb6a 100644 --- a/roles/vmware-ova/tasks/main.yml +++ b/roles/vmware-ova/tasks/main.yml @@ -20,6 +20,13 @@ template: src: templates/vyos_vmware_image.ovf.j2 dest: "{{ vyos_vmware_ovf }}" + when: not simple_ova +- name: Generate OVF + become: false + template: + src: templates/vyos_vmware_image.ovf.j2 + dest: "{{ vyos_vmware_ovf }}" + when: simple_ova - name: Generate MF shell: openssl sha1 "{{ vyos_vmware_vmdk | basename }}" "{{ vyos_vmware_ovf | basename }}" args: @@ -32,7 +39,8 @@ content: "{{ result.stdout }}" - name: Converting the OVF to signed OVA become: false - command: "ovftool --compress=9 --privateKey={{ vyos_vmware_private_key_path }} {{ vyos_vmware_ovf }} {{ vyos_vmware_ova }}" + command: "ovftool --compress=9 --privateKey={{ vyos_vmware_private_key_path }} + {{ vyos_vmware_ovf }} {{ vyos_vmware_ova }}" - name: Delete temporary files for VMware file: path: "{{ item }}" diff --git a/roles/vmware-ova/templates/vyos_vmware_simple.ovf.j2 b/roles/vmware-ova/templates/vyos_vmware_simple.ovf.j2 new file mode 100644 index 0000000..a60b66e --- /dev/null +++ b/roles/vmware-ova/templates/vyos_vmware_simple.ovf.j2 @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ovf:Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <References> + <File ovf:href="vyos_vmware_image.vmdk" ovf:id="file1" ovf:size="{{ vmdk_file_size.stdout }}"/> + </References> + <ovf:NetworkSection> + <ovf:Info>The list of logical networks</ovf:Info> + <ovf:Network ovf:name="WAN"> + <ovf:Description>LAN network</ovf:Description> + </ovf:Network> + <ovf:Network ovf:name="LAN"> + <ovf:Description>WAN network</ovf:Description> + </ovf:Network> + </ovf:NetworkSection> + <vmw:IpAssignmentSection ovf:required="false" vmw:protocols="IPv4 IPv6" vmw:schemes="ovfenv dhcp"> + <Info>Supported IP assignment schemes</Info> + </vmw:IpAssignmentSection> + <DiskSection> + <Info>Virtual disk information</Info> + <Disk ovf:capacity="10" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="{{vmdk_populated_size}}"/> + </DiskSection> + <VirtualSystem ovf:id="VyOS"> + <Info>A virtual machine</Info> + <ProductSection ovf:required="false"> + <Info>VyOS is a Linux-based network operating system that provides software-based network routing, firewall, and VPN functionality.</Info> + <Product>VyOS</Product> + <Vendor>Sentrium S.L.</Vendor> + <Version>{{version}}</Version> + <ProductUrl>https://www.vyos.io</ProductUrl> + <VendorUrl>https://sentrium.io/</VendorUrl> + <AppUrl/> + <Category>Appliance user Settings</Category> + </ProductSection> + <ProductSection ovf:class="vm" ovf:required="false"> + <Info>VM specific properties</Info> + <Property ovf:key="vmname" ovf:type="string" ovf:value="VyOS"/> + </ProductSection> + <AnnotationSection> + <Info/> + <Annotation>VyOS</Annotation> + </AnnotationSection> + <OperatingSystemSection ovf:id="96" ovf:version="6" vmw:osType="debian8_64Guest"> + <Info>The operating system installed</Info> + <Description>Debian GNU/Linux 8 (64-bit)</Description> + </OperatingSystemSection> + <VirtualHardwareSection ovf:required="false" ovf:transport="com.vmware.guestInfo"> + <Info>Virtual Hardware Requirements</Info> + <System> + <vssd:ElementName>Virtual Hardware Family</vssd:ElementName> + <vssd:InstanceID>0</vssd:InstanceID> + <vssd:VirtualSystemType>vmx-11</vssd:VirtualSystemType> + </System> + <Item> + <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits> + <rasd:Description>Number of virtual CPUs</rasd:Description> + <rasd:ElementName xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1 virtual CPU</rasd:ElementName> + <rasd:InstanceID xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</rasd:InstanceID> + <rasd:ResourceType>3</rasd:ResourceType> + <rasd:VirtualQuantity>1</rasd:VirtualQuantity> + </Item> + <Item> + <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits> + <rasd:Description>Memory Size</rasd:Description> + <rasd:ElementName xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4 GB of memory</rasd:ElementName> + <rasd:InstanceID xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</rasd:InstanceID> + <rasd:ResourceType>4</rasd:ResourceType> + <rasd:VirtualQuantity>4096</rasd:VirtualQuantity> + </Item> + <Item> + <rasd:Address xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">0</rasd:Address> + <rasd:ElementName xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">SCSI Controller 0 - VMware Paravirtual SCSI</rasd:ElementName> + <rasd:InstanceID xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</rasd:InstanceID> + <rasd:ResourceSubType>VirtualSCSI</rasd:ResourceSubType> + <rasd:ResourceType>6</rasd:ResourceType> + </Item> + <Item> + <rasd:AddressOnParent>0</rasd:AddressOnParent> + <rasd:ElementName xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">disk0</rasd:ElementName> + <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource> + <rasd:InstanceID xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</rasd:InstanceID> + <rasd:Parent>3</rasd:Parent> + <rasd:ResourceType>17</rasd:ResourceType> + </Item> + <Item> + <rasd:Address>0</rasd:Address> + <rasd:ElementName xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">IDE Controller 0</rasd:ElementName> + <rasd:InstanceID xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">5</rasd:InstanceID> + <rasd:ResourceType>5</rasd:ResourceType> + </Item> + <Item> + <rasd:AddressOnParent>0</rasd:AddressOnParent> + <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> + <rasd:ElementName xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">CD/DVD Drive 1</rasd:ElementName> + <rasd:InstanceID xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">6</rasd:InstanceID> + <rasd:Parent>5</rasd:Parent> + <rasd:ResourceType>15</rasd:ResourceType> + </Item> + <ovf:Item> + <rasd:AddressOnParent>7</rasd:AddressOnParent> + <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> + <rasd:Connection>WAN</rasd:Connection> + <rasd:Description>NIC representing LAN</rasd:Description> + <rasd:ElementName>WAN</rasd:ElementName> + <rasd:InstanceID>7</rasd:InstanceID> + <rasd:ResourceSubType>vmxnet3</rasd:ResourceSubType> + <rasd:ResourceType>10</rasd:ResourceType> + </ovf:Item> + <ovf:Item> + <rasd:AddressOnParent>8</rasd:AddressOnParent> + <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> + <rasd:Connection>LAN</rasd:Connection> + <rasd:Description>NIC representing WAN</rasd:Description> + <rasd:ElementName>LAN</rasd:ElementName> + <rasd:InstanceID>8</rasd:InstanceID> + <rasd:ResourceSubType>vmxnet3</rasd:ResourceSubType> + <rasd:ResourceType>10</rasd:ResourceType> + </ovf:Item> + <vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="true"/> + <vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="true"/> + <vmw:ExtraConfig ovf:required="false" vmw:key="sched.mem.pin" vmw:value="TRUE"/> + </VirtualHardwareSection> + </VirtualSystem> +</ovf:Envelope> @@ -8,7 +8,7 @@ vyos_vmdk_size: 10 vyos_vmware_ova: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-vmware.ova" vyos_output_img: "{{ vyos_vmware_ova }}" - cloud_init: "true" + cloud_init: True cloud_init_ds_string: "{{ cloud_init_ds | default('OVF,None') }}" cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}" roles: |