aboutsummaryrefslogtreecommitdiffstats
path: root/roles/vmm/tasks/main.yml
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2021-12-06 20:10:25 +0000
committerRomain Gonçalves <me@rgoncalves.se>2021-12-07 20:24:51 +0000
commit333eff6a0aeefcbf573bbf5e725fc27b5b4cb9f6 (patch)
tree1f06800c26e23bb272af02d45fe4d73f4f2a091e /roles/vmm/tasks/main.yml
parent4e542a8e15596421a9120cf700f0d4d12dbf6688 (diff)
downloadrules-333eff6a0aeefcbf573bbf5e725fc27b5b4cb9f6.tar.gz
roles/vmm: Setup and create vms on openbsd
Diffstat (limited to 'roles/vmm/tasks/main.yml')
-rw-r--r--roles/vmm/tasks/main.yml69
1 files changed, 69 insertions, 0 deletions
diff --git a/roles/vmm/tasks/main.yml b/roles/vmm/tasks/main.yml
new file mode 100644
index 0000000..3c5a462
--- /dev/null
+++ b/roles/vmm/tasks/main.yml
@@ -0,0 +1,69 @@
+- name: create vmm directories
+ file:
+ path: "{{ item }}"
+ owner: 0
+ group: 0
+ mode: 0770
+ state: directory
+ loop:
+ - "{{ vmm_root_dir }}"
+ - "{{ vmm_iso_dir }}"
+ - "{{ vmm_disk_dir }}"
+
+- name: include facts generation
+ include_tasks: facts.yml
+
+- name: include iso management
+ include_tasks: iso.yml
+ tags: task_iso
+
+- name: include disk management
+ include_tasks: disk.yml
+ tags: task_disk
+
+- name: start ip forwarding
+ command: sysctl net.inet.ip{{ item }}.forwarding=1
+ loop: "{{ vmm_network_forwarded_ips }}"
+
+- name: enable ip forwarding
+ lineinfile:
+ path: /etc/sysctl.conf
+ regexp: "^net.inet.ip{{ item }}.forwarding="
+ line: "net.inet.ip{{ item }}.forwarding=1"
+ owner: 0
+ group: 0
+ mode: 0640
+ create: true
+ loop: "{{ vmm_network_forwarded_ips }}"
+
+- name: create network switch
+ lineinfile:
+ path: "/etc/hostname.{{ vmm_network_switch.interface }}"
+ regexp: &network_line "add {{ ansible_default_ipv4.interface }}"
+ line: *network_line
+ owner: 0
+ group: 0
+ mode: 0640
+ create: true
+
+- name: start network switch
+ command: "sh /etc/netstart {{ vmm_network_switch.interface }}"
+
+- name: generate vmm configuration
+ template:
+ src: vm.conf.j2
+ dest: "{{ vmm_configuration_file }}"
+ owner: 0
+ group: 0
+ mode: 0640
+ register: result
+
+- name: lint vmm configuration
+ command: "vmd -nf {{ vmm_configuration_file }}"
+ when: result.changed
+
+- name: restart and enable vmd
+ service:
+ name: vmd
+ state: restarted
+ enabled: true
remember that computers suck.