summaryrefslogtreecommitdiff
path: root/roles/preseed/tasks/main.yml
blob: c32a032e5506ec6c7d23e56013da5d26004293aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- name: Copy initramfs into position
  copy:
    remote_src: yes
    src: "{{ debian_installer_path | mandatory }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/initrd.gz"
    dest: "{{ preseed_tmpdir }}/initrd.preseed.gz"

- name: Generate preseed file
  template:
    src: "preseed_{{ hostvars[hostname].preseed_template_name | default(install_distro + '-' + install_codename) }}.cfg.j2"
    dest: "{{ preseed_tmpdir }}/preseed.cfg"

- name: Generate authorized_keys file
  authorized_key:
    user: root
    manage_dir: no
    path: "{{ preseed_tmpdir }}/authorized_keys"
    key: "{{ ssh_keys_root | join('\n') }}"

## TODO: make this nicer (only needed für debian buster? does it work with others too?)
- file:
    path: "{{ preseed_tmpdir }}/etc/systemd/network"
    state: directory
- copy:
    dest: "{{ preseed_tmpdir }}/etc/systemd/network/90-namepolicy-path.link"
    content: |
      [Link]
      NamePolicy=path

- name: Inject files into initramfs
  shell: cpio -H newc -o | gzip -9 >> 'initrd.preseed.gz'
  args:
    chdir: "{{ preseed_tmpdir }}"
    stdin: |
      preseed.cfg
      authorized_keys
      etc/
      etc/systemd/
      etc/systemd/network/
      etc/systemd/network/90-namepolicy-path.link
  tags:
  - skip_ansible_lint