cloudmaniac / ansible-deploy-vmware-vm Goto Github PK
View Code? Open in Web Editor NEWDeploy multiple VMware VM with Ansible vmware_guest module
Deploy multiple VMware VM with Ansible vmware_guest module
Is there a way for Ansible to create the VM folder for the VMs? It looks like there is but I can't get it to work.
root@hgp-PC:/home/hgp/workspace/python/ansible-deploy-vmware-vm# pip install PyVim
Requirement already satisfied: PyVim in /usr/local/lib/python3.5/dist-packages (2.0.24)
Requirement already satisfied: pyflakes in /usr/local/lib/python3.5/dist-packages (from PyVim) (2.1.1)
Requirement already satisfied: docopt in /usr/local/lib/python3.5/dist-packages (from PyVim) (0.6.2)
Requirement already satisfied: prompt-toolkit<2.1.0,>=2.0.0 in /usr/local/lib/python3.5/dist-packages (from PyVim) (2.0.9)
Requirement already satisfied: pygments in /usr/local/lib/python3.5/dist-packages (from PyVim) (2.4.2)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.5/dist-packages (from prompt-toolkit<2.1.0,>=2.0.0->PyVim) (1.12.0)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.5/dist-packages (from prompt-toolkit<2.1.0,>=2.0.0->PyVim) (0.1.7)
WARNING: You are using pip version 19.2.3, however version 19.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@hgp-PC:/home/hgp/workspace/python/ansible-deploy-vmware-vm# pip3 install PyVim
Requirement already satisfied: PyVim in /usr/local/lib/python3.5/dist-packages (2.0.24)
Requirement already satisfied: pyflakes in /usr/local/lib/python3.5/dist-packages (from PyVim) (2.1.1)
Requirement already satisfied: docopt in /usr/local/lib/python3.5/dist-packages (from PyVim) (0.6.2)
Requirement already satisfied: pygments in /usr/local/lib/python3.5/dist-packages (from PyVim) (2.4.2)
Requirement already satisfied: prompt-toolkit<2.1.0,>=2.0.0 in /usr/local/lib/python3.5/dist-packages (from PyVim) (2.0.9)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.5/dist-packages (from prompt-toolkit<2.1.0,>=2.0.0->PyVim) (1.12.0)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.5/dist-packages (from prompt-toolkit<2.1.0,>=2.0.0->PyVim) (0.1.7)
WARNING: You are using pip version 19.2.3, however version 19.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@hgp-PC:/home/hgp/workspace/python/ansible-deploy-vmware-vm# ansible-playbook -i vms-to-deploy deploy-kubernetes-prod.yml
[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user configurable on deprecation. This feature will
be removed in version 2.10. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
[WARNING]: While constructing a mapping from /home/hgp/workspace/python/ansible-deploy-vmware-vm/roles/deploy-vsphere-template/tasks/main.yml, line 5, column 5, found a duplicate dict key (state). Using
last defined value only.
PLAY [all] ****************************************************************************************************************************************************************************************************
TASK [deploy-vsphere-template : Deploy VM from template] ******************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pyVim
fatal: [prod-k8s-master01]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (PyVmomi) on hgp-PC's Python /usr/bin/python. Please read module documentation and install in the appropriate location"}
PLAY RECAP ****************************************************************************************************************************************************************************************************
prod-k8s-master01 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
root@hgp-PC:/home/hgp/workspace/python/ansible-deploy-vmware-vm#
It works well for Linux VMs, but when I try to deploy Windows VM then it got deployed and not powered on and IP, hostname is not configured
Hello Mates,
Inventory file is not picking these parameters "guest_hostname, guest_vcpu, guest_vram, guest_custom_ip"
when I run the playbook I got below error msg.. variable is not defined for guest_hostname..
[root@test ansible-deploy-vmware-vm]# ansible-playbook -i vms-to-deploy deploy-kubernetes-prod.yml -vvv
ansible-playbook 2.9.15
config file = /opt/myagent/avi/ansible/ansible-deploy-vmware-vm/ansible.cfg
configured module search path = [u'/opt/myagent/avi/ansible/ansible-deploy-vmware-vm/library']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible-playbook
python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /opt/myagent/avi/ansible/ansible-deploy-vmware-vm/ansible.cfg as config file
host_list declined parsing /opt/myagent/avi/ansible/ansible-deploy-vmware-vm/vms-to-deploy as it did not pass its verify_file() method
script declined parsing /opt/myagent/avi/ansible/ansible-deploy-vmware-vm/vms-to-deploy as it did not pass its verify_file() method
auto declined parsing /opt/myagent/avi/ansible/ansible-deploy-vmware-vm/vms-to-deploy as it did not pass its verify_file() method
Parsed /opt/myagent/avi/ansible/ansible-deploy-vmware-vm/vms-to-deploy inventory source with ini plugin
Read vars_file 'answerfile.yml'
PLAYBOOK: deploy-kubernetes-prod.yml ***************************************************************************************************************************************
1 plays in deploy-kubernetes-prod.yml
Read vars_file 'answerfile.yml'
Read vars_file 'answerfile.yml'
Read vars_file 'answerfile.yml'
PLAY [all] *****************************************************************************************************************************************************************
META: ran handlers
Read vars_file 'answerfile.yml'
Read vars_file 'answerfile.yml'
TASK [deploy-vsphere-template : Deploy VM from template] *******************************************************************************************************************
task path: /opt/myagent/avi/ansible/ansible-deploy-vmware-vm/roles/deploy-vsphere-template/tasks/main.yml:3
Read vars_file 'answerfile.yml'
Read vars_file 'answerfile.yml'
fatal: [guest_hostname=test-deploy1]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'guest_hostname' is undefined\n\nThe error appears to be in '/opt/myagent/avi/ansible/ansible-deploy-vmware-vm/roles/deploy-vsphere-template/tasks/main.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# Deplo/ a VM from a template using Ansible 'vmware_guest' module\n- name: Deploy VM from template\n ^ here\n"
}
fatal: [guest_hostname=test-deploy2]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'guest_hostname' is undefined\n\nThe error appears to be in '/opt/myagent/avi/ansible/ansible-deploy-vmware-vm/roles/deploy-vsphere-template/tasks/main.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# Deplo/ a VM from a template using Ansible 'vmware_guest' module\n- name: Deploy VM from template\n ^ here\n"
}
PLAY RECAP *****************************************************************************************************************************************************************
guest_hostname=test-deploy1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
guest_hostname=test-deploy2 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
my inventory file like this
[vms]
guest_hostname='test-deploy1' guest_vcpu='1' guest_vram='2096' guest_custom_ip='0.0.0.0'
guest_hostname='test-deploy2' guest_vcpu='2' guest_vram='4096' guest_custom_ip='0.0.0.0'
I ran playbook like these
ansible-playbook -i (path of inventory file) (playbook path) -vvv
[root@test ansible-deploy-vmware-vm]# tree
.
├── ansible.cfg
├── answerfile.yml
├── deploy-kubernetes-prod.yml
├── README.md
├── roles
│ └── deploy-vsphere-template
│ └── tasks
│ └── main.yml
└── vms-to-deploy
3 directories, 6 files
Kindly help this
what was I missed here ??..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.