|
@@ -0,0 +1,101 @@
|
|
|
|
+---
|
|
|
|
+
|
|
|
|
+- hosts: nessi.verchow.egs
|
|
|
|
+ tags: create_kvm
|
|
|
|
+ vars:
|
|
|
|
+ kvm_alias: lx-builder
|
|
|
|
+ kvm_install_iso: /media0/software-images/debian-9.1.0-amd64-netinst.iso
|
|
|
|
+# if you skip the 'rebuild' tag
|
|
|
|
+ kvm:
|
|
|
|
+ uuid: '...'
|
|
|
|
+ pre_tasks:
|
|
|
|
+ - name: destroy current kvm
|
|
|
|
+ vmadm:
|
|
|
|
+ alias: "{{ kvm_alias }}"
|
|
|
|
+ state: absent
|
|
|
|
+ tasks:
|
|
|
|
+ - name: create kvm
|
|
|
|
+ vmadm:
|
|
|
|
+ alias: "{{ kvm_alias }}"
|
|
|
|
+ autoboot: false
|
|
|
|
+ brand: kvm
|
|
|
|
+ disks:
|
|
|
|
+ - boot: true
|
|
|
|
+ model: virtio
|
|
|
|
+ size: 8192
|
|
|
|
+ nics:
|
|
|
|
+ - nic_tag: admin
|
|
|
|
+ ip: dhcp
|
|
|
|
+ primary: true
|
|
|
|
+ model: virtio
|
|
|
|
+ ram: 4096
|
|
|
|
+ state: stopped
|
|
|
|
+ vcpus: 2
|
|
|
|
+ register: kvm
|
|
|
|
+
|
|
|
|
+ - debug: var=kvm
|
|
|
|
+
|
|
|
|
+ - name: copy install iso to zone
|
|
|
|
+ copy:
|
|
|
|
+ remote_src: true
|
|
|
|
+ src: "{{ kvm_install_iso }}"
|
|
|
|
+ dest: "/zones/{{ kvm.uuid }}/root/install.iso"
|
|
|
|
+
|
|
|
|
+ - name: boot from iso
|
|
|
|
+ shell: "vmadm boot {{ kvm.uuid }} order=cd,once=d cdrom=/install.iso,ide"
|
|
|
|
+
|
|
|
|
+ - name: get vnc infos
|
|
|
|
+ shell: "vmadm info {{ kvm.uuid }} | json vnc.port"
|
|
|
|
+ register: kvm_vnc_port
|
|
|
|
+
|
|
|
|
+ - debug: var=kvm_info.stdout
|
|
|
|
+ - debug:
|
|
|
|
+ msg: "vncviewer {{ ansible_hostname }}:{{ kvm_vnc_port.stdout }}"
|
|
|
|
+
|
|
|
|
+- hosts: lx-builder
|
|
|
|
+ gather_facts: no
|
|
|
|
+ roles:
|
|
|
|
+ - debian-ansible-target
|
|
|
|
+ tasks:
|
|
|
|
+
|
|
|
|
+- hosts: lx-builder
|
|
|
|
+ pre_tasks:
|
|
|
|
+ - name: create .ssh folder
|
|
|
|
+ file:
|
|
|
|
+ path: /root/.ssh
|
|
|
|
+ mode: 0700
|
|
|
|
+ state: directory
|
|
|
|
+ - name: copy ssh-id
|
|
|
|
+ copy:
|
|
|
|
+ src: /home/trv/.ssh/id_rsa.pub
|
|
|
|
+ dest: /root/.ssh/authorized_keys
|
|
|
|
+ mode: 0600
|
|
|
|
+ tasks:
|
|
|
|
+ - name: install packages
|
|
|
|
+ apt:
|
|
|
|
+ name:
|
|
|
|
+ - debootstrap
|
|
|
|
+ - git
|
|
|
|
+
|
|
|
|
+ - name: git checkout lx-brand image builder
|
|
|
|
+ git:
|
|
|
|
+ repo: https://github.com/joyent/debian-lx-brand-image-builder.git
|
|
|
|
+ dest: /root/debian-lx-brand-image-builder/
|
|
|
|
+
|
|
|
|
+ - name: chmod scripte
|
|
|
|
+ file:
|
|
|
|
+ dest: /root/debian-lx-brand-image-builder/install
|
|
|
|
+ mode: 0750
|
|
|
|
+
|
|
|
|
+ - set_fact:
|
|
|
|
+ release: "stretch"
|
|
|
|
+ install_dir: /root/lx/
|
|
|
|
+ archive_mirror: "http://ftp.de.debian.org/debian/"
|
|
|
|
+ image_name_short: "debian-9"
|
|
|
|
+ image_name_full: "Debian 9.1"
|
|
|
|
+ image_description: "Container-native Debian 9.1 (stretch) 64-bit image."
|
|
|
|
+
|
|
|
|
+ - name: build lx
|
|
|
|
+ command: "./install -r {{ release }} -d {{ install_dir }} -m {{ archive_mirror }} -i {{ image_name_short }} -p {{ image_name_full }} -D {{ image_description }}"
|
|
|
|
+ args:
|
|
|
|
+ chdir: /root/debian-lx-brand-image-builder/
|