2 - name: Create temporary build directory
3 command: mktemp --tmpdir -d openwrt-{{ inventory_hostname }}.XXXXXX
7 openwrt_imgbuilder_dir: "{{ tmpdir.stdout }}"
8 openwrt_imgbuilder_files: "{{ tmpdir.stdout }}/files"
10 - name: Create the directories for mixins
15 - "{{ openwrt_imgbuilder_files }}/etc/config"
16 - "{{ openwrt_mixin | map('dirname') | map('regex_replace', '^', openwrt_imgbuilder_files) | unique | list }}"
19 - name: Copy mixins in place [1/2]
21 src: "{{ item.value.file }}"
22 dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
23 mode: "{{ item.value.mode | default('0644') }}"
24 with_dict: "{{ openwrt_mixin }}"
25 when: '"file" in item.value'
27 label: "{{ item.key }}"
29 - name: Copy mixins in place [2/2]
31 content: "{{ item.value.content }}"
32 dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
33 mode: "{{ item.value.mode | default('0644') }}"
34 with_dict: "{{ openwrt_mixin }}"
35 when: '"content" in item.value'
37 label: "{{ item.key }}"
39 - name: Generate /etc/fstab
41 fstab: "{{ openwrt_imgbuilder_files }}/etc/fstab"
45 when: openwrt_mounts is defined
46 with_items: "{{ openwrt_mounts }}"
48 label: "{{ item.path }}"
50 - name: Create UCI configuration files
53 dest: "{{ openwrt_imgbuilder_files }}/etc/config/{{ item.key }}"
56 # force: no ## TODO: fail when overwriting a file
57 with_dict: "{{ openwrt_uci }}"
59 label: "{{ item.key }}"
61 - name: Create /etc/passwd
64 dest: "{{ openwrt_imgbuilder_files }}/etc/passwd"
67 when: openwrt_users is defined
69 - name: Create /etc/group
72 dest: "{{ openwrt_imgbuilder_files }}/etc/group"
75 when: openwrt_groups is defined or openwrt_users is defined
77 ### TODO: this just hangs?
80 # src: "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
81 # dest: "{{ openwrt_imgbuilder_dir }}"
83 - name: Decompress the OpenWrt image builder
85 tar -xf "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
86 -C "{{ openwrt_imgbuilder_dir }}"