*.retry
.*.sw?
/.cache/
+/files/
---
+openwrt_variant: lede
openwrt_release: 17.01.4
openwrt_download_dir: .cache/openwrt
-openwrt_tarball_basename: lede-imagebuilder-{{ openwrt_release }}-{{ openwrt_arch }}{% if openwrt_target != 'generic' %}-{{ openwrt_target }}{% endif %}.Linux-x86_64
+openwrt_tarball_basename: "{{ openwrt_variant }}-imagebuilder-{{ openwrt_release }}-{{ openwrt_arch }}{% if openwrt_target != 'generic' %}-{{ openwrt_target }}{% endif %}.Linux-x86_64"
openwrt_tarball_name: "{{ openwrt_tarball_basename }}.tar.xz"
openwrt_target: generic
-openwrt_output_dir: files/openwrt
+openwrt_output_dir: files/openwrt/{{ inventory_hostname }}
+openwrt_output_image_name_base: "{{ openwrt_variant }}-{{ openwrt_release }}-{{ openwrt_arch }}{% if openwrt_target != 'generic' %}-{{ openwrt_target }}{% endif %}"
+openwrt_output_image_suffixes:
+ - squashfs-sysupgrade.bin
+ - squashfs-factory.bin
openwrt_packages_remove: []
openwrt_packages_add: []
+++ /dev/null
----
-- name: Create download directory
- file:
- dest: "{{ openwrt_download_dir }}"
- state: directory
-
-- 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: gpg --verify "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
- changed_when: False
-
- - name: Extract SHA256 hash of the imagebuilder archive
- command: grep '{{ openwrt_tarball_name }}' "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
- register: sha256
- changed_when: False
-
- - name: Download imagebuilder
- get_url:
- url: "{{ openwrt_url }}/{{ openwrt_tarball_name }}" #lede-imagebuilder-{{ openwrt_release }}-{{ openwrt_arch }}.Linux-x86_64.tar.xz"
- dest: "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
- checksum: sha256:{{ sha256.stdout.split(' ') | first }}
-
- # /!\ This needs to be the last task in 00-fetch.yml
-# - set_fact:
-# openwrt_imgbuilder_tarball: >
-# {{ openwrt_download_dir }}/{{ openwrt_tarball_name }}
-
- rescue:
- - name: Delete downloaded artifacts
- file:
- path: "{{ item }}"
- state: absent
- with_items:
- - "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
- - "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
- - "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
- - fail:
- msg: Something borked
--- /dev/null
+---
+- name: Create download directory
+ file:
+ dest: "{{ openwrt_download_dir }}"
+ state: directory
+
+- 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: gpg --verify "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
+ changed_when: False
+
+ - name: Extract SHA256 hash of the imagebuilder archive
+ command: grep '{{ openwrt_tarball_name }}' "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
+ register: sha256
+ changed_when: False
+
+ - 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
+ file:
+ path: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256"
+ - "{{ openwrt_download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
+ - "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}"
+ - fail:
+ msg: Something borked
---
-- include: 00-fetch.yml
+- include: fetch.yml
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:
make -C {{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }} image
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
--- /dev/null
+---
+- name: Create temporary build directory
+ command: mktemp --tmpdir -d openwrt-{{ inventory_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 }}"
+
+### TODO: this just hangs?
+# - 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 }}"
vars:
openwrt_arch: x86
openwrt_target: geode
+ openwrt_output_image_suffixes:
+ - combined-ext4.img.gz
+ - combined-squashfs.img
openwrt_packages_remove:
- ppp
- ppp-mod-pppoe
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
-
+
config globals 'globals'
option ula_prefix 'fdc9:e01f:83db::/48'
-
+
config interface 'lan'
option ifname 'eth0'
option accept_ra '0'
option proto 'static'
- option ipaddr '192.168.33.7'
- option netmask '255.255.255.0'
- option gateway '192.168.33.1'
- option dns '192.168.33.1'
- option dns_search 'realraum.at'
+ option ipaddr '192.168.33.7'
+ option netmask '255.255.255.0'
+ option gateway '192.168.33.1'
+ option dns '192.168.33.1'
+ option dns_search 'realraum.at'
/etc/config/dropbear: |
config dropbear
/etc/dropbear/authorized_keys: |-
{% for key in noc_ssh_keys %}
- key
+ {{ key }}
{% endfor %}