noseka1 / openshift-auto-upi

OpenShift Automated User-Provided Infrastructure
Apache License 2.0
98 stars 51 forks source link

request ability to add multiple storage devices in hosts #18

Open jfblaine opened 4 years ago

jfblaine commented 4 years ago

To help facilitate installation of openshift container storage, it would be very helpful to be able to add multiple storage devices to a host. For example:


  - hostname: ocs-0
    role: infra
    ipaddr: 192.168.150.30
    macaddr: 00:50:56:94:99:23
    num_cpus: 10
    memory_gb: 24
    disk_gb: 120
    disk_gb: 200
    ignition_config: worker.ign
    ignition_transform:
      filetranspiler_roots:
        - files/ignition/filetranspiler/non-bootstrap
#      jsonpatches:
#        - files/ignition/jsonpatch/non-bootstrap/password.json
noseka1 commented 4 years ago

This would be a nice feature. Thanks for posting it.

jfblaine commented 4 years ago

I have added the feature to add one additional disk to vpshere by adding an element in the hosts file as such:

  - hostname: ocs-0
    role: infra
    ipaddr: 192.168.150.30
    macaddr: 00:50:56:94:99:23
    num_cpus: 10
    memory_gb: 24
    disk_gb: 120
    ocs_disk_gb: 200
    ignition_config: worker.ign
    ignition_transform:
      filetranspiler_roots:
        - files/ignition/filetranspiler/non-bootstrap
#      jsonpatches:
#        - files/ignition/jsonpatch/non-bootstrap/password.json
    bmc:
      username: admin
      password: ''
      hostname: 192.168.150.130
      port: 623

Then I added the following to roles/openshift_vsphere/tasks/deploy_host.yml (I only added the when block to the first task):

- name: Create a virtual machine from the template
  vmware_guest:
    hostname: '{{ vsphere.vcenter_hostname }}'
    username: '{{ vsphere.vcenter_username }}'
    password: '{{ vsphere.vcenter_password }}'
    datacenter: '{{ vsphere.datacenter_name }}'
    cluster: '{{ vsphere.cluster_name }}'
    folder: '{{ vsphere.target_folder }}'
    name: '{{ virtual_machine_names[item.hostname] }}'
    template: '{{ vsphere.template_name }}'
    customvalues:
      - key: guestinfo.ignition.config.data.encoding
        value: base64
      - key: guestinfo.ignition.config.data
        value: '{{ vsphere_ignition.content }}'
      - key: disk.EnableUUID
        value: 'TRUE'
    disk:
      - size_gb: '{{ item.disk_gb }}'
        type: thin
        datastore: '{{ vsphere.datastore_name }}'
    hardware:
      memory_mb: '{{ item.memory_gb * 1024 }}'
      num_cpus: '{{ item.num_cpus }}'
      scsi: paravirtual
      hotadd_cpu: False
      hotremove_cpu: False
      hotadd_memory: False
    networks:
      - name: '{{ vsphere.network_name }}'
        mac: '{{ item.macaddr }}'
    wait_for_ip_address: False
    validate_certs: '{{ vsphere.validate_certs }}'
    state: present
  when:
    - item.ocs_disk_gb is undefined

- name: Create an ocs virtual machine from the template
  vmware_guest:
    hostname: '{{ vsphere.vcenter_hostname }}'
    username: '{{ vsphere.vcenter_username }}'
    password: '{{ vsphere.vcenter_password }}'
    datacenter: '{{ vsphere.datacenter_name }}'
    cluster: '{{ vsphere.cluster_name }}'
    folder: '{{ vsphere.target_folder }}'
    name: '{{ virtual_machine_names[item.hostname] }}'
    template: '{{ vsphere.template_name }}'
    customvalues:
      - key: guestinfo.ignition.config.data.encoding
        value: base64
      - key: guestinfo.ignition.config.data
        value: '{{ vsphere_ignition.content }}'
      - key: disk.EnableUUID
        value: 'TRUE'
    disk:
      - size_gb: '{{ item.disk_gb }}'
        type: thin
        datastore: '{{ vsphere.datastore_name }}'
      - size_gb: '{{ item.ocs_disk_gb }}'
        type: thin
        datastore: '{{ vsphere.datastore_name }}'
    hardware:
      memory_mb: '{{ item.memory_gb * 1024 }}'
      num_cpus: '{{ item.num_cpus }}'
      scsi: paravirtual
      hotadd_cpu: False
      hotremove_cpu: False
      hotadd_memory: False
    networks:
      - name: '{{ vsphere.network_name }}'
        mac: '{{ item.macaddr }}'
    wait_for_ip_address: False
    validate_certs: '{{ vsphere.validate_certs }}'
    state: present
  when:
    - item.ocs_disk_gb is defined

This does what I need, but there may be a better way.