Skip to content

Instantly share code, notes, and snippets.

View jrisch's full-sized avatar
🏠
Working from home

Juri Rischel Jensen jrisch

🏠
Working from home
View GitHub Profile
@jrisch
jrisch / keybase.md
Last active August 29, 2015 14:21
Keybase.md

Keybase proof

I hereby claim:

  • I am jrisch on github.
  • I am jrisch (https://keybase.io/jrisch) on keybase.
  • I have a public key whose fingerprint is 46DA 8CEE 5C0A 7029 4E2F CF04 B45A 50EC E8C5 A4FD

To claim this, I am signing this object:

require 'rubygems'
require 'resque'
require 'resque/job_with_status' # in rails you would probably do this in an initializer
Resque.redis = "resque-dev.v50.loc:6379"
# sleeps for _length_ seconds updating the status every second
class SleepJob < Resque::JobWithStatus
def perform
@jrisch
jrisch / vmtypes.csv
Last active November 30, 2017 09:45
Type Disk CPU weight RAM
VM-S 26843545600 64 1073741824
VM-M 53687091200 256 2147483648
VM-L 107374182400 1024 4294967296
VM-XL 214748364800 4096 8589934592
VM-XXL 536870912000 16384 17179869184
VM-XXXL 1073741824000 65536 34359738368
- name: Load VPS specs for chosen type
set_fact:
memory: "{{ lookup('csvfile', '{{ vps_type }} file=vmtypes.csv delimiter=, col=3') }}"
cpu_weight: "{{ lookup('csvfile', '{{ vps_type }} file=vmtypes.csv delimiter=, col=2') }}"
disksize: "{{ lookup('csvfile', '{{ vps_type }} file=vmtypes.csv delimiter=, col=1') }}"
- name: Get UUID of share SR
command: xe sr-list name-label="{{ sr_name }}" --minimal
register: sruuid
- name: Get the UUID of the VM template
command: xe template-list name-label="{{ vm_template }}" --minimal
register: templateuuid
- name: Get the UUID of the network
command: xe network-list name-label="{{ network_name }}" --minimal
---
- name: Deploy new Debian or Ubuntu VPS
hosts: xenservers
remote_user: root
vars_files:
- xenserver_vars.yml
---
hostname: vm01
domainname: example.com
gateway: 192.168.1.1
dnsservers: "8.8.8.8"
network_name: "Network 0"
sr_name: "Local storage"
vm_template: "Debian Stretch 9.0 (64-bit)"
vm_name: "vm01"
ipaddress: 192.168.1.10
- name: Deploy new VM
command: xe vm-install template={{ templateuuid.stdout }} new-name-label="{{ vm_name }} - {{ ipaddress }} - {{ vps_type }}" sr-uuid={{ sruuid.stdout }}
register: vmuuid
- name: Set vcpu priority
command: xe vm-param-set VCPUs-params:weight={{ cpu_weight }} uuid={{ vmuuid.stdout }}
- name: Set vcpu count max
command: xe vm-param-set VCPUs-max={{ vcpu_count }} uuid={{ vmuuid.stdout }}
when: vcpu_count >= "2"
- name: Set vcpu count at startup
command: xe vm-param-set VCPUs-at-startup={{ vcpu_count }} uuid={{ vmuuid.stdout }}
when: vcpu_count >= "2"
- name: Get the UUID of the disk
command: xe vm-disk-list vbd-params=device=xvda uuid={{ vmuuid.stdout }} --minimal
register: vdiuuid
- name: Set disk size
command: xe vdi-resize disk-size="{{ disksize }}" uuid={{ vdiuuid.stdout }}