playbook_pve-deploy/pve-deploy.yml

55 lines
2.2 KiB
YAML

---
#####################################################################
#
# Playbook to deploy a new guest to a proxmox host
#
# pve-deploy.yml
#
# ansible-playbook -l <guest-host> -i <inventory> pve-deploy.yml
#
# This playbook will first use a proxmox ansible module to deploy either
# a container (community.general.proxmox) or a VM (community.general.proxmox_kvm).
#
# The VM deployment deploys by cloning a VM template. The template VM has to
# have been prepared properly. It first must have been configured with a static
# IP address. It also requires that the QEMU guest agent has been installed and
# enabled.
#
# After deployment the setup-host.yml playbook can be used to configure the guest
# as required.
#
#####################################################################
- hosts: all
gather_facts: false
user: root
vars:
guest_name: "{{ hostvars[inventory_hostname].inventory_hostname }}"
guest_ip_cidr: "{{ hostvars[inventory_hostname].ansible_host }}/{{ hostvars[inventory_hostname].ip_cidr }}"
guest_ip: "{{ hostvars[inventory_hostname].ansible_host }}"
guest_gw: "{{ hostvars[inventory_hostname].ip_gw }}"
cpu_num: "{{ hostvars[inventory_hostname].cpu }}"
mem_size: "{{ hostvars[inventory_hostname].mem * 1024 }}"
root_size: "{{ hostvars[inventory_hostname].root }}"
ctid: "{{ hostvars[inventory_hostname].vmid }}"
node: "{{ hostvars[inventory_hostname].pve_node }}"
api_user: "{{ hostvars[inventory_hostname].api_user }}"
api_password: "{{ hostvars[inventory_hostname].api_password }}"
api_host: "{{ hostvars[inventory_hostname].api_host }}"
ctswap: "{{ hostvars[inventory_hostname].swap }}"
ctpassword: "{{ hostvars[inventory_hostname].root_pw }}"
searchdomain: "{{ hostvars[inventory_hostname].domain }}"
ctnameserver: "{{ hostvars[inventory_hostname].ip_ns1 }}"
ctstorage: "{{ hostvars[inventory_hostname].storage }}"
ctbridge: "{{ hostvars[inventory_hostname].bridge }}"
ct_template: "{{ hostvars[inventory_hostname].ct_template }}"
vm_template: "{{ hostvars[inventory_hostname].vm_template }}"
vm_template_ip: "{{ hostvars[inventory_hostname].vm_template_ip }}"
host_type: "{{ hostvars[inventory_hostname].host_type }}"
roles:
- pve-deploy
# EOF