Post installation scripts


Executing bash code within finish scripts and snippets.

Expected outcome:

Foreman and Proxy versions:

Foreman and Proxy plugin versions:

Distribution and version:
Foreman 3.7 Katello 4.9

Other relevant data:
As I am new to foreman and unfamiliar with the ERB template syntax I am wondering if it is possible to imbed bash scripting within the template. As an example I added the following within the default finish script and within a snippet with no results. The preview of the template/snippet showed no errors.

#!/usr/bin/env bash

cat << EOF >> /root/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAuC+sT7kt8kJ+Q+2aUdW6kPX2lrC19nXgm+zHr2SeZ/pIOqtgZk9OVTMxC+etv81QLID3cO9Kesl+sJDgxR90coHfhcDpWJxyhaeAbJCaOAiUMzzdpgbBo6OiykMQox5yrqnZPPOsB7hXqNkna8bfQhiY2z3MQcazcaqSN4NYu90= root@server01

There were no errors in the production log for the server build. Any assistance would be greatly appreciated and thanks in advance.

Yes, it’s totally possible, that’s the exact use case for the templates.

What are you trying to achieve with the template above?
For adding remote execution keys we have remote_execution_ssh_keys.erb snippet, maybe that’s what you are looking for.

Hi lstejska,

Thank you for your response.
My ultimate goal here is to create a master finish script when provisioning clients.
For example to include authorized keys, register the host with CDN, configure zabbix clients and more. Can I assume that a snippet can be a bash script that you call within a finish template. My attempt at placing a bash script within a finish template did not work.
For example:


  shell commands.

There were no errors in the log files.

Is this the correct way of doing this. Any information would be greatly appreciated.
Am also investigating how to configure virt-who for client registration.


Did you say which OS you’re installing and what installation method you’re using? For Kickstart several of the steps you listed are included in the default %post if you set the right host parameters.