tuer: Add AuthorizedKeys script for tuerctl
[noc.git] / ansible / roles / openwrt-image / tasks / prepare.yml
index 29e24cd..e049983 100644 (file)
     path: "{{ item }}"
     state: directory
   with_items:
-    - "{{ openwrt_imgbuilder_files }}"
+    - "{{ 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 }}"
   loop_control:
     label: "{{ item.key }}"
 
+- name: Generate /etc/fstab
+  mount:
+    fstab: "{{ openwrt_imgbuilder_files }}/etc/fstab"
+    state: present
+  args:
+    "{{ item }}"
+  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 }}"
+
+- 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
+
 ### TODO: this just hangs?
 # - unarchive:
 #     copy: False