Rename vm_network to network and vm_install to install
authornicoo <nicoo@realraum.at>
Sun, 17 Jun 2018 19:31:21 +0000 (21:31 +0200)
committernicoo <nicoo@realraum.at>
Sat, 24 Nov 2018 23:30:26 +0000 (00:30 +0100)
This includes renaming vm_install_host to vm_host.

ansible/host_vars/testvm/main.yml
ansible/remove_known_hosts.yml
ansible/roles/preseed/templates/preseed_debian-stretch.cfg.j2
ansible/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2
ansible/roles/vm/guest/tasks/main.yml
ansible/roles/vm/install/tasks/main.yml
ansible/roles/vm/install/templates/libvirt-domain.xml.j2
ansible/roles/vm/network/tasks/main.yml
ansible/roles/vm/network/templates/interfaces.j2
ansible/roles/vm/network/templates/resolv.conf.j2
ansible/vm-install.yml

index 80a95ad..0cb9cf7 100644 (file)
@@ -1,10 +1,10 @@
 ---
 localconfig_ssh_config_user: root
 
-vm_install_host: alfred
+vm_host: alfred
 
-vm_install:
-  host: "{{ vm_install_host }}"
+install:
+  host: "{{ vm_host }}"
   mem: 1024
   numcpu: 2
   disks:
@@ -15,19 +15,19 @@ vm_install:
         lv: "{{ inventory_hostname }}"
         size: 10g
   interfaces:
-  - bridge: "{{ hostvars[vm_install_host].vm_host.network.interface }}"
+  - bridge: "{{ hostvars[vm_host].vm_host.network.interface }}"
     name: mgmt0
   - bridge: "br-svc"
     name: svc0
   autostart: True
 
-vm_network:
-  nameservers: "{{ hostvars[vm_install_host].vm_host.network.nameservers }}"
+network:
+  nameservers: "{{ hostvars[vm_host].vm_host.network.nameservers }}"
   domain: realraum.at
   systemd_link:
-    interfaces: "{{ vm_install.interfaces }}"
+    interfaces: "{{ install.interfaces }}"
   primary:
     interface: mgmt0
-    ip: "{{ (hostvars[vm_install_host].vm_host.network.ip+'/'+hostvars[vm_install_host].vm_host.network.mask) | ipaddr(hostvars[vm_install_host].vm_host.network.indices[inventory_hostname]) | ipaddr('address') }}"
-    mask: "{{ hostvars[vm_install_host].vm_host.network.mask }}"
-    gateway: "{{ hostvars[vm_install_host].vm_host.network.gateway | default(hostvars[vm_install_host].vm_host.network.ip) }}"
+    ip: "{{ (hostvars[vm_host].vm_host.network.ip+'/'+hostvars[vm_host].vm_host.network.mask) | ipaddr(hostvars[vm_host].vm_host.network.indices[inventory_hostname]) | ipaddr('address') }}"
+    mask: "{{ hostvars[vm_host].vm_host.network.mask }}"
+    gateway: "{{ hostvars[vm_host].vm_host.network.gateway | default(hostvars[vm_host].vm_host.network.ip) }}"
index 7173334..abde3f5 100644 (file)
@@ -8,4 +8,4 @@
         - r3-{{ hostname }}
         - r3g-{{ hostname }}
         - r3e-{{ hostname }}
-        - "{{ hostvars[hostname].vm_network_cooked.primary.ip }}"
+        - "{{ hostvars[hostname].network_cooked.primary.ip }}"
index 37f428b..b9d0085 100644 (file)
@@ -10,14 +10,14 @@ d-i keyboard-configuration/xkb-keymap select us
 d-i netcfg/disable_dhcp boolean true
 d-i netcfg/choose_interface select enp1s1
 d-i netcfg/disable_autoconfig boolean false
-d-i netcfg/get_ipaddress string {{ hostvars[hostname].vm_network_cooked.primary.ip }}
-d-i netcfg/get_netmask string {{ hostvars[hostname].vm_network_cooked.primary.mask }}
-d-i netcfg/get_gateway string {{ hostvars[hostname].vm_network_cooked.primary.gateway }}
-d-i netcfg/get_nameservers string {{ hostvars[hostname].vm_network_cooked.nameservers | join(' ') }}
+d-i netcfg/get_ipaddress string {{ hostvars[hostname].network_cooked.primary.ip }}
+d-i netcfg/get_netmask string {{ hostvars[hostname].network_cooked.primary.mask }}
+d-i netcfg/get_gateway string {{ hostvars[hostname].network_cooked.primary.gateway }}
+d-i netcfg/get_nameservers string {{ hostvars[hostname].network_cooked.nameservers | join(' ') }}
 d-i netcfg/confirm_static boolean true
 
 d-i netcfg/get_hostname string {{ hostname }}
-d-i netcfg/get_domain string {{ hostvars[hostname].vm_network_cooked.domain }}
+d-i netcfg/get_domain string {{ hostvars[hostname].network_cooked.domain }}
 d-i netcfg/wireless_wep string
 
 
@@ -37,7 +37,7 @@ d-i time/zone string Europe/Vienna
 d-i clock-setup/ntp boolean false
 
 
-d-i partman-auto/disk string /dev/{{ hostvars[hostname].vm_install_cooked.disks.primary }}
+d-i partman-auto/disk string /dev/{{ hostvars[hostname].install_cooked.disks.primary }}
 d-i partman-auto/method string lvm
 d-i partman-lvm/device_remove_lvm boolean true
 d-i partman-md/device_remove_md boolean true
@@ -92,7 +92,7 @@ d-i pkgsel/include string openssh-server python
 d-i pkgsel/upgrade select safe-upgrade
 popularity-contest popularity-contest/participate boolean false
 
-d-i grub-installer/choose_bootdev string /dev/{{ hostvars[hostname].vm_install_cooked.disks.primary }}
+d-i grub-installer/choose_bootdev string /dev/{{ hostvars[hostname].install_cooked.disks.primary }}
 d-i grub-installer/only_debian boolean true
 d-i grub-installer/with_other_os boolean false
 
index e1e3cec..5f4c49e 100644 (file)
@@ -14,14 +14,14 @@ d-i keyboard-configuration/layoutcode string us
 
 #d-i netcfg/choose_interface select enp1s1
 #d-i netcfg/disable_autoconfig boolean false
-#d-i netcfg/get_ipaddress string {{ hostvars[hostname].vm_network_cooked.primary.ip }}
-#d-i netcfg/get_netmask string {{ hostvars[hostname].vm_network_cooked.primary.mask }}
-#d-i netcfg/get_gateway string {{ hostvars[hostname].vm_network_cooked.primary.gateway }}
-#d-i netcfg/get_nameservers string {{ hostvars[hostname].vm_network_cooked.nameservers | join(' ') }}
+#d-i netcfg/get_ipaddress string {{ hostvars[hostname].network_cooked.primary.ip }}
+#d-i netcfg/get_netmask string {{ hostvars[hostname].network_cooked.primary.mask }}
+#d-i netcfg/get_gateway string {{ hostvars[hostname].network_cooked.primary.gateway }}
+#d-i netcfg/get_nameservers string {{ hostvars[hostname].network_cooked.nameservers | join(' ') }}
 #d-i netcfg/confirm_static boolean true
 
 d-i netcfg/get_hostname string {{ hostname }}
-d-i netcfg/get_domain string {{ hostvars[hostname].vm_network_cooked.domain }}
+d-i netcfg/get_domain string {{ hostvars[hostname].network_cooked.domain }}
 d-i netcfg/wireless_wep string
 
 
@@ -42,7 +42,7 @@ d-i time/zone string Europe/Vienna
 d-i clock-setup/ntp boolean false
 
 
-d-i partman-auto/disk string /dev/{{ hostvars[hostname].vm_install_cooked.disks.primary }}
+d-i partman-auto/disk string /dev/{{ hostvars[hostname].install_cooked.disks.primary }}
 d-i partman-auto/method string lvm
 d-i partman-auto/purge_lvm_from_device boolean true
 d-i partman-auto-lvm/new_vg_name string {{ hostname }}
@@ -100,7 +100,7 @@ d-i pkgsel/upgrade select safe-upgrade
 popularity-contest popularity-contest/participate boolean false
 d-i pkgsel/update-policy select none
 
-d-i grub-installer/choose_bootdev string /dev/{{ hostvars[hostname].vm_install_cooked.disks.primary }}
+d-i grub-installer/choose_bootdev string /dev/{{ hostvars[hostname].install_cooked.disks.primary }}
 d-i grub-installer/only_debian boolean true
 d-i grub-installer/with_other_os boolean false
 
index e328026..4830d05 100644 (file)
@@ -34,4 +34,4 @@
     content: |
       [Service]
       ExecStart=
-      ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 --noclear --autologin root --login-pause --host {{ vm_install_host }} %I $TERM
+      ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 --noclear --autologin root --login-pause --host {{ vm_host }} %I $TERM
index 14886d9..31d5c8f 100644 (file)
@@ -1,6 +1,6 @@
 ---
 - name: create disks for vm
-  with_dict: "{{ hostvars[hostname].vm_install_cooked.disks.virtio | default({}) | combine(hostvars[hostname].vm_install_cooked.disks.scsi | default({})) }}"
+  with_dict: "{{ hostvars[hostname].install_cooked.disks.virtio | default({}) | combine(hostvars[hostname].install_cooked.disks.scsi | default({})) }}"
   lvol:
     vg: "{{ item.value.vg }}"
     lv: "{{ item.value.lv }}"
@@ -86,6 +86,6 @@
 - name: mark vm as autostarted
   virt:
     name: "{{ hostname }}"
-    autostart: "{{ hostvars[hostname].vm_install_cooked.autostart }}"
+    autostart: "{{ hostvars[hostname].install_cooked.autostart }}"
     command: info ## virt module needs either command or state
-  when: hostvars[hostname].vm_install_cooked.autostart is defined
+  when: hostvars[hostname].install_cooked.autostart is defined
index aa45abb..0f4858b 100644 (file)
@@ -1,12 +1,12 @@
 <domain type='kvm'>
   <name>{{ hostname }}</name>
-  <memory>{{ hostvars[hostname].vm_install_cooked.mem * 1024 }}</memory>
-  <currentMemory>{{ hostvars[hostname].vm_install_cooked.mem * 1024 }}</currentMemory>
-  <vcpu>{{ hostvars[hostname].vm_install_cooked.numcpu }}</vcpu>
+  <memory>{{ hostvars[hostname].install_cooked.mem * 1024 }}</memory>
+  <currentMemory>{{ hostvars[hostname].install_cooked.mem * 1024 }}</currentMemory>
+  <vcpu>{{ hostvars[hostname].install_cooked.numcpu }}</vcpu>
   <os>
     <type arch='x86_64' machine='pc-0.12'>hvm</type>
 {% if run_installer %}
-    <kernel>{{ debian_installer_path }}/{{ distro }}-{{ distcodename }}/{{ hostvars[hostname].vm_install_cooked.arch | default('amd64') }}/linux</kernel>
+    <kernel>{{ debian_installer_path }}/{{ distro }}-{{ distcodename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/linux</kernel>
     <initrd>{{ preseed_path }}/{{ hostname }}-{{ distro }}-{{ distcodename }}.initrd.gz</initrd>
     <cmdline>console=ttyS0,115200n8</cmdline>
 {% endif %}
@@ -35,8 +35,8 @@
       <backend model='random'>/dev/urandom</backend>
     </rng>
 
-{% if 'virtio' in hostvars[hostname].vm_install_cooked.disks %}
-{%   for device, lv in hostvars[hostname].vm_install_cooked.disks.virtio.items() %}
+{% if 'virtio' in hostvars[hostname].install_cooked.disks %}
+{%   for device, lv in hostvars[hostname].install_cooked.disks.virtio.items() %}
     <disk type='block' device='disk'>
       <driver name='qemu' type='raw' cache='none' discard='unmap'/>
       <source dev='/dev/mapper/{{ lv.vg | replace('-', '--') }}-{{ lv.lv | replace('-', '--') }}'/>
@@ -45,9 +45,9 @@
 {%   endfor %}
 {% endif %}
 
-{% if 'scsi' in hostvars[hostname].vm_install_cooked.disks %}
+{% if 'scsi' in hostvars[hostname].install_cooked.disks %}
     <controller type='scsi' index='0' model='virtio-scsi'/>
-{%   for device, lv in hostvars[hostname].vm_install_cooked.disks.scsi.items() %}
+{%   for device, lv in hostvars[hostname].install_cooked.disks.scsi.items() %}
     <disk type='block' device='disk'>
       <driver name='qemu' type='raw' cache='none' discard='unmap'/>
       <source dev='/dev/mapper/{{ lv.vg | replace('-', '--') }}-{{ lv.lv | replace('-', '--') }}'/>
@@ -56,8 +56,8 @@
 {%   endfor %}
 {% endif %}
 
-{% if hostvars[hostname].vm_install_cooked.interfaces %}
-{%   for if in hostvars[hostname].vm_install_cooked.interfaces %}
+{% if hostvars[hostname].install_cooked.interfaces %}
+{%   for if in hostvars[hostname].install_cooked.interfaces %}
     <interface type='bridge'>
       <source bridge='{{ if.bridge }}'/>
       <model type='virtio'/>
index 3d51fff..39f4ff4 100644 (file)
@@ -9,7 +9,7 @@
         state: absent
 
     - name: install systemd network link units
-      with_items: "{{ vm_network.systemd_link.interfaces }}"
+      with_items: "{{ network.systemd_link.interfaces }}"
       loop_control:
         index_var: interface_index
       template:
@@ -17,7 +17,7 @@
         dest: "/etc/systemd/network/{{ '%02d' | format(interface_index + 11) }}-{{ item.name }}.link"
       notify: rebuild initramfs
 
-  when: vm_network.systemd_link is defined
+  when: network.systemd_link is defined
 
 - name: install basic interface config
   template:
index 542e18d..829a3e7 100644 (file)
@@ -8,10 +8,10 @@ auto lo
 iface lo inet loopback
 
 # The primary network interface
-auto {{ vm_network.primary.interface }}
-iface {{ vm_network.primary.interface }} inet static
-  address {{ vm_network.primary.ip }}
-  netmask {{ vm_network.primary.mask }}
-  gateway {{ vm_network.primary.gateway }}
+auto {{ network.primary.interface }}
+iface {{ network.primary.interface }} inet static
+  address {{ network.primary.ip }}
+  netmask {{ network.primary.mask }}
+  gateway {{ network.primary.gateway }}
   pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
   pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
index 86d4201..a32ec18 100644 (file)
@@ -1,4 +1,4 @@
-{% for nsrv in vm_network.nameservers %}
+{% for nsrv in network.nameservers %}
 nameserver {{ nsrv }}
 {% endfor %}
-search {{ vm_network.domain }}
+search {{ network.domain }}
index 9e7f055..32166e7 100644 (file)
@@ -5,11 +5,11 @@
   tasks:
   - name: setup variables
     set_fact:
-      vm_network_cooked: "{{ vm_network }}"
-      vm_install_cooked: "{{ vm_install }}"
+      network_cooked: "{{ network }}"
+      install_cooked: "{{ install }}"
   - name: create temporary host group for vm host
     add_host:
-      name: "{{ vm_install.host }}"
+      name: "{{ vm_host }}"
       inventory_dir: "{{inventory_dir}}"
       group: _vmhost_
   # TODO: add some sanity checks