ansible: copy resulting openwrt image to correct location
[noc.git] / ansible / roles / openwrt-image / tasks / main.yml
1 ---
2 - include: fetch.yml
3   when: openwrt_imgbuilder_tarball is not defined
4
5 - block:
6     - include: prepare.yml
7
8     - name: Create the output directory for built images
9       file:
10         path: "{{ openwrt_output_dir }}"
11         state: directory
12
13     - set_fact:
14         openwrt_packages: >-
15           {{ openwrt_packages_remove | map('regex_replace', '^', '-') | join(' ') }}
16           {{ openwrt_packages_add   | join(' ') }}
17           {{ openwrt_packages_extra | join(' ') }}
18
19     - name: Build the OpenWrt image
20       command: >-
21         make -C {{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }} image
22           FILES="{{ openwrt_imgbuilder_files }}"
23           PACKAGES="{{ openwrt_packages }}"
24           {% if openwrt_extra_name is defined %} EXTRA_IMAGE_NAME="{{ openwrt_extra_name }}" {% endif %}
25
26     - name: Copy newly built OpenWrt image
27       with_items: "{{ openwrt_output_image_suffixes }}"
28       copy:
29         src: "{{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }}/bin/targets/{{ openwrt_arch }}/{{ openwrt_target }}/{{ openwrt_output_image_name_base }}-{{ item }}"
30         dest: "{{ openwrt_output_dir }}"
31
32   always:
33     - name: Delete the temporary build directory
34       file:
35         path: "{{ openwrt_imgbuilder_dir }}"
36         state: absent