diff options
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | qemu.yml | 62 | ||||
-rw-r--r-- | raw.yml | 60 | ||||
-rw-r--r-- | roles/install-config/templates/config.boot.j2 | 6 | ||||
-rw-r--r-- | roles/vmware/tasks/main.yml (renamed from roles/vmware-ova/tasks/main.yml) | 12 | ||||
-rw-r--r-- | roles/vmware/templates/vyos_vmware_image.ovf.j2 (renamed from roles/vmware-ova/templates/vyos_vmware_image.ovf.j2) | 32 | ||||
-rw-r--r-- | roles/vmware/tests/inventory (renamed from roles/vmware-ova/tests/inventory) | 0 | ||||
-rw-r--r-- | roles/vmware/tests/test.yml (renamed from roles/vmware-ova/tests/test.yml) | 0 | ||||
-rw-r--r-- | roles/vmware/vars/main.yml (renamed from roles/vmware-ova/vars/main.yml) | 0 | ||||
-rw-r--r-- | vmware.yml | 58 |
10 files changed, 161 insertions, 79 deletions
@@ -32,12 +32,18 @@ You need to copy the ISO image with VyOS to /tmp/vyos.iso before running ansible ansible-playbook qemu.yml ``` -- VMware +- VMware Cloud-init ``` ansible-playbook vmware.yml -e vyos_vmware_private_key_path=path_to_private_key ``` +- VMware simple ova + + ``` + ansible-playbook vmware.yml -e vyos_vmware_private_key_path=path_to_private_key -e cloud_init=false -e ovf_template=simple + ``` + - Microsoft Hyper-V ``` @@ -136,4 +142,4 @@ You need to copy the ISO image with VyOS to /tmp/vyos.iso before running ansible ``` -e custom_packages=true - ```
\ No newline at end of file + ``` @@ -5,31 +5,45 @@ vars: vyos_platform: QEMU vyos_format: qcow2 - vyos_qemu_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-qemu.qcow2" + vyos_qemu_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-{{vyos_disk_size}}G-qemu.qcow2" vyos_output_img: "{{ vyos_qemu_img }}" cloud_init: "false" cloud_init_ds_string: "{{ cloud_init_ds | default('NoCloud,ConfigDrive,None') }}" cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}" - roles: - - install-packages - - load-modules - - download-iso - - mount-iso - - get-version - - create-disk - - setup-root-partition - - install-image - - mount-root-fs - - install-config - - install-grub - - install-persistence-conf - - install-cloud-init-wrapper - - install-guest-agent-wrapper - - install-custom-packages-wrapper - - fstrim - - unmount-pre - - create-pxe-archive - - unmount-all - - qemu-qcow2 - - cleanup-ending - - release + tasks: + - block: + - include_role: + name: '{{ roleinputvar }}' + loop: + - install-packages + - load-modules + - download-iso + - mount-iso + - get-version + - create-disk + - setup-root-partition + - install-image + - mount-root-fs + - install-config + - install-grub + - install-persistence-conf + - install-cloud-init-wrapper + - install-guest-agent-wrapper + - install-custom-packages-wrapper + - fstrim + - unmount-pre + - create-pxe-archive + - unmount-all + - qemu-qcow2 + - cleanup-ending + - release + loop_control: + loop_var: roleinputvar + rescue: + - include_role: + name: '{{ roleinputvar }}' + loop: + - unmount-pre + - unmount-all + loop_control: + loop_var: roleinputvar @@ -5,31 +5,45 @@ vars: vyos_platform: QEMU vyos_format: raw - vyos_qemu_raw_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-qemu.raw" + vyos_qemu_raw_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-{{vyos_disk_size}}G-qemu.raw" vyos_output_img: "{{ vyos_qemu_img }}" cloud_init: "false" cloud_init_ds_string: "{{ cloud_init_ds | default('NoCloud,ConfigDrive,None') }}" cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}" - roles: - - install-packages - - load-modules - - download-iso - - mount-iso - - get-version - - create-disk - - setup-root-partition - - install-image - - mount-root-fs - - install-config - - install-grub - - install-persistence-conf - - install-cloud-init-wrapper - - install-guest-agent-wrapper - - fstrim - - unmount-pre - - create-pxe-archive - - unmount-all - - qemu-raw - - cleanup-ending - - release + tasks: + - block: + - include_role: + name: '{{ roleinputvar }}' + loop: + - install-packages + - load-modules + - download-iso + - mount-iso + - get-version + - create-disk + - setup-root-partition + - install-image + - mount-root-fs + - install-config + - install-grub + - install-persistence-conf + - install-cloud-init-wrapper + - install-guest-agent-wrapper + - fstrim + - unmount-pre + - create-pxe-archive + - unmount-all + - qemu-raw + - cleanup-ending + - release + loop_control: + loop_var: roleinputvar + rescue: + - include_role: + name: '{{ roleinputvar }}' + loop: + - unmount-pre + - unmount-all + loop_control: + loop_var: roleinputvar diff --git a/roles/install-config/templates/config.boot.j2 b/roles/install-config/templates/config.boot.j2 index 852905e..b02c07e 100644 --- a/roles/install-config/templates/config.boot.j2 +++ b/roles/install-config/templates/config.boot.j2 @@ -26,9 +26,9 @@ system { } } ntp { - server "0.pool.ntp.org" - server "1.pool.ntp.org" - server "2.pool.ntp.org" + server "time1.vyos.net" + server "time2.vyos.net" + server "time3.vyos.net" } config-management { commit-revisions 100 diff --git a/roles/vmware-ova/tasks/main.yml b/roles/vmware/tasks/main.yml index 0146a15..f62c83f 100644 --- a/roles/vmware-ova/tasks/main.yml +++ b/roles/vmware/tasks/main.yml @@ -1,38 +1,48 @@ - name: Convert raw to vmdk command: qemu-img convert -f raw "{{ vyos_raw_img }}" -O vmdk -o adapter_type=lsilogic "{{ vyos_vmware_tmp_vmdk }}" + - name: Fix vmdk with open-vmdk command: vmdk-convert "{{ vyos_vmware_tmp_vmdk }}" "{{ vyos_vmware_vmdk }}" + - name: Delete temporary image file: path: "{{ vyos_vmware_tmp_vmdk }}" state: absent + - name: Get vmdk_file_size shell: du --bytes "{{ vyos_vmware_vmdk }}" | cut -f1 register: vmdk_file_size + - name: Get vmdk_populated_size shell: vmdk-convert -i "{{ vyos_vmware_vmdk }}" register: result + - name: Set vmdk_populated_size set_fact: vmdk_populated_size: "{{ (result.stdout | from_json).used }}" + - name: Generate OVF become: false template: src: templates/vyos_vmware_image.ovf.j2 dest: "{{ vyos_vmware_ovf }}" + - name: Generate MF shell: openssl sha1 "{{ vyos_vmware_vmdk | basename }}" "{{ vyos_vmware_ovf | basename }}" args: chdir: /tmp register: result + - name: Create MF become: false copy: dest: "{{ vyos_vmware_mf }}" 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 --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_image.ovf.j2 b/roles/vmware/templates/vyos_vmware_image.ovf.j2 index 7f58678..81a9b3a 100644 --- a/roles/vmware-ova/templates/vyos_vmware_image.ovf.j2 +++ b/roles/vmware/templates/vyos_vmware_image.ovf.j2 @@ -12,6 +12,7 @@ <ovf:Description>LAN network</ovf:Description> </ovf:Network> </ovf:NetworkSection> + {%- if ovf_template|default('ci') != 'simple' -%} <DeploymentOptionSection> <Info>List of profiles</Info> <Configuration ovf:default="true" ovf:id="1CPU-512MB"> @@ -27,6 +28,7 @@ <Description ovf:msgid="Large.description">Large hardware profile - 8 vCPUs, 32 GB RAM</Description> </Configuration> </DeploymentOptionSection> + {%- endif -%} <vmw:IpAssignmentSection ovf:required="false" vmw:protocols="IPv4 IPv6" vmw:schemes="ovfenv dhcp"> <Info>Supported IP assignment schemes</Info> </vmw:IpAssignmentSection> @@ -45,6 +47,7 @@ <VendorUrl>https://sentrium.io/</VendorUrl> <AppUrl/> <Category>Appliance user Settings</Category> + {%- if ovf_template|default('ci') != 'simple' -%} <Property ovf:key="password" ovf:password="true" ovf:qualifiers="MinLen(8)" ovf:type="string" ovf:userConfigurable="true" ovf:value=""> <Label ovf:msgid="Password.label">Password</Label> <Description ovf:msgid="Password.description">The password for the appliance 'vyos' account. Passwords must be at least 8 characters in length.</Description> @@ -95,6 +98,7 @@ <Label>Cloud-init User-Data</Label> <Description>User-Data, encoded with base64.</Description> </Property> + {%- endif -%} </ProductSection> <ProductSection ovf:class="vm" ovf:required="false"> <Info>VM specific properties</Info> @@ -104,17 +108,18 @@ <Info/> <Annotation>VyOS</Annotation> </AnnotationSection> - <OperatingSystemSection ovf:id="96" ovf:version="6" vmw:osType="debian8_64Guest"> + <OperatingSystemSection ovf:id="96" ovf:version="6" vmw:osType="{{ vmware_guest }}"> <Info>The operating system installed</Info> - <Description>Debian GNU/Linux 8 (64-bit)</Description> + <Description>Debian GNU/Linux {{ debian_release }} (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> + <vssd:VirtualSystemType>vmx-{{ 11 if debian_release == 8 else 13 }}</vssd:VirtualSystemType> </System> + {%- if ovf_template|default('ci') != 'simple' -%} <Item configuration="1CPU-512MB"> <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits> <rasd:Description>Number of virtual CPUs</rasd:Description> @@ -166,6 +171,24 @@ <rasd:VirtualQuantity>32768</rasd:VirtualQuantity> <rasd:Reservation>32768</rasd:Reservation> </Item> + {%- else -%} + <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> + {%- endif -%} <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> @@ -217,7 +240,6 @@ </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>
\ No newline at end of file +</ovf:Envelope> diff --git a/roles/vmware-ova/tests/inventory b/roles/vmware/tests/inventory index 878877b..878877b 100644 --- a/roles/vmware-ova/tests/inventory +++ b/roles/vmware/tests/inventory diff --git a/roles/vmware-ova/tests/test.yml b/roles/vmware/tests/test.yml index 58552e3..58552e3 100644 --- a/roles/vmware-ova/tests/test.yml +++ b/roles/vmware/tests/test.yml diff --git a/roles/vmware-ova/vars/main.yml b/roles/vmware/vars/main.yml index 598f592..598f592 100644 --- a/roles/vmware-ova/vars/main.yml +++ b/roles/vmware/vars/main.yml @@ -11,24 +11,40 @@ cloud_init: "true" cloud_init_ds_string: "{{ cloud_init_ds | default('OVF,None') }}" cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}" - roles: - - install-packages - - load-modules - - download-iso - - mount-iso - - get-version - - create-disk - - setup-root-partition - - install-image - - mount-root-fs - - install-config - - install-grub - - install-persistence-conf - - install-cloud-init-wrapper - - fstrim - - unmount-pre - - unmount-all - - install-open-vmdk - - vmware-ova - - cleanup-ending - - release + vmware_guest: debian10_64Guest + debian_release: 10 + tasks: + - block: + - include_role: + name: '{{ roleinputvar }}' + loop: + - install-packages + - load-modules + - download-iso + - mount-iso + - get-version + - create-disk + - setup-root-partition + - install-image + - mount-root-fs + - install-config + - install-grub + - install-persistence-conf + - install-cloud-init-wrapper + - fstrim + - unmount-pre + - unmount-all + - install-open-vmdk + - vmware + - cleanup-ending + - release + loop_control: + loop_var: roleinputvar + rescue: + - include_role: + name: '{{ roleinputvar }}' + loop: + - unmount-pre + - unmount-all + loop_control: + loop_var: roleinputvar |