Browse Source

baute debian-9, noch einiges manuell

dtrv 3 years ago
parent
commit
5300c25825
7 changed files with 175 additions and 115 deletions
  1. 34 1
      README.md
  2. 2 13
      ansible.cfg
  3. 49 0
      create_kvm.yml
  4. 20 0
      create_lx_image.yml
  5. 56 0
      create_tarball.yml
  6. 0 101
      site.yml
  7. 14 0
      vars.yml

+ 34 - 1
README.md

@@ -1 +1,34 @@
-baue debian lx-datasets
+# Debian LX-brand Images fuer SmartOS 
+
+## TL;DR
+1. baue KVM auf SmartOS-Host
+1. Installiere in die KVM ein Debian
+1. debootstrap das Debian in Verzeichnis.tgz
+1. mache auf SmartOS-Host aus Verzeichnis.tgz ein LX-Image
+
+## Voraussetzungen
+- Install-ISO zum Booten
+- VNC-Zugriff auf den SmartOS-Host
+- `id_rsa.pub` in `.ssh` auf dem Ansible-Host
+
+## Ablauf
+1. Playbook `create_kvm.yml`: KVM bauen und mit Install-ISO booten
+  * KVM heisst " lx-builder"
+  * fuer Hardware-Optionen siehe Playbook
+  * gibt als Host und Port fuer VNC aus
+1. Standard-Installation mit dem Installer per Hand
+  * user anlegen, sein Passwort merken! (spaeter remote_user Passwort)
+  * root-Passwort merken! (spaeter become Passwort)
+1. Playbook `create_tarball.yml`: Tarball mit debian-lx-brand-image-builder bauen
+  * run `ansible-playbook --ask-pass --ask-become-pass create_tarball.yml` 
+  * debootstrappt Debian in KVM in `/root/lx`
+  * erstellt Ergebnisse in `/root/debian-lx-brand-image-builder` und kopiert es dann nach `/tmp` damit jeder darauf zugreifen kann
+1. manuell kopiere `/tmp/debian-lx-brand-image-builder` auf SmartOS-Host
+1. Playbook `create_lx_image.yml`: baut das LX-Image und das Manifest
+  * laeuft auf SmartOS-Host
+  * erstellt Image in `/tmp`, d.h. Kopieren vor Reboot!
+1. Import des LX-Image mit `imgadm install -m MANIFEST.json -f ZONEFILE.zfs.gz`
+1. Anzeigen mit ` imgadm list`
+
+## Links
+* [debian-lx-brand-imgage-builder](https://github.com/joyent/debian-lx-brand-image-builder) on github

+ 2 - 13
ansible.cfg

@@ -1,21 +1,10 @@
 [defaults]
 inventory           = $HOME/verchow.inventory
-remote_user         = root
+remote_user         = 
 vault_password_file = $HOME/.vaults/verchow
 retry_files_enabled = False
 host_key_checking   = False
-
-# by default retrieve all facts subsets
-# all - gather all subsets
-# network - gather min and network facts
-# hardware - gather hardware facts (longest facts to retrieve)
-# virtual - gather min and virtual facts
-# facter - import facts from facter
-# ohai - import facts from ohai
-# You can combine them using comma (ex: network,virtual)
-# You can negate them using ! (ex: !hardware,!facter,!ohai)
-# A minimal set of facts is always gathered.
-gather_subset = !hardware
+gather_subset       = !hardware
 
 # additional paths to search for roles or modules in, colon separated
 roles_path = $HOME/ansible/roles/

+ 49 - 0
create_kvm.yml

@@ -0,0 +1,49 @@
+---
+
+- hosts: lx-builder-host
+  remote_user: root
+  vars_files: [ vars.yml ]
+  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 }}"
+

+ 20 - 0
create_lx_image.yml

@@ -0,0 +1,20 @@
+---
+
+- hosts: lx-builder-host
+  remote_user: root
+  vars_files: [ vars.yml ]
+  tasks:
+    - debug:
+        msg: "scp -r trv@lx-builder:/tmp/debian-lx-brand-image-builder /tmp/"
+
+    - shell: "./create-lx-image -t /tmp/debian-lx-brand-image-builder/{{ image_name_short|quote }}-{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}.tar.gz -k {{ lx_kernel_version }} -m {{ lx_min_platform }} -i {{ image_name_short|quote }} -d {{ image_description|quote }}"
+      args:
+        chdir: /tmp/debian-lx-brand-image-builder/
+        removes: /tmp/debian-lx-brand-image-builder/create-lx-image
+      register: lx
+
+    - debug: var=lx
+
+    - debug:
+        msg: "import image with: imgadm install -m XXX.json -f XXX.zfs.gz"
+     

+ 56 - 0
create_tarball.yml

@@ -0,0 +1,56 @@
+---
+
+- hosts: lx-builder
+  gather_facts: no
+  become: true
+  become_method: su
+  roles:
+    - debian-ansible-target
+    
+- hosts: lx-builder
+  vars_files: [ vars.yml ]
+  become: true
+  become_method: su
+  pre_tasks:
+    - name: create .ssh folder
+      file: 
+        path: /root/.ssh
+        mode: 0700
+        state: directory
+    - name: copy ssh-id
+      copy:
+        src: "{{ lookup('env','HOME') }}/.ssh/id_rsa.pub"
+        dest: /root/.ssh/authorized_keys
+        mode: 0600
+  tasks:
+    - name: install packages
+      apt:
+        name:
+          - debootstrap
+          - git
+          - curl
+
+    - 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: create install folder
+      file:
+        dest: /root/lx
+        state: directory
+
+    - name: build lx
+      tags: rebuild_lx
+      command: "./install -r {{ image_release }} -d /root/lx -m {{ image_archive_mirror }} -i {{ image_name_short }}  -p {{ image_name_full }} -D {{ image_description }}"
+      args:
+        chdir: /root/debian-lx-brand-image-builder/
+
+    - name: copy lx folder to /tmp
+      command: "cp -a /root/debian-lx-brand-image-builder /tmp/"
+
+    - name: make lx folter in /tmp readable for everybody
+      file:
+        dest: /tmp/debian-lx-brand-image-builder
+        mode: "o+r"
+        recurse: true

+ 0 - 101
site.yml

@@ -1,101 +0,0 @@
----
-
-- 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/

+ 14 - 0
vars.yml

@@ -0,0 +1,14 @@
+---
+
+kvm_alias: lx-builder
+kvm_install_iso: /media0/software-images/debian-9.1.0-amd64-netinst.iso
+
+image_release: "stretch"
+image_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."
+
+lx_kernel_version: "4.3.0"
+lx_min_platform: "20170511T001921Z"
+