Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provision VM on a prefered ESXi Host with vmware_guest #359

Closed
xenlo opened this issue Aug 24, 2020 · 3 comments · Fixed by #400
Closed

Provision VM on a prefered ESXi Host with vmware_guest #359

xenlo opened this issue Aug 24, 2020 · 3 comments · Fixed by #400
Labels
affects_2.10 bug This issue/PR relates to a bug cloud module module needs_triage Needs a first human triage before being processed. plugins plugin (any type) python3

Comments

@xenlo
Copy link
Contributor

xenlo commented Aug 24, 2020

SUMMARY

According to the documentation, esxi_hostname attribute define on which ESXi host the virtual machine will run. But actually it doesn't behave like that.

As far as I use the vmware_guest against the vcenter I din't found a way to define a prefered ESXi host where my VM have to run on.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • plugins/modules/vmware_guest.py
ANSIBLE VERSION
ansible 2.9.12
  config file = /home/xenlo/Projects/463/etc/ansible.cfg
  configured module search path = ['/home/xenlo/Projects/463/library']
  ansible python module location = /home/xenlo/.virtualenvs/463/lib/python3.8/site-packages/ansible
  executable location = /home/xenlo/.virtualenvs/463/bin/ansible
  python version = 3.8.5 (default, Aug 12 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]
CONFIGURATION
ANSIBLE_SSH_ARGS(/home/xenlo/Projects/463/etc/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=60s -o ServerAliveInterval=60
CACHE_PLUGIN(/home/xenlo/Projects/463/etc/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/xenlo/Projects/463/etc/ansible.cfg) = $HOME/.ansible/facts/
CACHE_PLUGIN_TIMEOUT(/home/xenlo/Projects/463/etc/ansible.cfg) = 3600
DEFAULT_ACTION_PLUGIN_PATH(env: ANSIBLE_ACTION_PLUGINS) = ['/home/xenlo/.virtualenvs/463/lib/python3.8/site-packages/ara/plugins/action']
DEFAULT_CALLBACK_PLUGIN_PATH(env: ANSIBLE_CALLBACK_PLUGINS) = ['/home/xenlo/.virtualenvs/463/lib/python3.8/site-packages/ara/plugins/callback']
DEFAULT_CALLBACK_WHITELIST(/home/xenlo/Projects/463/etc/ansible.cfg) = ['profile_tasks']
DEFAULT_FILTER_PLUGIN_PATH(env: ANSIBLE_FILTER_PLUGINS) = ['/home/xenlo/Projects/463/plugins/filter']
DEFAULT_GATHERING(/home/xenlo/Projects/463/etc/ansible.cfg) = smart
DEFAULT_LOG_PATH(/home/xenlo/Projects/463/etc/ansible.cfg) = /home/xenlo/.ansible/log/ansible.log
DEFAULT_MODULE_PATH(env: ANSIBLE_LIBRARY) = ['/home/xenlo/Projects/463/library']
DEFAULT_ROLES_PATH(env: ANSIBLE_ROLES_PATH) = ['/home/xenlo/Projects/463/roles.galaxy', '/home/xenlo/Projects/463/roles']
DEFAULT_STDOUT_CALLBACK(/home/xenlo/Projects/463/etc/ansible.cfg) = yaml
GALAXY_ROLE_SKELETON(env: ANSIBLE_GALAXY_ROLE_SKELETON) = /home/xenlo/Projects/463/etc/skel/default
HOST_KEY_CHECKING(/home/xenlo/Projects/463/etc/ansible.cfg) = False
OS / ENVIRONMENT
  • target: vsphere 6.7.0
STEPS TO REPRODUCE

A simple loop task which create VMs with a prefered host as esxi_hostname attribut.

Here is an sample:

---
# Deploy some VMS

- name: Provisions VM hosts
  hosts: vcenter
  gather_facts: no

  vars:
    domain_name: "my_domain.net"
    vcenter_sso_pass: "{{ ansible_ssh_pass }}"
    datacenter_name: "my_little_DC"
    datastore_name: "my_vmfs_01"

    vm_list:
      - name: little-vm-1-01
        pref_node: node01
      - name: little-vm-1-02
        pref_node: node01
      - name: little-vm-1-03
        pref_node: node01
      - name: little-vm-2-02
        pref_node: node02
      - name: little-vm-2-01
        pref_node: node02
      - name: little-vm-3-01
        pref_node: node03
      - name: little-vm-3-02
        pref_node: node03
      - name: little-vm-3-03
        pref_node: node03
      - name: little-vm-3-04
        pref_node: node03
      - name: little-vm-3-05
        pref_node: node03

  tasks:
    - name: Provision VM
      vmware_guest:
        hostname: "{{ ansible_host }}"
        esxi_hostname: "{{ vm.pref_node }}.{{ domain_name }}"
        username: "Administrator@{{ domain_name }}"
        password: "{{ vcenter_sso_pass }}"
        validate_certs: no
        name: "{{ vm.name }}.{{ domain_name }}"
        state: poweredoff
        folder: "/"
        datacenter: "{{ datacenter_name }}"
        guest_id: "debian9_64Guest"
        hardware:
          num_cpus: 1
          memory_mb: 1024
        disk:
          - size_gb: 2
            type: thin
            datastore: "{{ datastore_name }}"
      loop: "{{ vm_list }}"
      loop_control:
        loop_var: vm
      delegate_to: localhost
EXPECTED RESULTS

The VMs are provisioned on there prefered node.

ACTUAL RESULTS

The VMs are created but on random ESXi hosts.

@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug module module needs_triage Needs a first human triage before being processed. python3 labels Aug 24, 2020
@xenlo
Copy link
Contributor Author

xenlo commented Aug 24, 2020

I had some investigations with @goneri already.

He created a PR #357 to test some changes (having the set of self.relospec.host independent if we use template or not).

And from my side I tried to force some RelocateVM_Task(…) after the CreateVM_Task(…) but without any success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 bug This issue/PR relates to a bug cloud module module needs_triage Needs a first human triage before being processed. plugins plugin (any type) python3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants