Skip to content

Instantly share code, notes, and snippets.

@theopscorner
Last active July 11, 2021 22:05
Show Gist options
  • Save theopscorner/779c8a030105ecbf2f89db0fb0cf87da to your computer and use it in GitHub Desktop.
Save theopscorner/779c8a030105ecbf2f89db0fb0cf87da to your computer and use it in GitHub Desktop.
---
- name: Deploy VM based on Requested Size
hosts: localhost
gather_facts: no
vars_files:
- vars/sizes-vars.yaml
vars_prompt:
- name: strname
prompt: "\nPlease enter the VM name"
private: no
- name: vm_size
prompt: |
Enter the size number to select the requested size.
1 - Small (2cpus 4g mem)
2 - Medium (2cpus 8g mem)
3 - Large (4cpus 12g mem)
private: no
tasks:
- set_fact:
size: "small"
when: vm_size == '1'
- set_fact:
size: "medium"
when: vm_size == '2'
- set_fact:
size: "large"
when: vm_size == '3'
- name: Debug the variable for CPU
debug:
msg: >-
Creating VM {{ strname|lower }}
with {{ vm_cpu_size[size] }} vCPUs
and {{ vm_mem_size[size] }}MB of RAM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment