From 680fe2ba0548205ddd1bc790c21632c8939f35b7 Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 17 Jun 2018 21:31:21 +0200 Subject: [PATCH] Rename vm_network to network and vm_install to install This includes renaming vm_install_host to vm_host. --- ansible/host_vars/testvm/main.yml | 20 ++++++++++---------- ansible/remove_known_hosts.yml | 2 +- .../templates/preseed_debian-stretch.cfg.j2 | 14 +++++++------- .../preseed/templates/preseed_ubuntu-xenial.cfg.j2 | 14 +++++++------- ansible/roles/vm/guest/tasks/main.yml | 2 +- ansible/roles/vm/install/tasks/main.yml | 6 +++--- .../vm/install/templates/libvirt-domain.xml.j2 | 20 ++++++++++---------- ansible/roles/vm/network/tasks/main.yml | 4 ++-- ansible/roles/vm/network/templates/interfaces.j2 | 10 +++++----- ansible/roles/vm/network/templates/resolv.conf.j2 | 4 ++-- ansible/vm-install.yml | 6 +++--- 11 files changed, 51 insertions(+), 51 deletions(-) diff --git a/ansible/host_vars/testvm/main.yml b/ansible/host_vars/testvm/main.yml index 80a95ad..0cb9cf7 100644 --- a/ansible/host_vars/testvm/main.yml +++ b/ansible/host_vars/testvm/main.yml @@ -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) }}" diff --git a/ansible/remove_known_hosts.yml b/ansible/remove_known_hosts.yml index 7173334..abde3f5 100644 --- a/ansible/remove_known_hosts.yml +++ b/ansible/remove_known_hosts.yml @@ -8,4 +8,4 @@ - r3-{{ hostname }} - r3g-{{ hostname }} - r3e-{{ hostname }} - - "{{ hostvars[hostname].vm_network_cooked.primary.ip }}" + - "{{ hostvars[hostname].network_cooked.primary.ip }}" diff --git a/ansible/roles/preseed/templates/preseed_debian-stretch.cfg.j2 b/ansible/roles/preseed/templates/preseed_debian-stretch.cfg.j2 index 37f428b..b9d0085 100644 --- a/ansible/roles/preseed/templates/preseed_debian-stretch.cfg.j2 +++ b/ansible/roles/preseed/templates/preseed_debian-stretch.cfg.j2 @@ -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 diff --git a/ansible/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2 b/ansible/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2 index e1e3cec..5f4c49e 100644 --- a/ansible/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2 +++ b/ansible/roles/preseed/templates/preseed_ubuntu-xenial.cfg.j2 @@ -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 diff --git a/ansible/roles/vm/guest/tasks/main.yml b/ansible/roles/vm/guest/tasks/main.yml index e328026..4830d05 100644 --- a/ansible/roles/vm/guest/tasks/main.yml +++ b/ansible/roles/vm/guest/tasks/main.yml @@ -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 diff --git a/ansible/roles/vm/install/tasks/main.yml b/ansible/roles/vm/install/tasks/main.yml index 14886d9..31d5c8f 100644 --- a/ansible/roles/vm/install/tasks/main.yml +++ b/ansible/roles/vm/install/tasks/main.yml @@ -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 diff --git a/ansible/roles/vm/install/templates/libvirt-domain.xml.j2 b/ansible/roles/vm/install/templates/libvirt-domain.xml.j2 index aa45abb..0f4858b 100644 --- a/ansible/roles/vm/install/templates/libvirt-domain.xml.j2 +++ b/ansible/roles/vm/install/templates/libvirt-domain.xml.j2 @@ -1,12 +1,12 @@ {{ hostname }} - {{ hostvars[hostname].vm_install_cooked.mem * 1024 }} - {{ hostvars[hostname].vm_install_cooked.mem * 1024 }} - {{ hostvars[hostname].vm_install_cooked.numcpu }} + {{ hostvars[hostname].install_cooked.mem * 1024 }} + {{ hostvars[hostname].install_cooked.mem * 1024 }} + {{ hostvars[hostname].install_cooked.numcpu }} hvm {% if run_installer %} - {{ debian_installer_path }}/{{ distro }}-{{ distcodename }}/{{ hostvars[hostname].vm_install_cooked.arch | default('amd64') }}/linux + {{ debian_installer_path }}/{{ distro }}-{{ distcodename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/linux {{ preseed_path }}/{{ hostname }}-{{ distro }}-{{ distcodename }}.initrd.gz console=ttyS0,115200n8 {% endif %} @@ -35,8 +35,8 @@ /dev/urandom -{% 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() %} @@ -45,9 +45,9 @@ {% endfor %} {% endif %} -{% if 'scsi' in hostvars[hostname].vm_install_cooked.disks %} +{% if 'scsi' in hostvars[hostname].install_cooked.disks %} -{% for device, lv in hostvars[hostname].vm_install_cooked.disks.scsi.items() %} +{% for device, lv in hostvars[hostname].install_cooked.disks.scsi.items() %} @@ -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 %} diff --git a/ansible/roles/vm/network/tasks/main.yml b/ansible/roles/vm/network/tasks/main.yml index 3d51fff..39f4ff4 100644 --- a/ansible/roles/vm/network/tasks/main.yml +++ b/ansible/roles/vm/network/tasks/main.yml @@ -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: diff --git a/ansible/roles/vm/network/templates/interfaces.j2 b/ansible/roles/vm/network/templates/interfaces.j2 index 542e18d..829a3e7 100644 --- a/ansible/roles/vm/network/templates/interfaces.j2 +++ b/ansible/roles/vm/network/templates/interfaces.j2 @@ -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 diff --git a/ansible/roles/vm/network/templates/resolv.conf.j2 b/ansible/roles/vm/network/templates/resolv.conf.j2 index 86d4201..a32ec18 100644 --- a/ansible/roles/vm/network/templates/resolv.conf.j2 +++ b/ansible/roles/vm/network/templates/resolv.conf.j2 @@ -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 }} diff --git a/ansible/vm-install.yml b/ansible/vm-install.yml index 9e7f055..32166e7 100644 --- a/ansible/vm-install.yml +++ b/ansible/vm-install.yml @@ -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 -- 1.7.10.4