adapt vm install role to new inventory naming scheme
authorChristian Pointner <equinox@realraum.at>
Sun, 22 Apr 2018 19:25:17 +0000 (21:25 +0200)
committerChristian Pointner <equinox@realraum.at>
Sun, 22 Apr 2018 19:25:17 +0000 (21:25 +0200)
ansible/host_playbooks/alfred.mgmt.yml [deleted file]
ansible/host_playbooks/alfred.yml [new file with mode: 0644]
ansible/host_playbooks/testvm.mgmt.yml [deleted file]
ansible/host_playbooks/testvm.yml [new file with mode: 0644]
ansible/host_vars/alfred.mgmt/main.yml [deleted file]
ansible/host_vars/alfred/main.yml [new file with mode: 0644]
ansible/host_vars/testvm.mgmt/main.yml [deleted file]
ansible/host_vars/testvm/main.yml [new file with mode: 0644]
ansible/roles/vm/install/templates/preseed_debian-stretch.cfg.j2

diff --git a/ansible/host_playbooks/alfred.mgmt.yml b/ansible/host_playbooks/alfred.mgmt.yml
deleted file mode 100644 (file)
index d5c93e3..0000000
+++ /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 (file)
index 0000000..f4d7646
--- /dev/null
@@ -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 (file)
index 80fbc6b..0000000
+++ /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 (file)
index 0000000..261bb7e
--- /dev/null
@@ -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 (file)
index 0ade5a7..0000000
+++ /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 (file)
index 0000000..b6b9b0c
--- /dev/null
@@ -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 (file)
index 45248e7..0000000
+++ /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 (file)
index 0000000..f894adc
--- /dev/null
@@ -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
index e8694ec..f8e7e11 100644 (file)
@@ -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"