"Fossies" - the Fresh Open Source Software Archive

Member "ansible-6.1.0/ansible_collections/ovirt/ovirt/roles/hosted_engine_setup/tasks/create_target_vm/01_create_target_hosted_engine_vm.yml" (9 Jun 2022, 6297 Bytes) of package /linux/misc/ansible-6.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ansible YAML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "01_create_target_hosted_engine_vm.yml": 5.9.0_vs_6.0.0.

    1 ---
    2 - name: Create target Hosted Engine VM
    3   block:
    4   - include_tasks: ../auth_sso.yml
    5   - name: Get local VM IP
    6     shell: virsh -r net-dhcp-leases default | grep -i {{ he_vm_mac_addr }} | awk '{ print $5 }' | cut -f1 -d'/'
    7     environment: "{{ he_cmd_lang }}"
    8     register: local_vm_ip
    9     changed_when: true
   10   - name: Set the name for add_host
   11     set_fact:
   12       he_fqdn_ansible_host: "{{ local_vm_ip.stdout_lines[0] }}"
   13   - import_tasks: ../add_engine_as_ansible_host.yml
   14   - name: Fetch host facts
   15     ovirt_host_info:
   16       pattern: name={{ he_host_name }} status=up
   17       auth: "{{ ovirt_auth }}"
   18     register: host_result
   19     until: host_result is succeeded and host_result.ovirt_hosts|length >= 1
   20     retries: 50
   21     delay: 10
   22   - name: Fetch Cluster ID
   23     set_fact: cluster_id="{{ host_result.ovirt_hosts[0].cluster.id }}"
   24   - name: Fetch Cluster facts
   25     ovirt_cluster_info:
   26       auth: "{{ ovirt_auth }}"
   27     register: cluster_facts
   28   - name: Fetch Datacenter facts
   29     ovirt_datacenter_info:
   30       auth: "{{ ovirt_auth }}"
   31     register: datacenter_facts
   32   - name: Fetch Cluster name
   33     set_fact: cluster_name={{ cluster_facts.ovirt_clusters|ovirt.ovirt.json_query("[?id=='" + cluster_id + "'].name")|first }}
   34   - name: Fetch Datacenter ID
   35     set_fact: >-
   36       datacenter_id={{ cluster_facts.ovirt_clusters|ovirt.ovirt.json_query("[?id=='" + cluster_id + "'].data_center.id")|first }}
   37   - name: Fetch Datacenter name
   38     set_fact: >-
   39       datacenter_name={{ datacenter_facts.ovirt_datacenters|ovirt.ovirt.json_query("[?id=='" + datacenter_id + "'].name")|first }}
   40   - name: Parse Cluster details
   41     set_fact:
   42       cluster_cpu: >-
   43         {{ cluster_facts.ovirt_clusters|selectattr('id', 'match', '^'+cluster_id+'$')|map(attribute='cpu')|list|first }}
   44       cluster_version: >-
   45         {{ cluster_facts.ovirt_clusters|selectattr('id', 'match', '^'+cluster_id+'$')|
   46         map(attribute='version')|list|first }}
   47   - name: Get server CPU list
   48     ovirt_system_option_info:
   49       auth: "{{ ovirt_auth }}"
   50       name: ServerCPUList
   51       version: "{{ cluster_version.major }}.{{ cluster_version.minor }}"
   52     register: server_cpu_list
   53   - name: Get cluster emulated machine list
   54     ovirt_system_option_info:
   55       name: ClusterEmulatedMachines
   56       auth: "{{ ovirt_auth }}"
   57       version: "{{ cluster_version.major }}.{{ cluster_version.minor }}"
   58     register: emulated_machine_list
   59   - name: Prepare for parsing server CPU list
   60     set_fact:
   61       server_cpu_dict: {}
   62   - name: Parse server CPU list
   63     set_fact:
   64       server_cpu_dict: "{{ server_cpu_dict | combine({item.split(':')[1]: item.split(':')[3]}) }}"
   65     with_items: >-
   66       {{ server_cpu_list['ovirt_system_option']['values'][0]['value'].split('; ')|list|difference(['']) }}
   67   - name: Convert CPU model name
   68     set_fact:
   69       cluster_cpu_model: "{{ server_cpu_dict[cluster_cpu.type] }}"
   70   - name: Parse emulated_machine
   71     set_fact:
   72       emulated_machine: >-
   73         {{ emulated_machine_list['ovirt_system_option']['values'][0]['value'].replace(
   74         '[','').replace(']','').split(', ')|first }}
   75   - name: Get storage domain details
   76     ovirt_storage_domain_info:
   77       pattern: name={{ he_storage_domain_name }} and datacenter={{ datacenter_name }}
   78       auth: "{{ ovirt_auth }}"
   79     register: storage_domain_details
   80   - name: Add HE disks
   81     ovirt_disk:
   82       name: "{{ item.name }}"
   83       size: "{{ item.size }}"
   84       format: "{{ item.format }}"
   85       sparse: "{{ item.sparse }}"
   86       description: "{{ item.description }}"
   87       content_type: "{{ item.content }}"
   88       interface: virtio
   89       storage_domain: "{{ he_storage_domain_name }}"
   90       wait: true
   91       timeout: 600
   92       auth: "{{ ovirt_auth }}"
   93     with_items:
   94       - {
   95         name: 'he_virtio_disk',
   96         description: 'Hosted-Engine disk',
   97         size: "{{ he_disk_size_GB }}GiB",
   98         format: 'raw',
   99         sparse: "{{ false if he_domain_type == 'fc' or he_domain_type == 'iscsi' else true }}",
  100         content: 'hosted_engine'
  101       }
  102       - {
  103         name: 'he_sanlock',
  104         description: 'Hosted-Engine sanlock disk',
  105         size: '1GiB',
  106         format: 'raw',
  107         sparse: false,
  108         content: 'hosted_engine_sanlock'
  109       }
  110       - {
  111         name: 'HostedEngineConfigurationImage',
  112         description: 'Hosted-Engine configuration disk',
  113         size: '1GiB',
  114         format: 'raw',
  115         sparse: false,
  116         content: 'hosted_engine_configuration'
  117       }
  118       - {
  119         name: 'he_metadata',
  120         description: 'Hosted-Engine metadata disk',
  121         size: '128MiB',
  122         format: 'raw',
  123         sparse: false,
  124         content: 'hosted_engine_metadata'
  125       }
  126     register: add_disks
  127   - name: Register disk details
  128     set_fact:
  129       he_virtio_disk_details: "{{ add_disks.results[0] }}"
  130       he_sanlock_disk_details: "{{ add_disks.results[1] }}"
  131       he_conf_disk_details: "{{ add_disks.results[2] }}"
  132       he_metadata_disk_details: "{{ add_disks.results[3] }}"
  133   - name: Set VNC graphic protocol
  134     set_fact:
  135       he_graphic_protocols: [vnc]
  136   - name: Check if FIPS is enabled
  137     command: sysctl -n crypto.fips_enabled
  138     register: he_fips_enabled
  139   - name: Add VM
  140     ovirt_vm:
  141       state: stopped
  142       cluster: "{{ cluster_name }}"
  143       name: "{{ he_vm_name }}"
  144       description: 'Hosted Engine Virtual Machine'
  145       memory: "{{ he_mem_size_MB }}Mib"
  146       cpu_cores: "{{ he_vcpus }}"
  147       cpu_sockets: 1
  148       graphical_console:
  149         headless_mode: false
  150         protocol: "{{ he_graphic_protocols }}"
  151       serial_console: false
  152       operating_system: rhel_8x64
  153       bios_type: q35_sea_bios
  154       type: server
  155       high_availability_priority: 1
  156       high_availability: false
  157       delete_protected: true
  158       # timezone: "{{ he_time_zone }}" # TODO: fix with the right parameter syntax
  159       disks:
  160         - id: "{{ he_virtio_disk_details.disk.id }}"
  161       nics:
  162         - name: vnet0
  163           profile_name: "{{ he_mgmt_network }}"
  164           interface: virtio
  165           mac_address: "{{ he_vm_mac_addr }}"
  166       auth: "{{ ovirt_auth }}"
  167     register: he_vm_details
  168   - name: Register external local VM uuid
  169     shell: virsh -r domuuid {{ he_vm_name }}Local | head -1
  170     environment: "{{ he_cmd_lang }}"
  171     register: external_local_vm_uuid
  172     changed_when: true