Skip to content

Commit

Permalink
Fixes #35378- Add systemd first boot service for host provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Dyrkon committed Apr 4, 2023
1 parent 56fe651 commit dbba291
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ sed -e 's/DEFAULTKERNEL=kernel-uek/DEFAULTKERNEL=kernel/g' -i /etc/sysconfig/ker

<%= snippet 'insights' if host_param_true?('host_registration_insights') && os_major < 9 -%>

<%= snippet 'first_boot_setup' %>

touch /tmp/foreman_built

chvt 1
Expand All @@ -384,7 +386,6 @@ The last post section halts Anaconda to prevent endless loop in case HTTP reques

if test -f /tmp/foreman_built; then
echo "calling home: build is done!"
<%= indent(2, skip1: true) { snippet('built', :variables => { :endpoint => 'built', :method => 'POST', :body_file => '/root/install.post.log' }) } -%>
else
echo "calling home: build failed!"
<%= indent(2, skip1: true) { snippet('built', :variables => { :endpoint => 'failed', :method => 'POST', :body_file => '/root/install.post.log' }) } -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%#
kind: snippet
name: first_boot_setup
model: ProvisioningTemplate
snippet: true
description: |
Post replacement.
-%>
<%= save_to_file('/etc/systemd/system/first_boot_setup_service.service',
snippet('first_boot_setup_service')) %>
<%= save_to_file('/root/fist_boot_setup_script.sh',
snippet('first_boot_setup_script')) %>
systemctl enable initial_setup
chmod +x '/root/initial_setup.sh'
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%#
kind: snippet
name: first_boot_setup_service
model: ProvisioningTemplate
snippet: true
description: |
Post replacement service
-%>
[Unit]
Description=Initial setup callback
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/bin/bash /root/fist_boot_setup_script.sh
RemainAfterExit=true
Type=oneshot

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%#
kind: snippet
name: first_boot_setup_script
model: ProvisioningTemplate
snippet: true
description: |
First boot setup script
-%>
<%= indent(2, skip1: true) { snippet('built', :variables => { :endpoint => 'built', :method => 'POST', :body_file => '/root/install.post.log' }) } -%>

0 comments on commit dbba291

Please sign in to comment.