From b13acb3e4bef791b2196590a61b27bfb7f606ea6 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 22 Apr 2018 21:25:17 +0200 Subject: [PATCH] adapt vm install role to new inventory naming scheme --- ansible/host_playbooks/alfred.mgmt.yml | 6 ---- ansible/host_playbooks/alfred.yml | 6 ++++ ansible/host_playbooks/testvm.mgmt.yml | 7 ----- ansible/host_playbooks/testvm.yml | 7 +++++ ansible/host_vars/alfred.mgmt/main.yml | 27 ----------------- ansible/host_vars/alfred/main.yml | 27 +++++++++++++++++ ansible/host_vars/testvm.mgmt/main.yml | 32 -------------------- ansible/host_vars/testvm/main.yml | 32 ++++++++++++++++++++ .../templates/preseed_debian-stretch.cfg.j2 | 2 +- 9 files changed, 73 insertions(+), 73 deletions(-) delete mode 100644 ansible/host_playbooks/alfred.mgmt.yml create mode 100644 ansible/host_playbooks/alfred.yml delete mode 100644 ansible/host_playbooks/testvm.mgmt.yml create mode 100644 ansible/host_playbooks/testvm.yml delete mode 100644 ansible/host_vars/alfred.mgmt/main.yml create mode 100644 ansible/host_vars/alfred/main.yml delete mode 100644 ansible/host_vars/testvm.mgmt/main.yml create mode 100644 ansible/host_vars/testvm/main.yml diff --git a/ansible/host_playbooks/alfred.mgmt.yml b/ansible/host_playbooks/alfred.mgmt.yml deleted file mode 100644 index d5c93e3..0000000 --- a/ansible/host_playbooks/alfred.mgmt.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Basic Setup for alfred - hosts: alfred.mgmt - roles: - - role: base - - role: vm/host diff --git a/ansible/host_playbooks/alfred.yml b/ansible/host_playbooks/alfred.yml new file mode 100644 index 0000000..f4d7646 --- /dev/null +++ b/ansible/host_playbooks/alfred.yml @@ -0,0 +1,6 @@ +--- +- name: Basic Setup for alfred + hosts: alfred + roles: + - role: base + - role: vm/host diff --git a/ansible/host_playbooks/testvm.mgmt.yml b/ansible/host_playbooks/testvm.mgmt.yml deleted file mode 100644 index 80fbc6b..0000000 --- a/ansible/host_playbooks/testvm.mgmt.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup for testvm - hosts: testvm.mgmt - roles: - - role: base - - role: vm/grub - - role: vm/network diff --git a/ansible/host_playbooks/testvm.yml b/ansible/host_playbooks/testvm.yml new file mode 100644 index 0000000..261bb7e --- /dev/null +++ b/ansible/host_playbooks/testvm.yml @@ -0,0 +1,7 @@ +--- +- name: Basic Setup for testvm + hosts: testvm + roles: + - role: base + - role: vm/grub + - role: vm/network diff --git a/ansible/host_vars/alfred.mgmt/main.yml b/ansible/host_vars/alfred.mgmt/main.yml deleted file mode 100644 index 0ade5a7..0000000 --- a/ansible/host_vars/alfred.mgmt/main.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -vm_host: - installer: - net_if: br-mgmt - preseed_path: /srv/preseed - path: /srv/installer - distros: - - distro: debian - codename: stretch - arch: - - amd64 - - i386 - - distro: ubuntu - codename: xenial - arch: - - amd64 - - i386 - network: - interface: br-mgmt - ip: 192.168.33.65 - mask: 255.255.255.0 - gateway: 192.168.33.1 - nameservers: - - 192.168.33.1 - - 10.12.0.10 - indices: - testvm.mgmt: 200 diff --git a/ansible/host_vars/alfred/main.yml b/ansible/host_vars/alfred/main.yml new file mode 100644 index 0000000..b6b9b0c --- /dev/null +++ b/ansible/host_vars/alfred/main.yml @@ -0,0 +1,27 @@ +--- +vm_host: + installer: + net_if: br-mgmt + preseed_path: /srv/preseed + path: /srv/installer + distros: + - distro: debian + codename: stretch + arch: + - amd64 + - i386 + - distro: ubuntu + codename: xenial + arch: + - amd64 + - i386 + network: + interface: br-mgmt + ip: 192.168.33.65 + mask: 255.255.255.0 + gateway: 192.168.33.1 + nameservers: + - 192.168.33.1 + - 10.12.0.10 + indices: + testvm: 200 diff --git a/ansible/host_vars/testvm.mgmt/main.yml b/ansible/host_vars/testvm.mgmt/main.yml deleted file mode 100644 index 45248e7..0000000 --- a/ansible/host_vars/testvm.mgmt/main.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -localconfig_ssh_config_user: root - -vm_install_host: alfred.mgmt - -vm_install: - host: "{{ vm_install_host }}" - mem: 1024 - numcpu: 2 - disks: - primary: vda - virtio: - vda: - vg: alfred - lv: "{{ inventory_hostname }}" - size: 10g - interfaces: - - idx: 1 - bridge: "{{ hostvars[vm_install_host].vm_host.network.interface }}" - name: primary0 - autostart: True - -vm_network: - systemd_link: - interfaces: "{{ vm_install.interfaces }}" - primary: - interface: primary0 - 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) }}" - nameservers: "{{ hostvars[vm_install_host].vm_host.network.nameservers }}" - domain: realraum.at diff --git a/ansible/host_vars/testvm/main.yml b/ansible/host_vars/testvm/main.yml new file mode 100644 index 0000000..f894adc --- /dev/null +++ b/ansible/host_vars/testvm/main.yml @@ -0,0 +1,32 @@ +--- +localconfig_ssh_config_user: root + +vm_install_host: alfred + +vm_install: + host: "{{ vm_install_host }}" + mem: 1024 + numcpu: 2 + disks: + primary: vda + virtio: + vda: + vg: alfred + lv: "{{ inventory_hostname }}" + size: 10g + interfaces: + - idx: 1 + bridge: "{{ hostvars[vm_install_host].vm_host.network.interface }}" + name: primary0 + autostart: True + +vm_network: + systemd_link: + interfaces: "{{ vm_install.interfaces }}" + primary: + interface: primary0 + 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) }}" + nameservers: "{{ hostvars[vm_install_host].vm_host.network.nameservers }}" + domain: realraum.at diff --git a/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 b/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 index e8694ec..f8e7e11 100644 --- a/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 +++ b/ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2 @@ -102,5 +102,5 @@ d-i finish-install/reboot_in_progress note d-i preseed/late_command string \ lvremove -f {{ vmname }}/dummy; \ in-target bash -c "apt-get update -q && apt-get full-upgrade -y -q"; \ - in-target bash -c "passwd -d root; passwd -l root; umask 077; mkdir -p /root/.ssh/; echo -e '{{ lookup('pipe','cat ssh/noc/*.pub') | replace('\n', '\\n') }}' > /root/.ssh/authorized_keys"; \ + in-target bash -c "passwd -d root; passwd -l root; umask 077; mkdir -p /root/.ssh/; echo -e '{{ noc_ssh_keys | join('\\n') }}' > /root/.ssh/authorized_keys"; \ in-target bash -c "sed 's/^\(\s*#\s*Port.*\)/Port 22000/' -i /etc/ssh/sshd_config" -- 1.7.10.4