Browse Source

cleanup

master
parent
commit
23c3a7af01
13 changed files with 56 additions and 73 deletions
  1. +0
    -1
      .gitignore
  2. +0
    -2
      defaults/main.yml
  3. +0
    -25
      meta/main.yml
  4. +12
    -6
      tasks/installer.yml
  5. +10
    -12
      tasks/main.yml
  6. +0
    -1
      tasks/method/iso.yml
  7. +0
    -0
      tasks/method/kexec.yml
  8. +10
    -6
      tasks/preseed.yml
  9. +17
    -0
      tasks/setup.yml
  10. +0
    -14
      tasks/tools.yml
  11. +0
    -3
      tasks/vm.yml
  12. +3
    -1
      templates/preseed.cfg.j2
  13. +4
    -2
      templates/run.sh.j2

+ 0
- 1
.gitignore View File

@@ -1 +0,0 @@
*~

+ 0
- 2
defaults/main.yml View File

@@ -1,4 +1,2 @@
installer_directory: host_files/{{ inventory_hostname }}/installer
nonfree_firmware: false
img_size: 8
memory: 512

+ 0
- 25
meta/main.yml View File

@@ -1,25 +0,0 @@
---
dependencies:
- name: static_host_vars
static_host_vars_default:
uuid: "{{ lookup('pipe','uuid') }}"
networks: "{{ { netname : { 'mac': '%02x' | format( (2**44)*5 + 2**41 + (2**32)*84 + (16777216|random) ) | hwaddr( 'linux' ) } } }}"
when: install=="vm"
- name: password
password_name: root
password_hash: sha512
password_wordlists: ['en']
password_space: true
password_bits: 96
- name: password
password_name: "local-admin"
password_hash: sha512
password_wordlists: ['en']
password_space: true
password_bits: 96
- name: password
password_name: grub
password_hash: md5
password_wordlists: ['en']
password_space: true
password_bits: 96

+ 12
- 6
tasks/installer.yml View File

@@ -1,22 +1,28 @@
---

- name: copy linux kernel
copy: src=/usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/linux dest={{installer_directory}}/linux remote_src=true
copy:
src: /usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/linux
dest: {{installer_directory}}/linux remote_src=true

- name: copy initrd for customization
shell: gunzip -c /usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/initrd.gz > {{installer_directory}}/initrd
shell: gunzip -c
/usr/lib/debian-installer/images/8/amd64/text/debian-installer/amd64/initrd.gz
> {{installer_directory}}/initrd

- name: insert files into initrd
shell: echo {{item}} | cpio --create --format=newc --append --file=initrd
args:
chdir: "{{installer_directory}}/"
chdir: "{{installer_directory}}"
with_items:
- preseed.cfg
- run.sh
- preseed.cfg
- run.sh

- name: compress custom initrd
command: gzip -f {{installer_directory}}/initrd

- name: merge initrd.gz and firmware.cpio.gz
shell: cat /usr/lib/debian-installer/images/8/amd64/text/debian-installer/firmware.cpio.gz >> {{installer_directory}}/initrd.gz
shell: cat
/usr/lib/debian-installer/images/8/amd64/text/debian-installer/firmware.cpio.gz
>> {{installer_directory}}/initrd.gz
when: nonfree_firmware

+ 10
- 12
tasks/main.yml View File

@@ -1,19 +1,17 @@
---

#- include: tools.yml
- import_tasks: setup.yml

- name: host install directory
file: state=directory path={{installer_directory}}
file:
state: directory
path: "{{installer_directory}}"

- include: preseed.yml
- import_tasks: preseed.yml
- import_tasks: installer.yml

- include: installer.yml
- include: method/kexec.yml
when: debian_installer_method == "kexec"

- include: kexec.yml
when: install == "kexec"
- include: iso.yml
when: (install == "iso") or (install == "vm")

- include: vm.yml
when: install == "vm"
- include: method/iso.yml
when: debian_installer_method == "iso"

tasks/iso.yml → tasks/method/iso.yml View File

@@ -11,4 +11,3 @@

- name: generate iso image
command: genisoimage -o {{installer_directory}}/installer.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table {{installer_directory}}/

tasks/kexec.yml → tasks/method/kexec.yml View File


+ 10
- 6
tasks/preseed.yml View File

@@ -1,12 +1,16 @@
---

- name: template run.sh
template: src=run.sh.j2 dest={{installer_directory}}/run.sh
- name: run.sh
template:
src: run.sh.j2
dest: "{{installer_directory}}/run.sh"

- name: stat run.sh
stat: path={{installer_directory}}/run.sh
stat:
path: "{{installer_directory}}/run.sh"
register: run_sh
- name: template preseed.cfg
template: src=preseed.cfg.j2 dest={{installer_directory}}/preseed.cfg

- name: preseed.cfg
template:
src: preseed.cfg.j2
dest: "{{installer_directory}}/preseed.cfg"

+ 17
- 0
tasks/setup.yml View File

@@ -0,0 +1,17 @@
---

- name: install required software
apt:
name: "{{item}}"
with_items:
- cpio
- debian-installer-9-netboot-amd64
- genisoimage
- syslinux
- isolinux
- pxelinux

- name: download unofficial firmware for debian-installer
get_url:
url: http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.cpio.gz
dest: /opt/debian-installer-unofficial-firmware.cpio.gz

+ 0
- 14
tasks/tools.yml View File

@@ -1,14 +0,0 @@
---

- name: install required software
apt: name={{item}} state=present
with_items:
- cpio
- debian-installer-8-netboot-amd64
- genisoimage
- syslinux
- isolinux
- pxelinux

- name: download d-i non-free firmware
get_url: url=http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stable/current/firmware.cpio.gz dest=/usr/lib/debian-installer/images/8/amd64/text/debian-installer/firmware.cpio.gz

+ 0
- 3
tasks/vm.yml View File

@@ -1,3 +0,0 @@
---
- name: install vm
command: virt-install -n {{ inventory_hostname }} --memory {{memory}} --vcpus {{vcpus|default(1)}} --disk size={{img_size}} --network network={{netname}},mac={{networks[netname].mac}},model=e1000 --cdrom {{installer_directory}}/installer.iso --os-variant=debianwheezy

+ 3
- 1
templates/preseed.cfg.j2 View File

@@ -9,6 +9,7 @@ d-i debian-installer/locale string de_DE.UTF-8
d-i keyboard-configuration/xkb-keymap select de
d-i keyboard-configuration/toggle select No toggling

{#
### Network configuration
{% if (networks is defined) and (netname is defined) and (networks[netname] is defined) %}
d-i netcfg/choose_interface select {{ networks[netname].mac | default("auto") }}
@@ -22,6 +23,7 @@ d-i netcfg/get_nameservers string {{ networks[netname].nameservers | join(" ") }
d-i netcfg/confirm_static boolean true
{% endif %}
{% endif %}
#}

### Network console
{% if network_console is defined %}
@@ -50,7 +52,7 @@ d-i passwd/root-password-crypted password {{ passwords_hashed["root"] }}

# local-admin
d-i passwd/user-fullname string Administrator
d-i passwd/username string local-admin
d-i passwd/username string local-admin
d-i passwd/user-password-crypted password {{ passwords_hashed["local-admin"] }}
d-i passwd/user-uid string 999



+ 4
- 2
templates/run.sh.j2 View File

@@ -1,7 +1,9 @@
#!/bin/sh

{% if root_ssh_authorized_keys is defined %}
mkdir -p /.ssh

cat > /.ssh/authorized_keys << EOF
{{ lookup('file', 'ssh_authorized_keys') }}
{% for key in root_ssh_authorized_keys %}
{{key}}
{% endfor %}
EOF

Loading…
Cancel
Save