HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible_collections/ovirt/ovirt/roles/vm_infra/tasks/main.yml
---
- name: Set sensitive vms
  ansible.builtin.set_fact:
    sensitive_vms: "{{ vms }}"
  no_log: true

- name: Check if VMs are correct
  ansible.builtin.set_fact:
    vms: "{{ vms | ovirt.ovirt.removesensitivevmdata }}"

- name: Main block
  block:
    - name: Login to oVirt
      ovirt_auth:
        url: "{{ engine_url | default(lookup('env','OVIRT_URL')) | default(omit) }}"
        hostname: "{{ engine_fqdn | default(lookup('env','OVIRT_HOSTNAME')) | default(omit) }}"
        username: "{{ engine_user | default(lookup('env','OVIRT_USERNAME')) | default(omit) }}"
        password: "{{ engine_password | default(lookup('env','OVIRT_PASSWORD')) | default(omit) }}"
        ca_file: "{{ engine_cafile | default(lookup('env','OVIRT_CAFILE')) | default(omit) }}"
        insecure: "{{ engine_insecure | default(true) }}"
      when: ovirt_auth is undefined or not ovirt_auth
      register: loggedin

    - name: Split list of VMs
      ansible.builtin.set_fact:
        create_vms: "{{ create_vms | default([]) + [item] }}"
      with_items: "{{ vms }}"
      when: (item.state is undefined and item.profile.state is defined and item.profile.state != 'absent')
        or (item.state is defined and item.state != 'absent') or (item.state is undefined and item.profile.state is undefined)
      # Uses item state first if not defined it will check profile state and use it.

    - name: Split list of sensitive VMs
      ansible.builtin.set_fact:
        create_sensitive_vms: "{{ create_sensitive_vms | default([]) + [item] }}"
      with_items: "{{ sensitive_vms }}"
      no_log: true
      when: (item.state is undefined and item.profile.state is defined and item.profile.state != 'absent')
        or (item.state is defined and item.state != 'absent') or (item.state is undefined and item.profile.state is undefined)
      # Uses item state first if not defined it will check profile state and use it.

    - name: Delete VM
      include_tasks: vm_state_absent.yml
      with_items: "{{ vms }}"
      loop_control:
        loop_var: current_vm
      when: (current_vm.state is defined and current_vm.state == 'absent')
        or (current_vm.profile.state is defined and current_vm.state is undefined and current_vm.profile.state == 'absent')

    - name: Include create VM
      include_tasks: vm_state_present.yml
      when: create_vms is defined

  always:
    - name: Unset facts
      ansible.builtin.set_fact:
        create_vms: []
        create_sensitive_vms: []

    - name: Logout from oVirt
      ovirt_auth:
        state: absent
        ovirt_auth: "{{ ovirt_auth }}"
      when: not loggedin.skipped | default(false)