blob d6362f70a753516d05f412a8fd6e44e386479dee 6022 bytes (raw)
name: gnu/services/cloud-init.scm # note: path name is non-authoritative(*)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
| | (define-module (gnu services cloud-init)
#:use-module (gnu packages bash)
#:use-module (gnu packages python-web)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (guix gexp)
#:use-module (guix records)
#:export (cloud-init-configuration cloud-init-service
cloud-init-service-type))
(define-record-type* <cloud-init-configuration> cloud-init-configuration
make-cloud-init-configuration
cloud-init-configuration?
(cloud-init cloud-init-configuration-cloud-init ;file-like
(default python-cloud-init))
(init-modules cloud-init-configuration-init-modules ;list of symbols
(default '(seed_random growpart
resizefs
disk_setup
mounts
set_hostname
update_hostname
users_groups
ssh
set_passwords)))
(config-modules cloud-init-configuration-config-modules ;list of symbols
(default '()))
(final-modules cloud-init-configuration-final-modules ;list of symbols
(default '(ssh_authkey_fingerprints)))
(extra-configuration-files
cloud-init-configuration-extra-configuration-files ;list of file-likes
(default '())))
(define %cloud-dir
"/etc/cloud")
(define %cloud-cfg
(string-append %cloud-dir "/cloud.cfg"))
(define %cloud-run
(mixed-text-file "run.sh"
"#!"
(file-append bash "/bin/bash")
"\n\nset -euo pipefail\n\n"
(file-append python-cloud-init "/bin/cloud-init")
" init --local\n"
(file-append python-cloud-init "/bin/cloud-init")
" init\n"
(file-append python-cloud-init "/bin/cloud-init")
" modules --mode config\n"
(file-append python-cloud-init "/bin/cloud-init")
" modules --mode final\n"))
(define %cloud-cfg-d
(string-append %cloud-dir "/cloud.cfg.d"))
(define (cloud-init-initialization init-modules config-modules final-modules
extra)
"Return the gexp to initialize the cloud-init configuration files"
#~(begin
(use-modules (srfi srfi-1)
(srfi srfi-2)
(guix build utils))
(define reduce-modules
(lambda (mods)
(string-join (map (lambda (mod)
(string-append "\n - "
(symbol->string mod))) mods))))
(mkdir-p #$%cloud-cfg-d)
(copy-file #$%cloud-run
(string-append #$%cloud-dir "/run.sh"))
(chmod (string-append #$%cloud-dir "/run.sh") #o755)
(unless (null? '(#$@extra))
(for-each (lambda (file)
(symlink (cadr file)
(string-append #$%cloud-cfg-d "/"
(car file))))
'(#$@extra)))
(call-with-output-file #$%cloud-cfg
(lambda (p)
(unless (null? '(#$@init-modules))
(display (string-append "cloud_init_modules:"
(reduce-modules '(#$@init-modules)) "\n\n")
p))
(unless (null? '(#$@config-modules))
(display (string-append "cloud_config_modules:"
(reduce-modules '(#$@config-modules))
"\n\n") p))
(unless (null? '(#$@final-modules))
(display (string-append "cloud_final_modules:"
(reduce-modules '(#$@final-modules))
"\n\n") p))))))
(define (cloud-init-activation config)
"Return the activation gexp for CONFIG."
#~(begin
(use-modules (guix build utils))
#$(cloud-init-initialization (cloud-init-configuration-init-modules
config)
(cloud-init-configuration-config-modules
config)
(cloud-init-configuration-final-modules
config)
(cloud-init-configuration-extra-configuration-files
config))))
(define (cloud-init-service config)
"Return a <cloud-init-service> for cloud-init with CONFIG."
(define cloud-init
(cloud-init-configuration-cloud-init config))
(list (shepherd-service (documentation "cloud-init service")
(provision '(cloud-init))
(requirement '(networking))
(one-shot? #t)
(start #~(fork+exec-command (list (string-append #$%cloud-dir
"/run.sh"))
#:log-file (string-append
"/var/log/cloud-init.log")
#:environment-variables '
("PATH=/run/current-system/profile/bin:/run/current-system/profile/sbin:"))))))
(define cloud-init-service-type
(service-type (name 'cloud-init)
(default-value (cloud-init-configuration))
(description "cloud init")
(extensions (list (service-extension
shepherd-root-service-type
cloud-init-service)
(service-extension activation-service-type
cloud-init-activation)))))
|
debug log:
solving d6362f70a7 ...
found d6362f70a7 in https://yhetil.org/guix/c907e459d6898df885e3aac67c8446a1c15d62b2.1731824739.git.alex@infiniteadaptability.org/
applying [1/1] https://yhetil.org/guix/c907e459d6898df885e3aac67c8446a1c15d62b2.1731824739.git.alex@infiniteadaptability.org/
diff --git a/gnu/services/cloud-init.scm b/gnu/services/cloud-init.scm
new file mode 100644
index 0000000000..d6362f70a7
Checking patch gnu/services/cloud-init.scm...
Applied patch gnu/services/cloud-init.scm cleanly.
index at:
100644 d6362f70a753516d05f412a8fd6e44e386479dee gnu/services/cloud-init.scm
(*) Git path names are given by the tree(s) the blob belongs to.
Blobs themselves have no identifier aside from the hash of its contents.^
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.