From 17077868e615fa7115abdb03a5af4662ab0a3679 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 23 Apr 2020 01:24:38 +0200 Subject: refactor all install roles ans playbooks to work with new variable install_hostname --- common/cloud-install.yml | 10 +++++----- common/usb-install.yml | 8 ++++---- common/vm-install.yml | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'common') diff --git a/common/cloud-install.yml b/common/cloud-install.yml index e80bfed0..57ebc9e6 100644 --- a/common/cloud-install.yml +++ b/common/cloud-install.yml @@ -1,12 +1,12 @@ --- - name: basic installation - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" gather_facts: no roles: - role: cloud/install - name: wait for newly installed machine to start up - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" gather_facts: no tasks: ## TODO: find a better way to fetch host key of new VMs @@ -22,17 +22,17 @@ ansible_ssh_extra_args: "" - name: run post install roles - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" pre_tasks: - name: make sure to update cached facts setup: roles: - role: cloud/post-install -- import_playbook: "../{{ hostenv }}/{{ hostname }}.yml" +- import_playbook: "../{{ install_environment }}/{{ hostvars[install_hostname].install_playbook | default(install_hostname) }}.yml" - name: reboot and wait for machine come back - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" gather_facts: no roles: - role: reboot-and-wait diff --git a/common/usb-install.yml b/common/usb-install.yml index db9faf7e..33f488eb 100644 --- a/common/usb-install.yml +++ b/common/usb-install.yml @@ -1,6 +1,6 @@ --- - name: fetch debian installer and bake initrd - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" connection: local gather_facts: no @@ -12,7 +12,7 @@ pre_tasks: - set_fact: - artifacts_dir: "{{ global_artifacts_dir }}/{{ hostname }}" + artifacts_dir: "{{ global_artifacts_dir }}/{{ install_hostname }}" installer_path: "{{ global_cache_dir }}/debian-installer" - file: @@ -44,7 +44,7 @@ dest: "{{ usbdrive_path }}/syslinux.cfg" content: | DEFAULT linux - SAY SYSLINUX booting an automated installer for {{ hostname }}... + SAY SYSLINUX booting an automated installer for {{ install_hostname }}... LABEL linux KERNEL linux INITRD initrd.preseed.gz @@ -60,7 +60,7 @@ dest: "{{ usbdrive_path }}/EFI/boot/syslinux.cfg" content: | DEFAULT linux - SAY SYSLINUX booting an automated installer for {{ hostname }}... + SAY SYSLINUX booting an automated installer for {{ install_hostname }}... LABEL linux KERNEL ../../linux INITRD ../../initrd.preseed.gz diff --git a/common/vm-install.yml b/common/vm-install.yml index cb3b86f0..c3e7a25c 100644 --- a/common/vm-install.yml +++ b/common/vm-install.yml @@ -1,17 +1,11 @@ --- - name: preperations and sanity checks - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" gather_facts: no tasks: - - name: create temporary host group for vm host - add_host: - name: "{{ vm_host }}" - inventory_dir: "{{ inventory_dir }}" - group: _vmhost_ - - name: check if the installee belongs to the kvmguests group fail: - msg: "the host '{{ hostname }}' does not belong to the group 'kvmguests'" + msg: "the host '{{ install_hostname }}' does not belong to the group 'kvmguests'" when: - "'kvmguests' not in group_names" @@ -23,6 +17,12 @@ # TODO: add some more sanity checks + - name: create temporary host group for vm host + add_host: + name: "{{ vm_host }}" + inventory_dir: "{{ inventory_dir }}" + group: _vmhost_ + - name: basic installation hosts: _vmhost_ @@ -30,7 +30,7 @@ - role: vm/install - name: wait for new vm to start up - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" gather_facts: no tasks: ## TODO: find a better way to fetch host key of new VMs @@ -46,7 +46,7 @@ ansible_ssh_extra_args: "" - name: apply basic VM configuration roles - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" pre_tasks: - name: make sure to update cached facts setup: @@ -58,10 +58,10 @@ - role: vm/guest when: install_distro in ['debian', 'ubuntu'] -- import_playbook: "../{{ hostenv }}/{{ hostname }}.yml" +- import_playbook: "../{{ install_environment }}/{{ hostvars[install_hostname].install_playbook | default(install_hostname) }}.yml" - name: reboot and wait for VM come back - hosts: "{{ hostname }}" + hosts: "{{ install_hostname }}" gather_facts: no roles: - role: reboot-and-wait -- cgit v1.2.3