summaryrefslogtreecommitdiff
path: root/roles/openwrt/image/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/openwrt/image/tasks')
-rw-r--r--roles/openwrt/image/tasks/fetch.yml57
-rw-r--r--roles/openwrt/image/tasks/main.yml65
-rw-r--r--roles/openwrt/image/tasks/prepare.yml110
3 files changed, 0 insertions, 232 deletions
diff --git a/roles/openwrt/image/tasks/fetch.yml b/roles/openwrt/image/tasks/fetch.yml
deleted file mode 100644
index 1dc5728d..00000000
--- a/roles/openwrt/image/tasks/fetch.yml
+++ /dev/null
@@ -1,57 +0,0 @@
----
-- name: Create download directory
- file:
- dest: "{{ openwrt_download_dir }}"
- state: directory
-
-- name: download the openwrt image builder
- block:
- - name: Generate OpenWrt download URLs
- set_fact:
- openwrt_url:
- https://downloads.openwrt.org/releases/{{ openwrt_release }}/targets/{{ openwrt_arch | mandatory }}/{{ openwrt_target }}
-
- - name: Download sha256sums
- get_url:
- url: "{{ openwrt_url }}/sha256sums"
- dest: "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
-
- - name: Download sha256sums.asc
- get_url:
- url: "{{ openwrt_url }}/sha256sums.asc"
- dest: "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
-
- - name: Check OpenPGP signature
- command: >-
- gpgv --keyring "{{ global_files_dir }}/common/keyrings/openwrt-{{ [0, 1] | map('extract', (openwrt_release | split('.'))) | join('.') }}.gpg"
- "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc" "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
- changed_when: False
- register: openwrt_image_gpg_result
-
- - debug:
- var: openwrt_image_gpg_result.stderr_lines
-
- - name: Extract SHA256 hash of the imagebuilder archive
- command: grep '{{ openwrt_tarball_name }}' "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
- changed_when: False
- register: sha256
-
- - name: Download imagebuilder
- get_url:
- url: "{{ openwrt_url }}/{{ openwrt_tarball_name }}"
- dest: "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
- checksum: sha256:{{ sha256.stdout.split(' ') | first }}
-
- rescue:
- - name: Delete downloaded artifacts
- loop:
- - "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
- - "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
- - "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
- file:
- path: "{{ item }}"
- state: absent
-
- - name: the download has failed...
- fail:
- msg: Something borked
diff --git a/roles/openwrt/image/tasks/main.yml b/roles/openwrt/image/tasks/main.yml
deleted file mode 100644
index 5bf07d04..00000000
--- a/roles/openwrt/image/tasks/main.yml
+++ /dev/null
@@ -1,65 +0,0 @@
----
-- name: fetch imagebuilder
- when: openwrt_imgbuilder_tarball is not defined
- run_once: true
- import_tasks: fetch.yml
-
-- name: build the image
- block:
- - import_tasks: prepare.yml
-
- - name: Create the output directory for built images
- file:
- path: "{{ openwrt_output_dir }}"
- state: directory
-
- - name: generate list of packages to add or remove
- set_fact:
- openwrt_packages: >-
- {{ openwrt_packages_remove | map('regex_replace', '^', '-') | join(' ') }}
- {{ openwrt_packages_add | join(' ') }}
- {{ openwrt_packages_extra | join(' ') }}
-
- - 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 }}"
- {% if openwrt_extra_name is defined %} EXTRA_IMAGE_NAME="{{ openwrt_extra_name }}" {% endif %}
- {% if openwrt_rootfs_partsize is defined %} ROOTFS_PARTSIZE="{{ openwrt_rootfs_partsize }}" {% endif %}
- register: openwrt_build
-
- - name: Copy newly built OpenWrt image
- loop: "{{ 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 }}"
-
- - name: set output image names
- set_fact:
- output_images: "{{ [(openwrt_output_dir, openwrt_output_image_name_base) | path_join | realpath] | product(openwrt_output_image_suffixes) | map('join', '-') }}"
-
- always:
- - name: save stdout build-log to output directory
- when: openwrt_build is defined
- copy:
- content: "{{ openwrt_build.stdout }}\n"
- dest: "{{ openwrt_output_dir }}/build-stdout.log"
-
- - name: save stderr build-log to output directory
- when: openwrt_build is defined
- copy:
- content: "{{ openwrt_build.stderr }}\n"
- dest: "{{ openwrt_output_dir }}/build-stderr.log"
-
- - name: delete the temporary build directory
- when: not openwrt_keep_temporary_build_dir
- file:
- path: "{{ openwrt_imgbuilder_dir }}"
- state: absent
-
- - name: print temporary build directory information
- when: openwrt_keep_temporary_build_dir
- debug:
- msg: "The temporary build directory has not been deleted, the path to the directory is: {{ openwrt_imgbuilder_dir }}"
diff --git a/roles/openwrt/image/tasks/prepare.yml b/roles/openwrt/image/tasks/prepare.yml
deleted file mode 100644
index f685540c..00000000
--- a/roles/openwrt/image/tasks/prepare.yml
+++ /dev/null
@@ -1,110 +0,0 @@
----
-- name: Create temporary build directory
- tempfile:
- state: directory
- register: tmpdir
-
-- name: set variables needed to build images
- set_fact:
- openwrt_imgbuilder_dir: "{{ tmpdir.path }}"
- openwrt_imgbuilder_files: "{{ tmpdir.path }}/files"
-
-- name: Create the directories for mixins
- loop: "{{ mixin_directories | flatten }}"
- vars:
- mixin_directories:
- - "{{ openwrt_download_dir }}/dl/{{ openwrt_arch }}"
- - "{{ openwrt_imgbuilder_files }}/etc/config"
- - "{{ openwrt_mixin | map('dirname') | map('regex_replace', '^', openwrt_imgbuilder_files) | unique | list }}"
- file:
- path: "{{ item }}"
- state: directory
- mode: '0755'
-
-
-- name: Copy mixins in place [1/3]
- loop: "{{ openwrt_mixin | dict2items | selectattr('value.link', 'defined') | list }}"
- loop_control:
- label: "{{ item.key }}"
- file:
- dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
- src: "{{ item.value.link }}"
- force: yes
- follow: no
- state: link
-
-- name: Copy mixins in place [2/3]
- loop: "{{ openwrt_mixin | dict2items | selectattr('value.file', 'defined') | list }}"
- loop_control:
- label: "{{ item.key }}"
- copy:
- src: "{{ item.value.file }}"
- dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
- mode: "{{ item.value.mode | default('0644') }}"
-
-- name: Copy mixins in place [3/3]
- loop: "{{ openwrt_mixin | dict2items | selectattr('value.content', 'defined') | list }}"
- loop_control:
- label: "{{ item.key }}"
- copy:
- content: "{{ item.value.content }}"
- dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
- mode: "{{ item.value.mode | default('0644') }}"
-
-- name: Generate /etc/fstab
- when: openwrt_mounts is defined
- loop: "{{ openwrt_mounts }}"
- loop_control:
- label: "{{ item.path }}"
- mount:
- fstab: "{{ openwrt_imgbuilder_files }}/etc/fstab"
- state: present
- src: "{{ item.src | default(omit) }}"
- path: "{{ item.path | default(omit) }}"
- fstype: "{{ item.fstype | default(omit) }}"
- opts: "{{ item.opts | default(omit) }}"
- boot: "{{ item.boot | default(omit) }}"
- dump: "{{ item.dump | default(omit) }}"
- passno: "{{ item.passno | default(omit) }}"
-
-
-- name: Create UCI configuration files
- loop: "{{ openwrt_uci | dict2items }}"
- loop_control:
- label: "{{ item.key }}"
- template:
- src: uci.j2
- dest: "{{ openwrt_imgbuilder_files }}/etc/config/{{ item.key }}"
- mode: 0644
- trim_blocks: yes
-# force: no ## TODO: fail when overwriting a file
-
-- name: Create /etc/passwd
- when: openwrt_users is defined
- template:
- src: passwd.j2
- dest: "{{ openwrt_imgbuilder_files }}/etc/passwd"
- mode: 0644
- trim_blocks: yes
-
-- name: Create /etc/group
- when: openwrt_groups is defined or openwrt_users is defined
- template:
- src: group.j2
- dest: "{{ openwrt_imgbuilder_files }}/etc/group"
- mode: 0644
- trim_blocks: yes
-
-- name: extract image builder tarball
- environment: ### TODO: remove once this lands in ansible: https://github.com/ansible/ansible/pull/76542
- LANGUAGE: en_US.utf8
- unarchive:
- src: "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
- remote_src: yes
- dest: "{{ openwrt_imgbuilder_dir }}"
-
-- name: Symlink the cache repository
- file:
- state: link
- src: "{{ openwrt_download_dir }}/dl/{{ openwrt_arch }}"
- path: "{{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }}/dl"