Skip to content

Commit 0ff136d

Browse files
authored
Packaging: Add conf files to deb/rpm packages (#6330)
2 parents c9d9e30 + ae649f9 commit 0ff136d

File tree

11 files changed

+181
-3
lines changed

11 files changed

+181
-3
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Added
8080
#6118 #6141 #6133 #6120 #6181 #6183 #6200 #6237 #6229 #6240 #6241 #6244 #6251 #6253
8181
#6254 #6258 #6259 #6260 #6269 #6275 #6279 #6278 #6282 #6283 #6273 #6287 #6306 #6307
8282
#6311 #6314 #6315 #6317 #6319 #6312 #6320 #6321 #6323 #6324 #6325 #6326 #6327 #6328
83-
#6329
83+
#6329 #6330
8484
Contributed by @cognifloyd
8585
* Build of ST2 EL9 packages #6153
8686
Contributed by @amanda11

conf/BUILD

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,55 @@ file(
5757
name="st2_package_conf",
5858
source="st2.package.conf",
5959
)
60+
61+
shell_command(
62+
name="htpasswd",
63+
description="An empty htpasswd file for st2-auth-backend-flat-file",
64+
command="touch htpasswd",
65+
tools=["touch"],
66+
output_files=["htpasswd"],
67+
)
68+
69+
shell_command(
70+
name="packaged_st2_conf",
71+
execution_dependencies=[":st2_package_conf"],
72+
# virtualenv_opts is no longer needed for most OSes. We used to do this only for EL 8.
73+
command="""crudini --verbose --set st2.package.conf actionrunner virtualenv_opts ''""",
74+
runnable_dependencies=["//:crudini"],
75+
output_files=["st2.package.conf"],
76+
)
77+
78+
nfpm_content_files(
79+
name="packaged_conf_files",
80+
dependencies=[
81+
":packaged_st2_conf",
82+
":logrotate",
83+
":nginx_sample_config",
84+
":htpasswd",
85+
],
86+
files=[
87+
("st2.package.conf", "/etc/st2/st2.conf"),
88+
("logrotate.conf", "/etc/logrotate.d/st2"),
89+
("nginx/st2.conf", "/usr/share/doc/st2/conf/nginx/st2.conf"),
90+
("htpasswd", "/etc/st2/htpasswd"),
91+
],
92+
content_type="config|noreplace",
93+
file_owner="root",
94+
file_group="root",
95+
file_mode="rw-r--r--",
96+
overrides={
97+
"/etc/st2/st2.conf": dict(
98+
# st2.conf typically contains secrets, so it is not world readable.
99+
file_mode="rw-r-----", # NOTE: Packaging used to install this world readable.
100+
# TODO: Maybe set file_group=ST2_SVC_USER if a non-root process needs access.
101+
),
102+
"/etc/st2/htpasswd": dict(
103+
file_owner=ST2_SVC_USER,
104+
file_group=ST2_SVC_USER,
105+
file_mode="rw-------",
106+
),
107+
"/usr/share/doc/st2/conf/nginx/st2.conf": dict(
108+
content_type="",
109+
),
110+
},
111+
)

packaging/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ nfpm_deb_package(
4545
"./deb/scripts",
4646
"./deb/systemd:services",
4747
"./common/systemd:generators",
48+
"./common:conf_files",
4849
"./common:dirs",
4950
"./common:symlinks",
5051
*_st2_venv_deps(),
@@ -80,6 +81,7 @@ nfpm_rpm_package(
8081
"./rpm/scripts",
8182
"./rpm/systemd:services",
8283
"./common/systemd:generators",
84+
"./common:conf_files",
8385
"./common:dirs",
8486
"./common:symlinks",
8587
*_st2_venv_deps(),

packaging/common/BUILD

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
nfpm_content_dirs(
22
name="root_dirs",
33
dirs=[
4-
# "/etc/bash_completion.d",
5-
# "/etc/logrotate.d",
64
"/etc/st2",
75
"/opt/stackstorm",
86
"/opt/stackstorm/st2",
@@ -71,3 +69,16 @@ nfpm_content_symlinks(
7169
file_owner="root",
7270
file_group="root",
7371
)
72+
73+
target(
74+
name="conf_files",
75+
dependencies=[
76+
"//conf:packaged_conf_files",
77+
"//st2actions/conf:packaged_conf_files",
78+
"//st2api/conf:packaged_conf_files",
79+
"//st2auth/conf:packaged_conf_files",
80+
"//st2client/conf:packaged_bash_completion",
81+
"//st2reactor/conf:packaged_conf_files",
82+
"//st2stream/conf:packaged_conf_files",
83+
],
84+
)

pants-plugins/macros.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,32 @@ def st2_logging_conf_resources(**kwargs):
226226
deps = list(deps) + list(_st2common_logging_deps)
227227
kwargs["dependencies"] = tuple(deps)
228228
resources(**kwargs) # noqa: F821
229+
230+
231+
def st2_logging_conf_for_nfpm(**kwargs):
232+
deps = kwargs.pop("dependencies") or []
233+
234+
shell_command( # noqa: F821
235+
name="package_logging_conf",
236+
execution_dependencies=deps,
237+
# Using "-E" and specifying the ".bak" suffix makes this portable
238+
command="""
239+
sed -E -i.bak "/args[[:space:]]*=[[:space:]]*/s:logs/:/var/log/st2/:g" logging.*conf;
240+
for conf_file in logging.*conf syslog.*conf; do
241+
crudini --verbose --set "${conf_file}" logger_root level INFO;
242+
done
243+
""",
244+
runnable_dependencies=["//:crudini"],
245+
tools=["sed"],
246+
output_files=["*.conf"],
247+
)
248+
249+
nfpm_content_files( # noqa: F821
250+
name="packaged_conf_files",
251+
dependencies=[":package_logging_conf"],
252+
file_owner="root",
253+
file_group="root",
254+
file_mode="rw-r--r--",
255+
content_type="config|noreplace",
256+
**kwargs,
257+
)

st2actions/conf/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,20 @@ st2_logging_conf_files(
2121
name="logging_syslog",
2222
sources=["syslog*.conf"],
2323
)
24+
25+
st2_logging_conf_for_nfpm(
26+
dependencies=[
27+
":logging",
28+
":logging_syslog",
29+
],
30+
files=[
31+
("logging.conf", "/etc/st2/logging.actionrunner.conf"),
32+
("syslog.conf", "/etc/st2/syslog.actionrunner.conf"),
33+
("logging.notifier.conf", "/etc/st2/logging.notifier.conf"),
34+
("syslog.notifier.conf", "/etc/st2/syslog.notifier.conf"),
35+
("logging.scheduler.conf", "/etc/st2/logging.scheduler.conf"),
36+
("syslog.scheduler.conf", "/etc/st2/syslog.scheduler.conf"),
37+
("logging.workflowengine.conf", "/etc/st2/logging.workflowengine.conf"),
38+
("syslog.workflowengine.conf", "/etc/st2/syslog.workflowengine.conf"),
39+
],
40+
)

st2api/conf/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ st2_logging_conf_file(
1919
name="logging_syslog",
2020
source="syslog.conf",
2121
)
22+
23+
st2_logging_conf_for_nfpm(
24+
dependencies=[
25+
":logging",
26+
":logging_gunicorn",
27+
":logging_syslog",
28+
],
29+
files=[
30+
("logging.conf", "/etc/st2/logging.api.conf"),
31+
("logging.gunicorn.conf", "/etc/st2/logging.api.gunicorn.conf"),
32+
("syslog.conf", "/etc/st2/syslog.api.conf"),
33+
],
34+
)

st2auth/conf/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ st2_logging_conf_file(
2929
name="logging_syslog",
3030
source="syslog.conf",
3131
)
32+
33+
st2_logging_conf_for_nfpm(
34+
dependencies=[
35+
":logging",
36+
":logging_gunicorn",
37+
":logging_syslog",
38+
],
39+
files=[
40+
("logging.conf", "/etc/st2/logging.auth.conf"),
41+
("logging.gunicorn.conf", "/etc/st2/logging.auth.gunicorn.conf"),
42+
("syslog.conf", "/etc/st2/syslog.auth.conf"),
43+
],
44+
)

st2client/conf/BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
shell_sources()
2+
3+
nfpm_content_file(
4+
name="packaged_bash_completion",
5+
dependencies=["./st2.complete.sh"],
6+
src="st2.complete.sh",
7+
dst="/etc/bash_completion.d/st2",
8+
content_type="config",
9+
file_owner="root",
10+
file_group="root",
11+
file_mode="rwxr-xr-x",
12+
)

st2reactor/conf/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,20 @@ st2_logging_conf_files(
1313
name="logging_syslog",
1414
sources=["syslog*.conf"],
1515
)
16+
17+
st2_logging_conf_for_nfpm(
18+
dependencies=[
19+
":logging",
20+
":logging_syslog",
21+
],
22+
files=[
23+
("logging.garbagecollector.conf", "/etc/st2/logging.garbagecollector.conf"),
24+
("syslog.garbagecollector.conf", "/etc/st2/syslog.garbagecollector.conf"),
25+
("logging.rulesengine.conf", "/etc/st2/logging.rulesengine.conf"),
26+
("syslog.rulesengine.conf", "/etc/st2/syslog.rulesengine.conf"),
27+
("logging.sensorcontainer.conf", "/etc/st2/logging.sensorcontainer.conf"),
28+
("syslog.sensorcontainer.conf", "/etc/st2/syslog.sensorcontainer.conf"),
29+
("logging.timersengine.conf", "/etc/st2/logging.timersengine.conf"),
30+
("syslog.timersengine.conf", "/etc/st2/syslog.timersengine.conf"),
31+
],
32+
)

0 commit comments

Comments
 (0)