fixed renaming of gnocci host_vars directories
[noc.git] / ansible / roles / openwrt-image / tasks / main.yml
index d182a5b..1781d9e 100644 (file)
@@ -1,52 +1,10 @@
 ---
-- include: 00-fetch.yml
+- include: fetch.yml
+  run_once: true
   when: openwrt_imgbuilder_tarball is not defined
 
-- name: Create temporary build directory
-  command: mktemp --tmpdir -d openwrt-{{ ansible_hostname }}.XXXXXX
-  register: tmpdir
-
-- set_fact:
-    openwrt_imgbuilder_dir:   "{{ tmpdir.stdout }}"
-    openwrt_imgbuilder_files: "{{ tmpdir.stdout }}/files"
-
-- name: Create the directories for mixins
-  file:
-    path: "{{ item }}"
-    state: directory
-  with_items:
-    - "{{ openwrt_imgbuilder_files }}"
-    - "{{ openwrt_mixin.files | map('dirname') | map('regex_replace', '^', openwrt_imgbuilder_files) | unique | list }}"
-    - "{{ openwrt_mixin.content | map('dirname') | map('regex_replace', '^', openwrt_imgbuilder_files) | unique | list }}"
-
-- name: Copy mixins in place [1/2]
-  copy:
-    src: "{{ item.value }}"
-    dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
-  with_dict: "{{ openwrt_mixin.files }}"
-  loop_control:
-    label: "{{ item.key }}"
-
-- name: Copy mixins in place [2/2]
-  copy:
-    content: "{{ item.value }}"
-    dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
-  with_dict: "{{ openwrt_mixin.content }}"
-  loop_control:
-    label: "{{ item.key }}"
-
 - block:
-#    - unarchive:
-#        copy: False
-#        src:  "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
-#        dest: "{{ openwrt_imgbuilder_dir }}"
-
-    - name: Decompress the OpenWrt image builder
-      command: >-
-        tar -xf  "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
-            -C   "{{ openwrt_imgbuilder_dir     }}"
-
-#    - include: 02-prepare.yml
+    - include: prepare.yml
 
     - name: Create the output directory for built images
       file:
     - name: Build the OpenWrt image
       command: >-
         make -C {{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }} image
+          {% if openwrt_profile is defined %}PROFILE="{{ openwrt_profile }}" {% endif %}
           FILES="{{ openwrt_imgbuilder_files }}"
           PACKAGES="{{ openwrt_packages }}"
-          BIN_DIR="{{ openwrt_output_dir }}"
           {% if openwrt_extra_name is defined %} EXTRA_IMAGE_NAME="{{ openwrt_extra_name }}" {% endif %}
 
+    - name: Copy newly built OpenWrt image
+      with_items: "{{ openwrt_output_image_suffixes }}"
+      copy:
+        src: "{{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }}/bin/targets/{{ openwrt_arch }}/{{ openwrt_target }}/{{ openwrt_output_image_name_base }}-{{ item }}"
+        dest: "{{ openwrt_output_dir }}"
 
-#  always:
-#    - name: Delete the temporary build directory
-#      file:
-#        path: "{{ openwrt_imgbuilder_dir }}"
-#        state: absent
+  always:
+    - name: Delete the temporary build directory
+      file:
+        path: "{{ openwrt_imgbuilder_dir }}"
+        state: absent