seperate directory for every host
This commit is contained in:
parent
4ae019a512
commit
1987344d15
@ -1,4 +1,14 @@
|
||||
---
|
||||
- name: check if iso exists
|
||||
stat:
|
||||
path: "{{ playbook_dir }}/debian-11.4.0-amd64-netinst-unattended-{{ inventory_hostname }}.iso"
|
||||
delegate_to: localhost
|
||||
register: iso_exists
|
||||
|
||||
- name: stop when facts not set to download Packages
|
||||
meta: end_play
|
||||
when: iso_exists.stat.exists
|
||||
|
||||
- name: install stuff
|
||||
apt:
|
||||
name:
|
||||
@ -10,51 +20,51 @@
|
||||
|
||||
- name: create project directory
|
||||
file:
|
||||
dest: /opt/ansiblepackages/debianunattended
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}"
|
||||
state: directory
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Download ISO Image
|
||||
get_url:
|
||||
url: "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.3.0-amd64-netinst.iso"
|
||||
dest: "/opt/ansiblepackages/debianunattended/debian-11.3.0-amd64-netinst.iso"
|
||||
url: "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.4.0-amd64-netinst.iso"
|
||||
dest: "/opt/ansiblepackages/debianunattended/debian-11.4.0-amd64-netinst.iso"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: delete old stuff
|
||||
file:
|
||||
path: /opt/ansiblepackages/debianunattended/isofiles/
|
||||
path: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/"
|
||||
state: absent
|
||||
delegate_to: localhost
|
||||
|
||||
- name: extract ISO Image
|
||||
command: xorriso -osirrox on -indev /opt/ansiblepackages/debianunattended/debian-11.3.0-amd64-netinst.iso -extract / /opt/ansiblepackages/debianunattended/isofiles/
|
||||
command: "xorriso -osirrox on -indev /opt/ansiblepackages/debianunattended/debian-11.4.0-amd64-netinst.iso -extract / /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/"
|
||||
args:
|
||||
creates: /opt/ansiblepackages/debianunattended/isofiles/install.amd/initrd.gz
|
||||
creates: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/initrd.gz"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: generate /opt/ansiblepackages/debianunattended/preseed.cfg
|
||||
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/preseed.cfg
|
||||
template:
|
||||
src: preseed.cfg.j2
|
||||
dest: /opt/ansiblepackages/debianunattended/preseed.cfg
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/preseed.cfg"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: generate /opt/ansiblepackages/debianunattended/md5sum.sh
|
||||
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh
|
||||
template:
|
||||
src: md5sum.sh.j2
|
||||
mode: "0755"
|
||||
dest: /opt/ansiblepackages/debianunattended/md5sum.sh
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: generate /opt/ansiblepackages/debianunattended/mergepreseed.sh
|
||||
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh
|
||||
template:
|
||||
src: mergepreseed.sh.j2
|
||||
mode: "0755"
|
||||
dest: /opt/ansiblepackages/debianunattended/mergepreseed.sh
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set permissions
|
||||
file:
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/install.amd/
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/"
|
||||
mode: +w
|
||||
recurse: yes
|
||||
delegate_to: localhost
|
||||
@ -62,67 +72,67 @@
|
||||
- name: Extract isofiles/install.amd/initrd.gz
|
||||
command: gunzip isofiles/install.amd/initrd.gz
|
||||
args:
|
||||
chdir: /opt/ansiblepackages/debianunattended/
|
||||
chdir: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: merge preseed.cfg
|
||||
command: /opt/ansiblepackages/debianunattended/mergepreseed.sh
|
||||
command: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/mergepreseed.sh"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: generate /opt/ansiblepackages/debianunattended/isofiles/late_command.sh
|
||||
- name: generate /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/late_command.sh
|
||||
template:
|
||||
src: late_command.sh.j2
|
||||
mode: "0755"
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/late_command.sh
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/late_command.sh"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: copy authorized_keys file
|
||||
copy:
|
||||
src: files/authorized_keys
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/authorized_keys
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/authorized_keys"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: copy sudoers file
|
||||
copy:
|
||||
src: files/sudoers
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/sudoers
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/sudoers"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: compress isofiles/install.amd/initrd
|
||||
command: gzip isofiles/install.amd/initrd
|
||||
args:
|
||||
chdir: /opt/ansiblepackages/debianunattended/
|
||||
chdir: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set permissions
|
||||
file:
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/install.amd/
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/install.amd/"
|
||||
mode: -w
|
||||
recurse: yes
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set permissions
|
||||
file:
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/md5sum.txt
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/md5sum.txt"
|
||||
mode: +w
|
||||
delegate_to: localhost
|
||||
|
||||
- name: generate md5sums
|
||||
command: /opt/ansiblepackages/debianunattended/md5sum.sh
|
||||
command: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/md5sum.sh"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set permissions
|
||||
file:
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/md5sum.txt
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/md5sum.txt"
|
||||
mode: -w
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set permissions
|
||||
file:
|
||||
dest: /opt/ansiblepackages/debianunattended/isofiles/isolinux/isolinux.bin
|
||||
dest: "/opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles/isolinux/isolinux.bin"
|
||||
mode: +w
|
||||
delegate_to: localhost
|
||||
|
||||
- name: genisoimage
|
||||
command: "genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o {{ playbook_dir }}/debian-11.3.0-amd64-netinst-unattended-{{ inventory_hostname }}.iso /opt/ansiblepackages/debianunattended/isofiles"
|
||||
command: "genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o {{ playbook_dir }}/debian-11.4.0-amd64-netinst-unattended-{{ inventory_hostname }}.iso /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}/isofiles"
|
||||
delegate_to: localhost
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd /opt/ansiblepackages/debianunattended
|
||||
cd /opt/ansiblepackages/debianunattended/{{ inventory_hostname }}
|
||||
echo preseed.cfg | cpio -H newc -o -A -F isofiles/install.amd/initrd
|
Loading…
Reference in New Issue
Block a user