Coder Social home page Coder Social logo

ansible-module-vcloud-director's Introduction

ansible-module-vcloud-director

Overview

ansible-module-vcloud-director is a set of ansible modules to manage various operations on VMware vCloud Director.

Try it out

Prerequisites

  1. Python 3.6 or above
  2. pyvcloud

Build & Run

  1. pip install --user pyvcloud
  2. git clone https://github.com/vmware/ansible-module-vcloud-director
  3. cd ansible-module-vcloud-director
  4. ansible-playbook -i main.yml

Usage

This reposiroty packaged below two components to manage VCD,

  1. Ansible Modules
  2. Ansbile Playbooks

Ansible playbooks are the client which use modules as a gateway to interact with VCD. We have written various ansible playbooks to show how to interact with VCD. We are using ansible roles to define playbooks in modular fashion for each module. Please refer roles and main.yml to see usage.

Deployment

These modules may be deployed in two ways,

Local Deployment

We may define modules and module_utils settings in ansible.cfg to deploy ansible modules local to a directory. We have packaged ansible.cfg with this repository. You may refer this

Global Deployment

We may copy modules and module_utils to below paths to deploy ansible modules globally.

  • /usr/share/ansible/plugins/modules/
  • /usr/share/ansible/plugins/module_utils

Documentation

Refer docs to know more about available modules and their usage.

  1. vcd_catalog
  2. vcd_catalog_item
  3. vcd_disk
  4. vcd_external_network
  5. vcd_org
  6. vcd_org_vdc
  7. vcd_roles
  8. vcd_user
  9. vcd_vapp
  10. vcd_vapp_network
  11. vcd_vapp_vm
  12. vcd_vapp_vm_disk
  13. vcd_vapp_vm_nic
  14. vcd_vapp_vm_snapshot
  15. vcd_vdc_gateway
  16. vcd_vdc_network
  17. vcd_gateway_services

Releases & Major Branches

Following is the approx version matrix which are tested and supported through vCD ansible modules,

vCD Version API Versions
vCD 9.0 29.0
vCD 9.1 30.0
vCD 9.5 31.0
vCD 9.7 32.0
vCD 10.0 33.0
vCD 10.1 34.0

Note - Testing is still in progress for new releases of vCD and Pyvcloud.

Contributing

The ansible-module-vcloud-director project team welcomes contributions from the community. Before you start working with ansible-module-vcloud-director, please read our Developer Certificate of Origin. All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to CONTRIBUTING.md.

License

BSD-2 License or GPLv3

ansible-module-vcloud-director's People

Contributors

cdivitotawela avatar kaneda-fr avatar michaltaratuta avatar moonrail avatar mukultaneja avatar rdbwebster avatar robinelfrink avatar stoffus avatar triqster avatar vmwsrpbot avatar warthog9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-module-vcloud-director's Issues

vcd_vapp SyntaxError

Dear Author

When I am trying to use vcd_vapp module, I'm facing below error. I completed followed guide and read me to setup my environment. Would you please to check this:

The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1547550025.88-20448556516779/AnsiballZ_vcd_vapp.py", line 113, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1547550025.88-20448556516779/AnsiballZ_vcd_vapp.py", line 105, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1547550025.88-20448556516779/AnsiballZ_vcd_vapp.py", line 48, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/tmp/ansible_vcd_vapp_payload__5McFr/__main__.py", line 1
SyntaxError: Non-ASCII character '\xc2' in file /tmp/ansible_vcd_vapp_payload__5McFr/__main__.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1547550025.88-20448556516779/AnsiballZ_vcd_vapp.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1547550025.88-20448556516779/AnsiballZ_vcd_vapp.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1547550025.88-20448556516779/AnsiballZ_vcd_vapp.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_vcd_vapp_payload__5McFr/__main__.py\", line 1\nSyntaxError: Non-ASCII character '\\xc2' in file /tmp/ansible_vcd_vapp_payload__5McFr/__main__.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
    "rc": 1
}

run.yml:

---
- name: vCloudDirectorAnsible
  hosts: localhost
  environment:
    env_user: user-XXX
    env_password: password-XXX
    env_host: example.com
    env_org: example.org
    env_api_version: 30.0
    env_verify_ssl_certs: false

- name: create vapp
  hosts: localhost
  tasks:
    - vcd_vapp:
        vapp_name: "test_vapp_ansible"
        vdc: "example-vdc"
        state: "present"
      register: output
    - debug:
        msg: '{{ output }}'

Thanks!

Login failed to ORG

Attempting to login to vCD and list all VMs using this module but getting the below error:

line 49, in login\nansible.module_utils.vcd_errors.VCDLoginError: Login failed for user REDACTED to org REDACTED\n",


Playbook

  • name: Initialisation
    hosts: localhost
    gather_facts: false
    environment:
    env_user: REDACTED
    env_password: "REDACTED"
    env_host: REDACTED
    env_org: "REDACTED"
    env_api_version: 30.0
    env_verify_ssl_certs: false
    tasks:
    • name: Getting list of VMs from REDACTED vAPP
      vcd_vapp:
      vapp_name: "REDACTED"
      vdc: "REDACTED"
      operation: "list_vms"

Running vCD version 9.5. Installed this ansible module on the 19/06/2019 so should be up to date.

PyVCloud Version:
pyvcloud==20.1.0

Create Org doesn't work

Error: Login failed for user admin.okan to org None\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}

What is the correct usage for login?

  • name: vCloudDirectorAnsible
    hosts: localmachine
    connection: local
    become: yes
    environment:
    env_api_version: 30.0
    env_host: "https://vcloudhostname.com"
    env_org:
    env_password: mypass
    env_user: admin.okan
    env_verify_ssl_certs: false
    gather_facts: false
    tasks:

     - name: create org
       vcd_org:
         org_name: "ansible"
         full_name: "ansible"
         is_enabled : "true"
         state: "present"
       register: output
    
     - name: create org output
       debug:
         msg: '{{ output }}'
    

vcd_vapp_vm_disk showing change where there is none

- name: VMWARE_CLOUDDIRECTOR_CREATE_VM | Create additional data drive vapp vm disk
  vcd_vapp_vm_disk:
    vm_name: "{{ vmname }}"
    vapp: "{{ vappname }}"
    vdc: "{{ vdc }}"
    size: "{{ cloud.disk.datadrive.size|int|default(0) }}"
    state: "present"

The size is defined and not changing.

Running the playbook over an over and over again shows a change each time. Nothing noticeable changes on the vm.

Error create vm in api 5.6

I have a permission error when I create a vm in a vapp that is booted.

I can't do it until I make a complete stop of the vapp

Has anyone happened to you?

Only in version 5.6

Create VMs and assign a static IP

Thanks for supporting ansible users with these provisioning modules, VMware!

I'm wondering how one would go about creating multiple VMs within a vApp, each assigned their own static IP address using this project?

The only module that appears to support setting a static/manual IP address is vcd_vapp. However, I can't seem to use this module multiple times targeting the same vApp with different/separate VMs as the module tells me the "vApp is already present" when I run it after the first subsequent run where it creates the vApp and VM.

The vcd_vapp_vm module has ip_allocation_mode but no ip_address attribute.

Am I missing something or does this functionality not yet exist?

Unable to Run the playbooks

TASK [catalogs : create catalog] ****************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SyntaxError: Non-ASCII character '\xc2' in file /var/folders/nc/v4fymr5x12zfmm7mk49_rgjw0000gn/T/ansible_vcd_catalog_payload_XoqrUs/main.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/Users/sp/.ansible/tmp/ansible-tmp-1560948808.22-96272297509022/AnsiballZ_vcd_catalog.py", line 114, in \n _ansiballz_main()\n File "/Users/sp/.ansible/tmp/ansible-tmp-1560948808.22-96272297509022/AnsiballZ_vcd_catalog.py", line 106, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/Users/sp/.ansible/tmp/ansible-tmp-1560948808.22-96272297509022/AnsiballZ_vcd_catalog.py", line 49, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File "/var/folders/nc/v4fymr5x12zfmm7mk49_rgjw0000gn/T/ansible_vcd_catalog_payload_XoqrUs/main.py", line 1\nSyntaxError: Non-ASCII character '\xc2' in file /var/folders/nc/v4fymr5x12zfmm7mk49_rgjw0000gn/T/ansible_vcd_catalog_payload_XoqrUs/main.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Disk name in vcd_vapp_vm_disk can not be set

The vcd_vapp_vm_disk module does use the disk_name parameter in the code but does not allow it to be set by the user through ansible.

With having multiple disks on a machine it gets a bit confusing when they are all called harddrive 0 harddrive 1 harddrive 2 etc.

cannot connect to my Vcloud

Hello, I tried to run this command below, I think there is problem in my environment (Centos 7.6)
Best Regards,

$ansible-playbook run.yml -e ansible_python_interpreter="/opt/rh/rh-python36/root/usr/bin/python"

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [vCloudDirectorAnsible] *********************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************
ok: [localhost]

PLAY [create vapp] *******************************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************
ok: [localhost]

TASK [vcd_vapp] **********************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.vcd_errors.VCDLoginError: Login failed for user None to org None
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/tmp/ansible_vcd_vapp_payload_t71vxoma/ansible_vcd_vapp_payload.zip/ansible/module_utils/vcd.py", line 43, in login\n File "/root/.local/lib/python3.6/site-packages/pyvcloud/vcd/client.py", line 613, in init\n if len(self._uri) > 0:\nTypeError: object of type 'NoneType' has no len()\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1548078426.93-222646917081201/AnsiballZ_vcd_vapp.py", line 113, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1548078426.93-222646917081201/AnsiballZ_vcd_vapp.py", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1548078426.93-222646917081201/AnsiballZ_vcd_vapp.py", line 48, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File "/opt/rh/rh-python36/root/usr/lib64/python3.6/imp.py", line 235, in load_module\n return load_source(name, filename, file)\n File "/opt/rh/rh-python36/root/usr/lib64/python3.6/imp.py", line 170, in load_source\n module = _exec(spec, sys.modules[name])\n File "", line 618, in _exec\n File "", line 678, in exec_module\n File "", line 219, in _call_with_frames_removed\n File "/tmp/ansible_vcd_vapp_payload_t71vxoma/main.py", line 476, in \n File "/tmp/ansible_vcd_vapp_payload_t71vxoma/main.py", line 458, in main\n File "/tmp/ansible_vcd_vapp_payload_t71vxoma/main.py", line 216, in init\n File "/tmp/ansible_vcd_vapp_payload_t71vxoma/ansible_vcd_vapp_payload.zip/ansible/module_utils/vcd.py", line 31, in init\n File "/tmp/ansible_vcd_vapp_payload_t71vxoma/ansible_vcd_vapp_payload.zip/ansible/module_utils/vcd.py", line 49, in login\nansible.module_utils.vcd_errors.VCDLoginError: Login failed for user None to org None\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
to retry, use: --limit @/opt/ansible-module-vcloud-director/run.retry

PLAY RECAP ***************************************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=1

$python --version
Python 3.6.3

$ansible --version
ansible 2.7.6
config file = /opt/ansible-module-vcloud-director/ansible.cfg
configured module search path = [u'/opt/ansible-module-vcloud-director/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible

And I use this playbook:

more run.yml

  • name: vCloudDirectorAnsible
    hosts: localhost
    environment:
    env_user: jenkins_user
    env_password: jenkins-pass
    env_host: https://api-3.vcloud.com/api
    env_org: vdr_lab
    env_api_version: 30.0
    env_verify_ssl_certs: false

  • name: create vapp
    hosts: localhost
    tasks:

    • vcd_vapp:
      vapp_name: "test_vapp_ansible"
      vdc: "OVDC_1"
      state: "present"
      register: output
    • debug:
      msg: '{{ output }}'

Feature Request: snapshot managent with the vCloud provider

Environment

ansible-module-vcloud-director v1.0

Proposed Functionality

As a service provider I would like to have the ability to offer tenants with the ability to control VM and/or vApp snapshots with the Ansible vCloud provider.

Use Case

This feature would be benificial for tenants that want to be able to create snapshots automatically. For instance before executing an automated patch cycle on a selection of VMs / vApps.

vcd_vapp_vm networking

Hi there!

I have got an error in adding VM to exists VAPP. I have template without networks preset, so there is two ways:

  1. setup VM w/o subnets
  2. add subnet net1
  3. add subnet net2
    or
  4. setup VM w/ subnet net1
  5. add subnet net2

I'm having trouble with both of them:
in first case exception
AttributeError: no such child: {http://www.vmware.com/vcloud/v1.5}NetworkConnection
raised
in the second case exception
AttributeError: no such child: {http://www.vmware.com/vcloud/v1.5}PrimaryNetworkConnectionIndex
raised
I cannot add VM in any ways without presets in template.

settings:
https://gist.github.com/AlexDyukov/6123dc3a06d9264b077c5cb3323e7edf

if I'm doing it wrong, give a link to the docs, please.

Problems with gateway configuration

I am attempting to use the recently added and edge gateway module and I'm running into trouble with a few items. First, the module performs it's check for an existing gateway by using a try/except block but the get_gateway function it relies on returns None if a gateway isn't found. This results in the module always reporting that the gateway exists, whether it does not not.

I added an additional check to determine if there was a None response from the get_gateway function and encountered the error fatal: [localhost]: FAILED! => {"changed": false, "msg": "'VDC' object has no attribute 'create_gateway'"} after verifying that I am on pyvcloud 20.0.1 I dug into the pyvcloud code and found that there is no create_gateway() function within VDC . There are however 3 api version specific functions create_gateway_api_version_30(), create_gateway_api_version_31() and create_gateway_api_version_32().

Specifically modifying the module to use create_gateway_api_version_31() allowed the gateway to actually be created but get_gateway seems to return None regardless of whether a gateway with the specified name already exists, I'm guessing this is due to using a System user for the query rather than one that belongs to the tenant org but not sure how to work around that as tenant administrators cannot create edge gateways.

vcd_vapp_vm poweroff error when vm already powered off

- name: VMWARE_CLOUDDIRECTOR_STOP_VM | Power off vm in vapp
  vcd_vapp_vm:
    target_vm_name: "test_vm"
    target_vapp: "test_vapp"
    target_vdc: "demo"
    operation: "poweroff"

Running this once does poweroff the VM nicely.

Running it a second time produces an ansible fail !!

Expected result: A simple message that the state is already powered off.


TASK [VMWARE_CLOUDDIRECTOR_STOP_VM | Power off vm in vapp] ********************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Value of unknown type: <class 'pyvcloud.vcd.exceptions.BadRequestException'>, Status code: 400/BAD_REQUEST, [ 7c292d2d-0255-4fdd-869e-09dbc38bb7f7 ] The requested operation could not be executed since VM "test_vm" is not powered on. (request id: 7c292d2d-0255-4fdd-869e-09dbc38bb7f7)
fatal: [test_vm -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):

File "/tmp/ansible_vcd_vapp_vm_payload_kqrc3176/main.py", line 568, in main

File "/tmp/ansible_vcd_vapp_vm_payload_kqrc3176/main.py", line 251, in manage_operations

File "/tmp/ansible_vcd_vapp_vm_payload_kqrc3176/main.py", line 466, in power_off_vm

File "/home/foobar/.local/lib/python3.5/site-packages/pyvcloud/vcd/vm.py", line 298, in power_off

operation_name='power off')

File "/home/foobar/.local/lib/python3.5/site-packages/pyvcloud/vcd/vm.py", line 249, in _perform_power_operation

vm_resource, rel, media_type, contents)

File "/home/foobar/.local/lib/python3.5/site-packages/pyvcloud/vcd/client.py", line 1088, in post_linked_resource

media_type)

File "/home/foobar/.local/lib/python3.5/site-packages/pyvcloud/vcd/client.py", line 1072, in post_resource

objectify_results=objectify_results)

File "/home/foobar/.local/lib/python3.5/site-packages/pyvcloud/vcd/client.py", line 861, in _do_request

response), _objectify_response(response, objectify_results))

File "/home/foobar/.local/lib/python3.5/site-packages/pyvcloud/vcd/client.py", line 866, in _response_code_to_exception

raise BadRequestException(sc, request_id, objectify_response)

pyvcloud.vcd.exceptions.BadRequestException: Status code: 400/BAD_REQUEST, [ 7c292d2d-0255-4fdd-869e-09dbc38bb7f7 ] The requested operation could not be executed since VM "test_vm" is not powered on. (request id: 7c292d2d-0255-4fdd-869e-09dbc38bb7f7)

Roles partialy implemented

There are multiple issues in roles implementation.

  1. Hardcoded values, eg. Terraform_VDC in https://github.com/vmware/ansible-module-vcloud-director/blob/master/roles/vapp/tasks/main.yml
  2. Questionable flow. For example what is the point of creating and destroying vApp in the same role like in https://github.com/vmware/ansible-module-vcloud-director/blob/master/roles/vapp/tasks/main.yml ?

Generally speaking roles in the current implementation state shouldn't be merged into master. They are completely useless.

Update VAPP/VM metadata

It would be helpful if the vApp and VM modules offered the ability to set metadata, either at create time or after an object has been built. We are using metadata tags to provide group membership information to our inventory script and currently we need to add multiple tasks after the deployment to retrieve the VM's ID and then post the correct metadata to assign groups.

VDC Resource limits

Per the docs

cpu_allocated - (Optional) capacity that is committed to be available

I assume this means CPU Quota - does a 0 value mean unlimited or does it mean 0. If it means zero, how could I specify unlimited?

TY in advance
Ted

problem creating a vapp

running this playbook
`name: vCloudDirectorAnsible
hosts: localhost
environment:
env_user: ansible_test ## default user details for entire execution enviornment. Modules will use
env_password: Password ## these default values in case no module level user details are provided.
env_host: vcloud_Server_ip
env_org: Prueba-001
env_api_version: 29.0
env_verify_ssl_certs: false

tasks:

  • name: "create vapp"
    vcd_vapp:
    vapp_name: "test_vapp_ansible"
    template_name: "test_ansible_template"
    catalog_name: "Prueba"
    vdc: "Prueba-001"
    description: "test_description"
    network: "APP_10.233.1.0_27"
    fence_mode: "bridged"
    ip_allocation_mode: 'static'
    deploy: true
    power_on: true
    accept_all_eulas: true
    memory: 1024000
    cpu: 1000
    disk_size: 10240000
    password: "password"
    cust_script: "test_script"
    vm_name: "test_vm_ansible"
    hostname: "test_host"
    ip_address: "1.1.1.1"
    storage_profile: "Standard"
    network_adapter_type: "VMXNET3"
    state: "present"`

i get this error
`ansible-playbook test_e.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'

PLAY [vCloudDirectorAnsible] ***************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [create vapp] *************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/home/martin/.local/lib/python3.6/site-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n InsecureRequestWarning)\nTraceback (most recent call last):\n File "/tmp/ansible_9pbtjgbn/ansible_modlib.zip/ansible/module_utils/vcd.py", line 45, in login\n File "/home/martin/.local/lib/python3.6/site-packages/pyvcloud/vcd/client.py", line 724, in set_credentials\n raise VcdException('Login failed.')\npyvcloud.vcd.exceptions.VcdException: Login failed.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/tmp/ansible_9pbtjgbn/ansible_module_vcd_vapp.py", line 408, in \n main()\n File "/tmp/ansible_9pbtjgbn/ansible_module_vcd_vapp.py", line 390, in main\n module = Vapp(argument_spec=argument_spec, supports_check_mode=True)\n File "/tmp/ansible_9pbtjgbn/ansible_module_vcd_vapp.py", line 213, in init\n super(Vapp, self).init(**kwargs)\n File "/tmp/ansible_9pbtjgbn/ansible_modlib.zip/ansible/module_utils/vcd.py", line 31, in init\n File "/tmp/ansible_9pbtjgbn/ansible_modlib.zip/ansible/module_utils/vcd.py", line 49, in login\nansible.module_utils.vcd_errors.VCDLoginError: Login failed for user ansible_test to org Prueba-001\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
to retry, use: --limit @/home/martin/ansible-module-vcloud-director/test_e.retry

PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 `

NOTE - with the same authentication values i could create a catalog without problems.

Thanks in advance.
Martin

Reason for not merging upstream?

Is there a reason this module exists outside of the Ansible core?

The reasoning behind this is something I would like to know before using a module for multiple projects, might be useful information for the in the readme?

vcd_vapp_vm_nic is not idempotent

Hi,

Each time running this module runs, it will create a new NIC for the network, even if one already exists. The nic_id specified as parameter is not taken into account for the NIC creation.

An idempotent behavior would be to:

  • when nic_id is NOT specified and the network is already connected to the VM - do nothing
  • when a nic_id is specified and it already exist on that network - do nothing
  • when a nic_id is specified and it already exist with a different network - update the network for that nic
  • in all other case, create the network nic (using nic_id is specified)

Can you give me a feedback on the above and I can submit a module change.

ansible-module-vcloud-director/roles/catalogs/tasks/main.yml has hardcoded values

ansible-module-vcloud-director/roles/catalogs/tasks/main.yml

Copyright © 2018 VMware, Inc. All Rights Reserved.

SPDX-License-Identifier: BSD-2-Clause


#tasks file for roles/catalogs

#################################### Create ##########################################################################

  • name: create catalog
    vcd_catalog:
    user: 'acmeadmin'
    org: 'acme'
    password: 'VMware1!'
    host: '10.172.158.109'
    catalog_name: "{{ catalog_name }}"
    description: "{{ description }}"
    state: "present"
    register: output

  • name: create catalog output
    debug:
    msg: '{{ output }}'

Support for Edge configuration

Hi, is anyone working on a module to configure edges?
IMHO, nat and fw configuration would be the most important features.
thanks

VDC is already present

PLAY [vCloudDirectorAnsible] ***************************************************

TASK [create vdc] **************************************************************
[WARNING]: VDC ansible_pool is already present.

ok: [localmachine]

TASK [create vdc output] *******************************************************
ok: [localmachine] => {
"msg": {
"changed": false,
"failed": false,
"warnings": [
"VDC ansible_pool is already present."
]
}
}

PLAY RECAP *********************************************************************
localmachine : ok=2 changed=0 unreachable=0 failed=0

My task:

    - name: create vdc
      vcd_org_vdc:
           user: ansible_admin
           password: pass
           org: ansible
           vdc_name: "ansible_pool"
           provider_vdc_name: "Provider-VDC"
           description: "test vdc_ansible"
           allocation_model: "AllocationVApp"
           is_enabled: "true"
           storage_profiles:
           - name: "vCloud"
             enabled: true
             units: "MB"
             limit: 50000
             default: true
           cpu_units : "MHz"
           cpu_allocated : 2
           cpu_limit : 0
           mem_units : 'GB'
           mem_allocated : 4
           mem_limit : 0
           nic_quota : 0
           network_quota : 0
           vm_quota : 0
           resource_guaranteed_memory : 0
           resource_guaranteed_cpu : 0
           vcpu_in_mhz : 2000
           is_thin_provision : true
           uses_fast_provisioning : false
           over_commit_allowed : false
           state: "present"
      register: output

    - name: create vdc output
      debug:
        msg: '{{ output }}'

Expecting property name enclosed in double quotes -- vcd_org_vdc

I'm getting this error for the storage_profiles param:

The full traceback is:
  File "/tmp/ansible_vcd_org_vdc_payload_cpdcvfxd/__main__.py", line 369, in main
    response = module.manage_states()
  File "/tmp/ansible_vcd_org_vdc_payload_cpdcvfxd/__main__.py", line 246, in manage_states
    return self.create()
  File "/tmp/ansible_vcd_org_vdc_payload_cpdcvfxd/__main__.py", line 260, in create
    storage_profiles = json.loads(self.params.get('storage_profiles'))
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)

fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allocation_model": "AllocationPool",
            "api_version": "31.0",
            "cpu_allocated": 5,
            "cpu_limit": 0,
            "cpu_units": "GHz",
            "description": "DESCRIPTION",
            "host": "lab01vcd01.local",
            "is_enabled": true,
            "is_thin_provision": true,
            "mem_allocated": 4096,
            "mem_limit": 0,
            "mem_units": "MB",
            "network_pool_name": null,
            "network_quota": 0,
            "nic_quota": 0,
            "org": "Ansible",
            "org_name": "",
            "over_commit_allowed": true,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "provider_vdc_name": "CLOUDLAB PROVIDER VDC",
            "resource_guaranteed_cpu": 1.0,
            "resource_guaranteed_memory": 1.0,
            "state": "present",
            "storage_profiles": "[{'default': 'True', 'limit': '10', 'enabled': 'true', 'units': 'GB', 'name': 'GOLD TIER'}]",
            "user": "John_Ansible",
            "uses_fast_provisioning": true,
            "vcpu_in_mhz": null,
            "vdc_name": "Ansible Allocation Pool",
            "verify_ssl_certs": false,
            "vm_discovery_enabled": null,
            "vm_quota": 0
        }
    },
    "msg": "Expecting property name enclosed in double quotes: line 1 column 3 (char 2)"
}

My task:

- name: oVDC | Allocation Pool
  vcd_org_vdc:
    user: "{{vcd_user}}"
    password: "{{vcd_password}}"
    host: "{{host}}"
    org: "{{customer_org}}"
    api_version: "{{api_version}}"
    verify_ssl_certs: False
    vdc_name: "Ansible Allocation Pool"
    provider_vdc_name: "CLOUDLAB PROVIDER VDC"
    description: "DESCRIPTION"
    allocation_model: "AllocationPool"
    cpu_units: "GHz"
    cpu_allocated: 5
    cpu_limit: "0"
    mem_units: "MB"
    mem_allocated: 4096
    mem_limit: "0"
    nic_quota: "0"
    network_quota: "0"
    vm_quota: "0"
    storage_profiles:
      [{
      "name": "GOLD TIER",
      "enabled": "true",
      "units": "GB",
      "limit": "10",
      "default": "True"
    }]
    is_thin_provision: True
    uses_fast_provisioning: True
    is_enabled: "true"
    state: "present"
  1. I have tried different syntax versions of storage_profiles and can't get this working. What is the exact format for it, can you provide example rather then List of provider vDC storage profiles to add to this vDC. Each item is a dictionary.

  2. enabled and default are those strings or booleans?

error using vcd module

Im getting continuously this error:

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": " File "/var/folders/qy/lh_mfrzs7_nc1jbtcpl5gh600000gn/T/ansible_A03i4Y/ansible_module_vcd_vapp.py", line 1\nSyntaxError: Non-ASCII character '\xc2' in file /var/folders/qy/lh_mfrzs7_nc1jbtcpl5gh600000gn/T/ansible_A03i4Y/ansible_module_vcd_vapp.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}

any idea?

vcd_vapp_vm_disk - could not parse documentation

ansible-doc -t module vcd_vapp_vm_disk
ERROR! module vcd_vapp_vm_disk missing documentation (or could not parse documentation): Incorrect value for 'Required', a boolean is needed.: [False]

The error was: SyntaxError: Non-ASCII character '\xc2'

Python version output Python 3.6.7

Ansible version output

  config file = /home/ted/repos/ansible-module-vcloud-director/ansible.cfg
  configured module search path = ['/home/ted/repos/ansible-module-vcloud-director/modules']
  ansible python module location = /home/ted/python36/lib/python3.6/site-packages/ansible
  executable location = /home/ted/python36/bin/ansible
  python version = 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]

pip freeze output

ansible==2.7.7
asn1crypto==0.24.0
bcrypt==3.1.6
certifi==2018.11.29
cffi==1.12.1
chardet==3.0.4
Click==7.0
colorama==0.4.1
cryptography==2.5
entrypoints==0.3
humanfriendly==4.17
idna==2.8
jeepney==0.4
Jinja2==2.10
keyring==12.0.0
lxml==4.3.1
MarkupSafe==1.1.0
paramiko==2.4.2
pkg-resources==0.0.0
pyasn1==0.4.5
pycparser==2.19
pycryptodome==3.4.11
Pygments==2.3.1
PyNaCl==1.3.0
pyvcloud==20.0.3
PyYAML==3.13
requests==2.21.0
SecretStorage==3.1.1
six==1.12.0
tabulate==0.8.3
urllib3==1.24.1
vcd-cli==21.0.2

Play

- name: vCloudDirectorAnsible
  hosts: localhost
  connection: local
  environment:
    env_user: someuser
    env_password: somepass
    env_host: https://vcloud-lab0.lab.XXXXXXXXX.com
    env_org: someorg
    #    env_api_version: 30.0
    env_verify_ssl_certs: false

  tasks:
      - name: list catalog items
        vcd_catalog:
          catalog_name: "Some catalog"
          operation: list_items
          register: catalog_list

      - debug:
          msg: "{{ catalog_list.msg }}"
          changed_when: False

ansible-playbook output

(python36) ted@XXXXXXXX:~/repos/ansible-module-vcloud-director$ ansible-playbook list_catalogs.yml

PLAY [vCloudDirectorAnsible] **********************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [localhost]

TASK [list catalog items] *************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SyntaxError: Non-ASCII character '\xc2' in file /tmp/ansible_vcd_catalog_payload_2COd5X/__main__.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/ted/.ansible/tmp/ansible-tmp-1550722049.75-220904470425017/AnsiballZ_vcd_catalog.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/home/ted/.ansible/tmp/ansible-tmp-1550722049.75-220904470425017/AnsiballZ_vcd_catalog.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/ted/.ansible/tmp/ansible-tmp-1550722049.75-220904470425017/AnsiballZ_vcd_catalog.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_vcd_catalog_payload_2COd5X/__main__.py\", line 1\nSyntaxError: Non-ASCII character '\\xc2' in file /tmp/ansible_vcd_catalog_payload_2COd5X/__main__.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ****************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1

I believe I am using all the correct versions. Any ideas?

Thanks in advance
Ted

VDC Allocation Models

Per the documentaion there are three settings for VDC Allocation Models.

allocation_model - (Optional) allocation model used by this vdc. Accepted values are 'AllocationVApp', 'AllocationPool' or 'ReservationPool'

Two of these match VMWares chooseable allocation models

Allocation Pool == AllocationPool
Reservation Pool == ReservationPool

However

Pay-As-You-Go != AllocationVApp

My question is are these in fact the same thing. I can only assume yes, as VMWare has 3 allocation models, and the documents for this module have 3 allocation models. I just want to be sure that Pay-As-You-Go does in fact equal AllocationVapp.

TY in Advance
Ted Fiedler

Error creating isolated network with vcd_vdc_network.py

module vcd.py of pyvcloud 20.1.0 requires cidr notation also for isolated netwoks

def create_isolated_vdc_network(self,
    network_name,
    network_cidr,
    description=None,
    primary_dns_ip=None,
    secondary_dns_ip=None,
    dns_suffix=None,
    ip_range_start=None,
    ip_range_end=None,
    is_dhcp_enabled=None,
    default_lease_time=None,
    max_lease_time=None,
    dhcp_ip_range_start=None,
    dhcp_ip_range_end=None,
    is_shared=None):

so following patch in vcd_vdc_network.py is needed

@@ -320,8 +320,7 @@ class VdcNet(VcdAnsibleModule):
         except EntityNotFoundException:
             create = self.vdc.create_isolated_vdc_network(
                 self.network_name,
-                self.gateway_ip,
-                self.netmask,
+                self.network_cidr,
                 description=self.description,
                 primary_dns_ip=self.primary_dns_ip,
                 secondary_dns_ip=self.secondary_dns_ip,

vcd_vapp off of template without network not possible

I am not sure where to start describing this or what logs to send.

It is reproducible but pretty time consuming to do so.

I created a vm by hand in vCloud. Then sysprept it. Powered it down. Removed in vCloud Director the Network and then templated it.

It is impossible to use this template with the vcd_vapp module, I have tried it all and asked the provider to check the logs. He can not make a rime of it either.

My temporary solution is to leave the network conntected when templating (pretty stupid but works).

THIS the module can handle. It will generate everything, add the right IP address and all.

Hower it now leaves the IP reserverd in vCloud for the Template and every machine templating off of the template needs to be in that network.

Ugly workaround.

Anyone else have a construct like that, or is this really only something in my universe?

An exception occurred during task execution

Hello,

I could not run any task with this module.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'pyvcloud'

ansible 2.7.10
config file = None
configured module search path = ['/home/okan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.2.0]

vcd_vapp_vm_nic cannot change NetworkAdapterType

I have a load of VMs that have a strange default adapter type assigned to them which is now causing problems in my environment.

Using VMXNET3 solves this.

However I can not find a way to change this on the machines.

Feature Request: create organization admin user when create org

Organization admin account cannot create when creating organization.

If you want to create an organization admin account for org, you can not create. Because you can not login to an organization with local admin user. So, we need to create organization admin user when creating organization.

Is it possible to add this feature?

No direkt vcd vm modules available!

With one of the later updates VM Ware has finally made it possible to create VMs without having to use the vapp wrapper.

Have been waiting for this for quite a while now.

Now there are no ansible modules for this at all. Everything is made around the strange vapp.

Is this in planing or being worked on?

No good releasing something great and new when you can not use it.

Supported VCD version with these Ansible Modules

Hi Team,

Could anyone confirm which VCD version is supported with these modules. As I started with VCD version 9.5 and now my playbook is not working for vcd version 8.2.

Is there anything I am missing on. Or do these modules support on VCD version 8.2 ?

Thank You.

vcd_vapp_vm_nic cannot update VM nic from DHCP to MANUAL

Allocation mode cannot be changed from DHCP to MANUAL using vcd_vapp_vm_nic "update" operation.
The issue is present with VM powered off, when the IpAddress field is missing so cannot be modified.
This is the output of "read" operation command with a VM powered off with a DHCP nic

    "msg": {
        "0": {
            "IpAddressAllocationMode": "DHCP", 
            "IsConnected": "True", 
            "MACAddress": "00:50:56:01:3c:b0", 
            "NetworkAdapterType": "VMXNET3", 
            "NetworkConnectionIndex": "0"
        }
    }

This is the exception I got:

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "module_stderr": "Shared connection to localhost closed.\r\n", 
    "module_stdout": "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\r\n  InsecureRequestWarning)\r\n/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\r\n  InsecureRequestWarning)\r\n/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\r\n  InsecureRequestWarning)\r\n/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\r\n  InsecureRequestWarning)\r\n/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\r\n  InsecureRequestWarning)\r\n/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\r\n  InsecureRequestWarning)\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/__main__.py\", line 340, in main\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/__main__.py\", line 163, in manage_operations\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/__main__.py\", line 276, in update_nic\r\n  File \"/usr/local/lib/python3.6/dist-packages/pyvcloud/vcd/client.py\", line 1041, in put_resource\r\n    objectify_results=objectify_results)\r\n  File \"/usr/local/lib/python3.6/dist-packages/pyvcloud/vcd/client.py\", line 861, in _do_request\r\n    response), _objectify_response(response, objectify_results))\r\n  File \"/usr/local/lib/python3.6/dist-packages/pyvcloud/vcd/client.py\", line 866, in _response_code_to_exception\r\n    raise BadRequestException(sc, request_id, objectify_response)\r\npyvcloud.vcd.exceptions.BadRequestException: Status code: 400/BAD_REQUEST, Bad request  - Unexpected JAXB Exception  - cvc-complex-type.2.4.d: Invalid content was found starting with element 'IpAddress'. No child element is expected at this point. (request id: c66719c0-57e5-4f11-a264-e658b82531ae)\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/carmine/.ansible/tmp/ansible-tmp-1546945229.69-239004321790078/AnsiballZ_vcd_vapp_vm_nic.py\", line 113, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/carmine/.ansible/tmp/ansible-tmp-1546945229.69-239004321790078/AnsiballZ_vcd_vapp_vm_nic.py\", line 105, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/carmine/.ansible/tmp/ansible-tmp-1546945229.69-239004321790078/AnsiballZ_vcd_vapp_vm_nic.py\", line 48, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/usr/lib/python3.6/imp.py\", line 235, in load_module\r\n    return load_source(name, filename, file)\r\n  File \"/usr/lib/python3.6/imp.py\", line 170, in load_source\r\n    module = _exec(spec, sys.modules[name])\r\n  File \"<frozen importlib._bootstrap>\", line 618, in _exec\r\n  File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module\r\n  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/__main__.py\", line 352, in <module>\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/__main__.py\", line 346, in main\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/ansible_vcd_vapp_vm_nic_payload.zip/ansible/module_utils/basic.py\", line 2369, in fail_json\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/ansible_vcd_vapp_vm_nic_payload.zip/ansible/module_utils/basic.py\", line 2341, in _return_formatted\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/ansible_vcd_vapp_vm_nic_payload.zip/ansible/module_utils/basic.py\", line 522, in remove_values\r\n  File \"/tmp/ansible_vcd_vapp_vm_nic_payload_503i2a1n/ansible_vcd_vapp_vm_nic_payload.zip/ansible/module_utils/basic.py\", line 505, in _remove_values_conditions\r\nTypeError: Value of unknown type: <class 'pyvcloud.vcd.exceptions.BadRequestException'>, Status code: 400/BAD_REQUEST, Bad request  - Unexpected JAXB Exception  - cvc-complex-type.2.4.d: Invalid content was found starting with element 'IpAddress'. No child element is expected at this point. (request id: c66719c0-57e5-4f11-a264-e658b82531ae)\r\n", 
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
    "rc": 1
}

unable to delete nic per docs

I was getting errors when trying to delete a nic per the docs

but when I started poking around I saw you could use a list nic_ids instead of a string nic_id and everything worked as expected.

tasks:
    - name: Remove nic 0
      vcd_vapp_vm_nic:
          vm_name: "ansible-01"
          vapp: "ansible-01"
          vdc: "myVDC"
          nic_ids: [ 0 ]
          state: "absent"

Ted

Adding more than 1 network to a vapp?

So I have this snippet

- name: add ( update ) vapp with second network
      vcd_vapp:
          vapp_name: "Demo-vapp1"
          vdc: "tststartrek-01"
          network: "tststartrek-VLANabcx"
          network_adapter_type: "VMXNET"
          state: "update"
      when: init is defined
      register: add_network1_vapp
      tags: ['nic1', 'nic' ]

When I run it, I get the following error

fatal: [localhost]: FAILED! => {"changed": false, "msg": "value of state must be one of: present, absent, got: update"}

So I know state: "update" does not work, but Ive tried state: "present" and it just tells me the vapp already exists.

Does this functionality exist and Im missing it? Or has anyone found a workable workaround?

Thanks in advance
Ted

Support for Container services extensions

I would like to see the creation of a module that can perform basic CSE tasks like cluster creation, maintenance, and scaling. I'm happy to take on creating the actual module(s) but want to make sure I'm not duplicating work someone else is already pursuing. Any hints on getting started with development on this project are also greatly appreciated.

organization vdc are created only with SYSTEM org admin

Organization vdc are created only with SYSTEM org admin.
Looks like there is no way to use any other user.
The module should allow user to specify the organization admin not only the SYSTEM admin to create an organization vdc: this is critical to be implemented.
Thanks,
dom

raise OperationNotSupportedException from e

Hi I am getting the following error:




The full traceback is: |  
  | 124 | Traceback (most recent call last): |  
  | 125 | File "/tmp/ansible_ZXDt8z/ansible_module_vcd_org.py", line 103, in <module> |  
  | 126 | from pyvcloud.vcd.org import Org |  
  | 127 | File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyvcloud/vcd/org.py", line 27, in <module> |  
  | 128 | from pyvcloud.vcd.acl import Acl |  
  | 129 | File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyvcloud/vcd/acl.py", line 17, in <module> |  
  | 130 | from pyvcloud.vcd.client import E |  
  | 131 | File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/pyvcloud/vcd/client.py", line 998 |  
  | 132 | raise OperationNotSupportedException from e |  
  | 133 | ^ |  
  | 134 | SyntaxError: invalid syntax |  
  | 135 |   |  
  | 136 | fatal: [127.0.0.1]: FAILED! => { |  
  | 137 | "changed": false, |  
  | 138 | "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_ZXDt8z/ansible_module_v… |  
  | ...


I am using the following yml file:

---
- name: test
  hosts: 127.0.0.1
  connection: local

  tasks:
  - name: "create org"
    vcd_org:
      org_name: "test_org"
      full_name: "test_org"
      is_enabled : true
      state: present
      user: "{{ vcloud_user }}"
      password: "{{ vcloud_password }}"
      host: "myvcloudurl.org"

Am I missing something? Or is this an issue with pyvcloud?

vcd_vapp_vm_nic cannot create vm nic with static ip address (manual or pool)

DHCP is hard coded

        nic = E.NetworkConnection(
            E.NetworkConnectionIndex(max_id+1 if nic_id is None else nic_id),
            E.IsConnected(True),
            E.IpAddressAllocationMode('DHCP'),
            network=network)
        nics.NetworkConnection.addnext(nic)

I was able to change the behaviour to let POOL configuration (adding a parameter) but I wasn't able to use MANUAL mode (I tried with commented lines you can see but it didn't work)

diff --git a/modules/vcd_vapp_vm_nic.py b/modules/vcd_vapp_vm_nic.py
index c405750..dac2ef5 100644
--- a/modules/vcd_vapp_vm_nic.py
+++ b/modules/vcd_vapp_vm_nic.py
@@ -50,6 +50,10 @@ options:
         description:
             - VApp network name
         required: false
+    ip_allocation_mode:
+        description:
+            - IP allocation mode (DHCP or POOL, MANUAL not working)
+        required: false
     vm_name:
         description:
             - VM name
@@ -90,6 +94,7 @@ EXAMPLES = '''
     vapp = "vapp1"
     vdc = "vdc1"
     nic_id = "2000"
+    ip_allocation_mode = "POOL"
     state = "present"
 '''
 
@@ -123,6 +128,8 @@ def vapp_vm_nic_argument_spec():
         vdc=dict(type='str', required=True),
         nic_id=dict(type='int', required=False),
         network=dict(type='str', required=False),
+        ip_allocation_mode=dict(type='str', required=False),
+        #ip_address=dict(type='str', required=False),
         state=dict(choices=VAPP_VM_NIC_STATES, required=False),
         operation=dict(choices=VAPP_VM_NIC_OPERATIONS, required=False),
     )
@@ -166,6 +173,8 @@ class VappVMNIC(VcdAnsibleModule):
         vm = self.get_vm()
         nic_id = self.params.get('nic_id')
         network = self.params.get('network')
+        ip_allocation_mode = self.params.get('ip_allocation_mode')
+        #ip_address = self.params.get('ip_address')
         response = dict()
         response['changed'] = False
         max_id = -1;
@@ -181,7 +190,8 @@ class VappVMNIC(VcdAnsibleModule):
         nic = E.NetworkConnection(
             E.NetworkConnectionIndex(max_id+1 if nic_id is None else nic_id),
             E.IsConnected(True),
-            E.IpAddressAllocationMode('DHCP'),
+            E.IpAddressAllocationMode(ip_allocation_mode),
+            #E.IpAddress(ip_address),
             network=network)
         nics.NetworkConnection.addnext(nic)

the ansible file looks like this

  tasks:
  - name: create new vm nic
    vcd_vapp_vm_nic:
        vm_name: "{{ my_vm }}"
        vapp: "{{ my_vapp }}"
        vdc: "{{ my_vdc }}"
        network: "{{ my_network }}"
        ip_allocation_mode: "{{ my_ip_mode }}"
        state: "present"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.