ansible: Use clearer variable names in install-related roles
[noc.git] / ansible / roles / preseed / tasks / main.yml
1 - block:
2     - name: Make a temporary directory
3       command: mktemp -d
4       register: tmpdir
5
6     - set_fact:
7         tmpdir: "{{ tmpdir.stdout }}"
8         initramfs: "{{ preseed_path | mandatory }}/{{ hostname }}-{{ install_distro }}-{{ install_codename }}.initrd.gz"
9
10     - name: Copy initramfs into position
11       copy:
12         remote_src: yes
13         src: "{{ debian_installer_path | mandatory }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/initrd.gz"
14         dest: "{{ initramfs }}"
15
16     - name: Generate preseed file
17       template:
18         src: "preseed_{{ install_distro }}-{{ install_codename }}.cfg.j2"
19         dest: "{{ tmpdir }}/preseed.cfg"
20
21     - name: Generate authorized_keys file
22       authorized_key:
23         user: root
24         manage_dir: no
25         path: "{{ tmpdir }}/authorized_keys"
26         key: "{{ ssh_keys | join('\n') }}"
27
28     - name: Inject files into initramfs
29       shell: cpio -H newc -o | gzip -9 >> '{{ initramfs }}'
30       args:
31         chdir: "{{ tmpdir }}"
32         stdin: |
33           preseed.cfg
34           authorized_keys
35
36   always:
37     - name: Delete temporary directory
38       file:
39         path: "{{ tmpdir }}"
40         state: absent