You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/en/docs/Customizing/stages.md
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,19 +14,35 @@ We have a custom augmented cloud-init syntax that allows to hook into various st
14
14
- Network availability
15
15
- During upgrades, installation, deployments , and resets
16
16
17
-
Cloud-init files in `/system/oem`, `/oem` and `/usr/local/oem` are applied in 5 different phases: `boot`, `network`, `fs`, `initramfs` and `reconcile`. All the available cloud-init keywords can be used in each stage. Additionally, it's possible also to hook before or after a stage has run, each one has a specific stage which is possible to run steps: `boot.after`, `network.before`, `fs.after` etc.
17
+
Cloud-init files in `/system/oem`, `/oem`, `/usr/local/oem`, and kernel boot args are applied in 5 different phases: `boot`, `network`, `fs`, `initramfs` and `reconcile`. All the available cloud-init keywords can be used in each stage. Additionally, it's possible also to hook before or after a stage has run, each one has a specific stage which is possible to run steps: `boot.after`, `network.before`, `fs.after` etc.
18
18
19
19
Multiple stages can be specified in a single cloud-init file.
20
20
21
+
File extension name must be *.yaml or *.yml.
22
+
21
23
{{% alert title="Note" %}}
22
-
When a Elemental derivative boots it creates sentinel files in order to allow to execute cloud-init steps programmaticaly.
24
+
When an Elemental derivative boots it creates sentinel files in order to allow executing cloud-init steps programmatically.
23
25
24
26
-`/run/cos/recovery_mode` is being created when booting from the recovery partition
25
27
-`/run/cos/live_mode` is created when booting from the LiveCD
26
28
27
29
To execute a block using the sentinel files you can specify: `if: '[ -f "/run/cos/..." ]'`, see the examples below.
28
30
{{% /alert %}}
29
31
32
+
At every stage, Elemental derivative parse and execute Cloud-init files in the following order:
Copy file name to clipboardExpand all lines: docs/content/en/docs/Reference/cloud_init.md
+80-1Lines changed: 80 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,86 @@ stages:
85
85
The default cloud-config format is split into *stages* (*initramfs*, *boot*, *network*, *initramfs*, *reconcile*, called generically **STAGE_ID** below) [see also stages](../../customizing/stages) that are emitted internally during the various phases by calling `cos-setup STAGE_ID`.
86
86
*steps* (**STEP_NAME** below) defined for each stage are executed in order.
87
87
88
-
Each cloud-config file is loaded and executed only at the apprioriate stage, this allows further components to emit their own stages at the desired time.
88
+
Each cloud-config file is loaded and executed only at the appropriate stage, this allows further components to emit their own stages at the desired time.
89
+
90
+
_Note_:
91
+
- The execution order of multiple `substeps` within a single `step` is not guaranteed, especially whether the `commands` are executed after other substeps. For example:
92
+
```
93
+
stages:
94
+
fs:
95
+
- name: test
96
+
environment_file: /tmp/env_file1
97
+
environment:
98
+
ENV1: this is ENV1
99
+
files:
100
+
- path: /tmp/file1
101
+
content: "this is file1\n"
102
+
directories:
103
+
- path: /tmp/dir1
104
+
users:
105
+
user1:
106
+
passwd: password
107
+
commands:
108
+
- |
109
+
bash -x >> /tmp/log 2>&1 <<'EOF'
110
+
ls -lFd /tmp/env_file1
111
+
printenv ENV1
112
+
ls -lFd /tmp/file1
113
+
ls -lFd /tmp/dir1
114
+
id user1
115
+
EOF
116
+
```
117
+
118
+
You might expect that when the `commands` get executed, all things defined above it has been executed, such as the user1 has been created.
119
+
But it is not. As of now, the output (/tmp/log) is:
120
+
```
121
+
+ ls -lFd /tmp/env_file1
122
+
ls: cannot access '/tmp/env_file1': No such file or directory
123
+
+ printenv ENV1
124
+
this is ENV1
125
+
+ ls -lFd /tmp/file1
126
+
---------- 1 root root 14 Aug 6 07:13 /tmp/file1
127
+
+ ls -lFd /tmp/dir1
128
+
d--------- 2 root root 40 Aug 6 07:13 /tmp/dir1/
129
+
+ id user1
130
+
id: ‘user1’: no such user
131
+
```
132
+
133
+
Therefore, to make sure the order is what you want, you may split the `substeps` into multiple `steps`, for example, split to the following 2 yaml files:
134
+
```
135
+
stages:
136
+
fs:
137
+
- name: test
138
+
environment_file: /tmp/env_file1
139
+
environment:
140
+
ENV1: this is ENV1
141
+
files:
142
+
- path: /tmp/file1
143
+
content: "this is file1\n"
144
+
directories:
145
+
- path: /tmp/dir1
146
+
users:
147
+
user1:
148
+
passwd: password
149
+
```
150
+
and
151
+
```
152
+
stages:
153
+
fs:
154
+
- name: test2
155
+
commands:
156
+
- |
157
+
bash -x >> /tmp/log 2>&1 <<'EOF'
158
+
ls -lFd /tmp/env_file1
159
+
printenv ENV1
160
+
ls -lFd /tmp/file1
161
+
ls -lFd /tmp/dir1
162
+
id user1
163
+
EOF
164
+
```
165
+
166
+
- The name of `steps` and output of `substeps` will be output to system journal log which can be viewed by the command `journalctl -u 'elemental*'`.
167
+
- It is highly recommended to declare the `name` property of *steps*, so that it will be easier to investigate the output of `journalctl -u 'elemental*'` by the name.
89
168
90
169
{{% pageinfo %}}
91
170
The [cloud-init tool](https://github.com/mudler/yip#readme) can be also run standalone, this helps debugging locally and also during development, you can find separate [releases here](https://github.com/mudler/yip/releases).
0 commit comments