Browse Source

first commit

dtrv 3 years ago
commit
17e60f0142
4 changed files with 193 additions and 0 deletions
  1. 68 0
      .gitignore
  2. 1 0
      README.md
  3. 23 0
      ansible.cfg
  4. 101 0
      site.yml

+ 68 - 0
.gitignore

@@ -0,0 +1,68 @@
+# ---> Vim
+[._]*.s[a-w][a-z]
+[._]s[a-w][a-z]
+*.un~
+Session.vim
+.netrwhist
+*~
+
+# ---> Python
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+

+ 1 - 0
README.md

@@ -0,0 +1 @@
+baue debian lx-datasets

+ 23 - 0
ansible.cfg

@@ -0,0 +1,23 @@
+[defaults]
+inventory           = $HOME/verchow.inventory
+remote_user         = root
+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
+
+# additional paths to search for roles or modules in, colon separated
+roles_path = $HOME/ansible/roles/
+library    = $HOME/ansible/modules/
+

+ 101 - 0
site.yml

@@ -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/