diff options
Diffstat (limited to 'deployment/playbooks/roles/create-vm-cns-prod-ose/tasks/main.yaml')
-rw-r--r-- | deployment/playbooks/roles/create-vm-cns-prod-ose/tasks/main.yaml | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/deployment/playbooks/roles/create-vm-cns-prod-ose/tasks/main.yaml b/deployment/playbooks/roles/create-vm-cns-prod-ose/tasks/main.yaml new file mode 100644 index 00000000..e01f1dd0 --- /dev/null +++ b/deployment/playbooks/roles/create-vm-cns-prod-ose/tasks/main.yaml @@ -0,0 +1,142 @@ +--- +- name: Define set of main disks (system and heketi) + set_fact: + disks_info: "{{ disks_info | default([ + {'size_gb': 60, 'type': 'thin', 'datastore': vcenter_datastore}, + {'size_gb': 40, 'type': 'thin', 'datastore': vcenter_datastore}, + {'size_gb': 40, 'type': 'thin', 'datastore': vcenter_datastore}]) + }} + {{ + [{'size_gb': (item.strip() | int), + 'type': container_storage_disk_type, + 'datastore': vcenter_datastore}] + }}" + with_items: "{{ container_storage_disks.split(',') }}" + +- name: Define set of additional disks which will be just attached to nodes + set_fact: + additional_disks_info: "{{ additional_disks_info | default([]) }} + {{ + [{'size_gb': (item.strip() | int), + 'type': container_storage_disk_type, + 'datastore': vcenter_datastore}] + }}" + with_items: "{{ additional_disks_to_storage_nodes.split(',') }}" + +- name: Create CNS production VMs on vCenter + vmware_guest: + hostname: "{{ vcenter_host }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: False + name: "{{ item.value.guestname }}" + cluster: "{{ vcenter_cluster}}" + datacenter: "{{ vcenter_datacenter }}" + resource_pool: "{{ vcenter_resource_pool }}" + template: "{{vcenter_template_name}}" + state: poweredon + wait_for_ip_address: true + folder: "/{{ vcenter_folder }}" + annotation: "{{ item.value.tag }}" + disk: "{{ disks_info }} + {{ additional_disks_info }}" + hardware: + memory_mb: 32768 + networks: "[{'name': '{{ vm_network }}', 'type': 'dhcp' }]" + customization: + domain: "{{dns_zone}}" + dns_suffix: "{{dns_zone}}" + hostname: "{{ item.value.guestname}}" + with_dict: "{{host_inventory}}" + when: "item.value.guesttype in ['cns', ]" + async: "{{ 6 * 600 }}" + poll: 0 + register: async_vms_creation + +- name: Check async status of VMs creation + async_status: + jid: "{{ async_result_item.ansible_job_id }}" + with_items: "{{ async_vms_creation.results }}" + loop_control: + loop_var: "async_result_item" + register: async_poll_results + until: async_poll_results.finished + retries: "{{ 6 * 100 }}" + +- name: Read info of newly created VMs + vmware_guest_tools_wait: + hostname: "{{ vcenter_host }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + folder: "/{{ vcenter_folder }}" + validate_certs: False + uuid: "{{ item.instance.hw_product_uuid }}" + with_items: "{{ async_poll_results.results }}" + register: facts + +- name: Map node names and their IP addresses + set_fact: + ip4addrs: "{{ ip4addrs | default({}) | combine( + {item.instance.hw_name: ( + item.instance.hw_eth0.ipaddresses | ipv4 | first)}, + recursive=True) }}" + hostnames_for_reboot: "{{ + (hostnames_for_reboot | default([])) + + [(item.instance.hw_eth0.ipaddresses | ipv4 | first)] }}" + with_items: "{{ facts.results }}" + +- name: Define glusterfs devices + set_fact: + glusterfs_devices: "{{ glusterfs_devices | default([]) }} + + {{ ['/dev/sd' + 'defghijklmnopqrstuvwxyz'[item.0]] }}" + with_indexed_items: "{{ disks_info[3::] }}" + +- name: Define glusterfs additional devices + set_fact: + glusterfs_additional_devices: "{{ + glusterfs_additional_devices | default([]) + }} + {{ + ['/dev/sd' + 'defghijklmnopqrstuvwxyz'[item.0 + (glusterfs_devices|length)]] + }}" + with_indexed_items: "{{ additional_disks_info }}" + +- name: Add CNS production VMs to inventory + add_host: + hostname: "{{ item.value.guestname }}" + ansible_fqdn: "{{ item.value.guestname }}.{{ dns_zone }}" + ansible_ssh_host: "{{ ip4addrs[item.value.guestname] }}" + groups: "{{ item.value.tag }}, new_nodes, storage, cns, glusterfs" + openshift_node_group_name: "node-config-storage" + # Following vars are for 'openshift_storage_glusterfs' role from + # 'openshift/openshift-ansible' repo + glusterfs_devices: "{{ glusterfs_devices }}" + glusterfs_hostname: "{{ item.value.guestname }}" + glusterfs_ip: "{{ ip4addrs[item.value.guestname] }}" + glusterfs_zone: "{{ ip4addrs[item.value.guestname].split('.')[-2::] | join('') | int }}" + with_dict: "{{ host_inventory }}" + when: "item.value.guesttype in ['cns', ]" + +# Following updates config file +# which is required for automated tests from 'glusterfs-containers-tests' repo + +- name: Combine data about gluster servers for 'glusterfs-containers-tests' config file + set_fact: + gluster_servers: "{{ + gluster_servers | default({}) | combine({ + ip4addrs[item.value.guestname]: { + 'manage': item.value.guestname, + 'storage': ip4addrs[item.value.guestname], + 'additional_devices': glusterfs_additional_devices, + } + }) + }}" + with_dict: "{{ host_inventory }}" + when: + - item.value.guesttype in ['cns', ] + - cns_automation_config_file_path | length > 0 + +- name: Update 'glusterfs-containers-tests' config file + yedit: + src: "{{ cns_automation_config_file_path }}" + state: present + edits: + - key: gluster_servers + value: "{{ gluster_servers }}" + when: gluster_servers is defined |