Code Monkey home page Code Monkey logo

ansible_role_vmware_provisioner's Introduction

Ansible vmware_provisioner role

This is an Ansible role to setup VMware virtual machines.

Role Variables

A list of all the default variables for this role is available in defaults/main.yml. The role setups the following facts:

  • vmware_provisioner_datacenters_info: gathered datacenters info
  • vmware_provisioner_clusters_info: gathered clusters info
  • vmware_provisioner_datastores_info: gathered datastores info
  • vmware_provisioner_vms_basic_facts: gathered virtual machines basic facts
  • vmware_provisioner_vms_detailed_facts: gathered virtual machines detailed facts
  • vmware_provisioner_inventory_vms: virtual machines configs found in the inventory

Example Playbook

This is an example playbook:

---

- hosts: all
  roles:
    - role: amtega.vmware_provisioner
      vmware_provisioner_hostname: vcenter.acme.com
      vmware_provisioner_username: username
      vmware_provisioner_password: password
      vmware_provisioner_validate_certs: no
      vmware_provisioner_testing_vms:
        - name: "my_vm"
          annotation: Ansible provisioned vm
          folder: /
          guest_id: centos7_64Guest
          hardware:
            memory_mb: 512
            num_cpus: 1
            num_cpu_cores_per_socket: 1
          datacenter: dc
          cluster: cluster
          disk:
            - size_gb: 30
              type: thin
              datastore: datastore            
          wait_for_ip_address: no          
          force: yes

Testing

Tests are based on molecule with docker containers.

To run test you must point the environment variable VMWARE_PROVISIONER_TEST_HOST to a host that can be managed with ansible and that has access to an existing vCenter.

Also, to run test you need provide some role variables. One way to provide this information is calling the testing playbook passing an additional inventory using the following environment variables:

  • ANSIBLE_INVENTORY: path to an inventory
  • ANSIBLE_VAULT_PASSWORD_FILE: path to the file containing the vault password required for the previous inventory

The minimum variables required in the testing inventory are (see defaults/main.file for details):

  • vmware_provisioner_hostname
  • vmware_provisioner_username
  • vmware_provisioner_password
  • vmware_provisioner_vm_datacenter
  • vmware_provisioner_vm_cluster
  • vmware_provisioner_vm_disk
cd amtega.vmware_provisioner

VMWARE_PROVISIONER_TEST_HOST=myhost ANSIBLE_INVENTORY=~/myinventory ANSIBLE_VAULT_PASSWORD_FILE=~/myvaultpassword molecule test --all

License

Copyright (C) 2022 AMTEGA - Xunta de Galicia

This role is free software: you can redistribute it and/or modify it under the terms of:

GNU General Public License version 3, or (at your option) any later version; or the European Union Public License, either Version 1.2 or – as soon they will be approved by the European Commission ­subsequent versions of the EUPL.

This role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details or European Union Public License for more details.

Author Information

ansible_role_vmware_provisioner's People

Contributors

daniel-sanchez-fabregas avatar juanvalino avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

ansible_role_vmware_provisioner's Issues

VMs not being provisioned

Hello! Thanks for your playbook, it looks amazing.

I'm having problems provisioning VMs with the Readme example. Nothing is done after the ** Sequential VMWare virtual machines attributes setup** task:

TASK [amtega.vmware_provisioner : include_tasks] *******************************************************************************************************************************************
skipping: [localhost] => changed=false
  skip_reason: Conditional result was False

TASK [amtega.vmware_provisioner : include_tasks] *******************************************************************************************************************************************
included: /home/[email protected]/.ansible/roles/amtega.vmware_provisioner/tasks/vms_attrs.yml for localhost

TASK [amtega.vmware_provisioner : include_tasks] *******************************************************************************************************************************************
included: /home/[email protected]/.ansible/roles/amtega.vmware_provisioner/tasks/vms_attrs_sequential.yml for localhost

TASK [amtega.vmware_provisioner : Sequential vmware virtual machines attributes setup] *****************************************************************************************************

PLAY RECAP *********************************************************************************************************************************************************************************
localhost                  : ok=21   changed=0    unreachable=0    failed=0    skipped=15   rescued=0    ignored=0

This is my playbook:

- hosts: all
  roles:
    - role: amtega.vmware_provisioner
      vmware_provisioner_deps_resolved: true
      vmware_provisioner_no_log: false
      vmware_provisioner_hostname: nope
      vmware_provisioner_username: 'nope'
      vmware_provisioner_password: 'nope'
      vmware_provisioner_validate_certs: no
      vmware_provisioner_vm_template: '/DC/vm/Templates/N4 3.8.20.1 TEMPLATE'
      vmware_provisioner_testing_vms:
        - name: "my_vm"
          annotation: Ansible provisioned vm
          folder: '/'
          hardware:
            memory_mb: 512
            num_cpus: 1
            num_cpu_cores_per_socket: 1
          datacenter: 'DC'
          cluster: 'DC-Cluster01'
          disk:
            - size_gb: 30
              type: thin
              datastore: 'DS-V01'
          wait_for_ip_address: True
          networks:
            - name: Vlan_Test
              ip: 192.168.10.11
              netmask: 255.255.255.0

Maybe my vms definition is wrong, would you take a look of it?

Thanks!

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.