Variables in preseeds look like this: {{new_ip_address}}. So you can, for example, make some python code in preseed where you assign ip to variable and then make configuration with that variable.
Below is example of what we using to get puppet fact “puppet_team” variable via python post request:
{{py:
import operator
import re
import os
import requests
import subprocess
node_hostname = node.fqdn
node_distribution = node.get_distro_series()
puppet_team = “”
ipmi_ip_address = str(node.bmc.extract_ip_address(node.power_type, node.power_parameters)).strip()
team_request_data = {“event” : “created”, “model” : “team”, “data” : {“ipmi_ip” : ipmi_ip_address} }
team_req = requests.post(“http://%s:8084” % node.boot_cluster_ip, json=team_request_data)
puppet_team = team_req.json().get(‘team’)
}}
late_commands:
01_add_team_fact: [“curtin”, “in-target”, “–”, “sh”, “-c”, “echo team={{puppet_team}} >/opt/puppetlabs/facter/facts.d/team.txt”]
02_run_puppet: [“curtin”, “in-target”, “–”, “sh”, “-c”, “/opt/puppetlabs/bin/puppet agent -t --server server_name || true”]