blob: c2425c3b918ead48e847dc4481a8259962145a2a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
---
- 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 }}"
loop_control:
label: "{{ item.key }}"
file:
dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
src: "{{ item.value.link }}"
force: yes
follow: no
state: link
when: '"link" in item.value'
- name: Copy mixins in place [2/3]
loop: "{{ openwrt_mixin | dict2items }}"
loop_control:
label: "{{ item.key }}"
copy:
src: "{{ item.value.file }}"
dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
mode: "{{ item.value.mode | default('0644') }}"
when: '"file" in item.value'
- name: Copy mixins in place [3/3]
loop: "{{ openwrt_mixin | dict2items }}"
loop_control:
label: "{{ item.key }}"
copy:
content: "{{ item.value.content }}"
dest: "{{ openwrt_imgbuilder_files }}/{{ item.key }}"
mode: "{{ item.value.mode | default('0644') }}"
when: '"content" in item.value'
- name: Generate /etc/fstab
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) }}"
when: openwrt_mounts is defined
- 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
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: extract image builder tarball
unarchive:
copy: False
src: "{{ openwrt_download_dir }}/{{ openwrt_release }}/{{ 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"
|