site.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ---
  2. - hosts: nessi.verchow.egs
  3. tags: create_kvm
  4. vars:
  5. kvm_alias: lx-builder
  6. kvm_install_iso: /media0/software-images/debian-9.1.0-amd64-netinst.iso
  7. # if you skip the 'rebuild' tag
  8. kvm:
  9. uuid: '...'
  10. pre_tasks:
  11. - name: destroy current kvm
  12. vmadm:
  13. alias: "{{ kvm_alias }}"
  14. state: absent
  15. tasks:
  16. - name: create kvm
  17. vmadm:
  18. alias: "{{ kvm_alias }}"
  19. autoboot: false
  20. brand: kvm
  21. disks:
  22. - boot: true
  23. model: virtio
  24. size: 8192
  25. nics:
  26. - nic_tag: admin
  27. ip: dhcp
  28. primary: true
  29. model: virtio
  30. ram: 4096
  31. state: stopped
  32. vcpus: 2
  33. register: kvm
  34. - debug: var=kvm
  35. - name: copy install iso to zone
  36. copy:
  37. remote_src: true
  38. src: "{{ kvm_install_iso }}"
  39. dest: "/zones/{{ kvm.uuid }}/root/install.iso"
  40. - name: boot from iso
  41. shell: "vmadm boot {{ kvm.uuid }} order=cd,once=d cdrom=/install.iso,ide"
  42. - name: get vnc infos
  43. shell: "vmadm info {{ kvm.uuid }} | json vnc.port"
  44. register: kvm_vnc_port
  45. - debug: var=kvm_info.stdout
  46. - debug:
  47. msg: "vncviewer {{ ansible_hostname }}:{{ kvm_vnc_port.stdout }}"
  48. - hosts: lx-builder
  49. gather_facts: no
  50. roles:
  51. - debian-ansible-target
  52. tasks:
  53. - hosts: lx-builder
  54. pre_tasks:
  55. - name: create .ssh folder
  56. file:
  57. path: /root/.ssh
  58. mode: 0700
  59. state: directory
  60. - name: copy ssh-id
  61. copy:
  62. src: /home/trv/.ssh/id_rsa.pub
  63. dest: /root/.ssh/authorized_keys
  64. mode: 0600
  65. tasks:
  66. - name: install packages
  67. apt:
  68. name:
  69. - debootstrap
  70. - git
  71. - name: git checkout lx-brand image builder
  72. git:
  73. repo: https://github.com/joyent/debian-lx-brand-image-builder.git
  74. dest: /root/debian-lx-brand-image-builder/
  75. - name: chmod scripte
  76. file:
  77. dest: /root/debian-lx-brand-image-builder/install
  78. mode: 0750
  79. - set_fact:
  80. release: "stretch"
  81. install_dir: /root/lx/
  82. archive_mirror: "http://ftp.de.debian.org/debian/"
  83. image_name_short: "debian-9"
  84. image_name_full: "Debian 9.1"
  85. image_description: "Container-native Debian 9.1 (stretch) 64-bit image."
  86. - name: build lx
  87. command: "./install -r {{ release }} -d {{ install_dir }} -m {{ archive_mirror }} -i {{ image_name_short }} -p {{ image_name_full }} -D {{ image_description }}"
  88. args:
  89. chdir: /root/debian-lx-brand-image-builder/