Skip to content

Instantly share code, notes, and snippets.

View github-somerandomguy-xyz's full-sized avatar

github-somerandomguy-xyz

View GitHub Profile
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Last active April 16, 2020 09:48
/roles/common/tasks/debian.yml
---
- name: dpkg --configure -a
shell: dpkg --configure -a
tags:
- packages
- common
- dpkg-reconf
- name: install system utils, packages and stuff...
package:
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Created April 9, 2020 19:57
/roles/kvm/tasks/debian.yml
---
- name: install kvm packages on Debian
package:
name:
- bridge-utils
- genisoimage
- libguestfs-tools
- libnss-libvirt
- libosinfo-bin
- libvirt-clients
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Created April 9, 2020 20:06
install kvm packages on Debian
- name: install kvm packages on Debian
package:
name:
- bridge-utils
- genisoimage
- libguestfs-tools
- libnss-libvirt
- libosinfo-bin
- libvirt-clients
- libvirt-daemon-system
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Last active April 11, 2020 07:21
Enable service libvirt, and start if not started & adding existing user ansible to group libvirt/-qemu
- name: Enable service libvirt, and start if not started
service:
name: libvirtd
enabled: yes
state: started
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Last active April 11, 2020 07:26
Facts will be available as 'ansible_libvirt_pools'
# Facts will be available as 'ansible_libvirt_pools'
- name: gather facts on existing virsh pool
virt_pool:
command: facts
uri: "{{ libvirt_uri }}"
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Created April 9, 2020 20:11
add a storage pool for storing libvirt images if Pool doesn't already exists
- name: add a storage pool for storing libvirt images if Pool doesn't already exists
virt_pool:
command: define
# looks like setting name here is a redundant, the name is anyways taken from the template xml file, but should set it to make virt_pool module happy.
name: "{{ image_pool_name }}"
xml: '{{ lookup("template", "pool/dir.xml.j2") }}'
uri: "{{ libvirt_uri }}"
when: image_pool_name not in ansible_libvirt_pools
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Created April 9, 2020 20:12
create a image_pool_dir
- name: create a image_pool_dir
file:
path: "{{ image_pool_dir }}"
owner: "{{ ansible_user }}"
group: libvirt
recurse: yes
mode: '0755'
become: true
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Created April 9, 2020 20:13
build & start storage pool
- block:
- name: build the storage pool.
virt_pool:
command: build
name: "{{ image_pool_name }}"
uri: "{{ libvirt_uri }}"
- name: start the storage pool.
virt_pool:
command: create
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Created April 9, 2020 20:14
autostart and ensure that the pool is active
- name: autostart the storage pool
virt_pool:
autostart: yes
name: "{{ image_pool_name }}"
uri: "{{ libvirt_uri }}"
- name: ensure that the pool is active
virt_pool:
state: active
name: "{{ image_pool_name }}"
@github-somerandomguy-xyz
github-somerandomguy-xyz / debian.yml
Created April 11, 2020 07:24
/roles/tasks/kvm/debian.yml
- name: adding existing user ansible to group libvirt/-qemu
user:
name: "{{ansible_user}}"
groups: libvirt,libvirt-qemu
# if append is not set to yes, the user is removed from all other groups and gets added only to this one!
append: yes