X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=ansible%2Froles%2Fopenwrt-image%2Ftasks%2Fprepare.yml;h=b6b67c55ebd9f3de6de70e916380024310a2a7a2;hb=a4afa06c56a7c8e50f9ef94bb2cc1d8bba47a5b6;hp=056daf3e8f9ee3c6cc59cb0160ae9718fad67ff8;hpb=3751b141f2abac4c5e2d188846966bef7d4f3eff;p=noc.git diff --git a/ansible/roles/openwrt-image/tasks/prepare.yml b/ansible/roles/openwrt-image/tasks/prepare.yml index 056daf3..b6b67c5 100644 --- a/ansible/roles/openwrt-image/tasks/prepare.yml +++ b/ansible/roles/openwrt-image/tasks/prepare.yml @@ -11,35 +11,84 @@ file: path: "{{ item }}" state: directory + mode: '0755' with_items: - - "{{ openwrt_imgbuilder_files }}" + - "{{ openwrt_download_dir }}/dl/{{ openwrt_arch }}" + - "{{ openwrt_imgbuilder_files }}/etc/config" - "{{ openwrt_mixin | map('dirname') | map('regex_replace', '^', openwrt_imgbuilder_files) | unique | list }}" + - name: Copy mixins in place [1/2] copy: - src: "{{ item.file }}" + src: "{{ item.value.file }}" dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}" + mode: "{{ item.value.mode | default('0644') }}" with_dict: "{{ openwrt_mixin }}" - when: '"file" in item' + when: '"file" in item.value' loop_control: label: "{{ item.key }}" - name: Copy mixins in place [2/2] copy: - content: "{{ item.value }}" + content: "{{ item.value.content }}" dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}" + mode: "{{ item.value.mode | default('0644') }}" with_dict: "{{ openwrt_mixin }}" - when: '"content" in item' + when: '"content" in item.value' + loop_control: + label: "{{ item.key }}" + +- name: Generate /etc/fstab + 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) }}" + when: openwrt_mounts is defined + with_items: "{{ openwrt_mounts }}" + loop_control: + label: "{{ item.path }}" + + +- name: Create UCI configuration files + 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 + with_dict: "{{ openwrt_uci }}" loop_control: label: "{{ item.key }}" -### TODO: this just hangs? -# - unarchive: -# copy: False -# src: "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}" -# dest: "{{ openwrt_imgbuilder_dir }}" +- name: Create /etc/passwd + template: + src: passwd.j2 + dest: "{{ openwrt_imgbuilder_files }}/etc/passwd" + mode: 0644 + trim_blocks: yes + when: openwrt_users is defined + +- name: Create /etc/group + template: + src: group.j2 + dest: "{{ openwrt_imgbuilder_files }}/etc/group" + mode: 0644 + trim_blocks: yes + when: openwrt_groups is defined or openwrt_users is defined -- name: Decompress the OpenWrt image builder - command: >- - tar -xf "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}" - -C "{{ openwrt_imgbuilder_dir }}" +- unarchive: + copy: False + src: "{{ openwrt_download_dir }}/{{ openwrt_tarball_name }}" + 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"