@@ -11,7 +11,7 @@ namespace {
1111using namespace cloyster ;
1212using namespace cloyster ::utils;
1313
14- void addNode (const models::Node& node)
14+ void addNode (const models::Node& node, std::string_view image )
1515{
1616 services::runner::shell::fmt (
1717 R"(
@@ -36,12 +36,18 @@ nodeattrib {nodeName} net.ipv4_address={nodeIp}/{nodeCIDR}
3636 fmt::arg (" nodeMac" , macOpt.value ())
3737 );
3838 }
39+
40+ services::runner::shell::fmt (" nodedeploy -p {nodeName} -n {image}-diskless" ,
41+ fmt::arg (" nodeName" , node.getHostname ()),
42+ fmt::arg (" image" , image));
43+
44+ services::runner::shell::cmd (" confluent2hosts -a everything" );
3945}
4046
41- void addNodes ()
47+ void addNodes (std::string_view image )
4248{
4349 for (const auto & node : singleton::cluster ()->getNodes ()) {
44- addNode (node);
50+ addNode (node, image );
4551 }
4652}
4753}
@@ -50,6 +56,11 @@ namespace cloyster::services {
5056
5157void Confluent::install () {
5258 using namespace utils ::singleton;
59+
60+ const auto image = fmt::format (" {distro}-{arch}" ,
61+ fmt::arg (" arch" , cloyster::utils::enums::toString (os ().getArch ())),
62+ fmt::arg (" distro" , os ().getDistroString ()));
63+ //
5364 // NOTE: WIP - GENERALIZE THIS
5465 runner::shell::fmt (R"d(
5566# Add the Confluent repository
@@ -78,7 +89,11 @@ if systemctl is-enabled -q firewalld; then
7889fi
7990
8091# Add basic settings to allow a minimalist boot environment for testing
81- nodegroupattrib everything dns.servers={hnIp} dns.domain={domain} net.ipv4_gateway={gateway}
92+ nodegroupattrib everything \
93+ dns.servers={hnIp} \
94+ dns.domain={domain} \
95+ net.ipv4_gateway={hnIp} \
96+ deployment.useinsecureprotocols=always
8297
8398# Fill required passwords
8499# FIXME: Those strings are get from `stdin` we need to automate also
@@ -87,31 +102,22 @@ nodegroupattrib everything dns.servers={hnIp} dns.domain={domain} net.ipv4_gatew
87102# Generate a keypair for internal cluster usage
88103test -f ~/.ssh/id_ed25519 || ssh-keygen -t ed25519 -N ""
89104
90- # Define a given node
91- # nodedefine n01
92- # nodeattrib n01 net.hwaddr=00:0c:29:7d:b6:67
93- # nodeattrib n01 net.ipv4_address=100.64.0.1/24
94-
95- # Add nodes to /etc/hosts
96- # Needs to evaluate in the future if there is a better approach to add files to /etc/hosts; `dnsmasq` maybe?
97- confluent2hosts -a everything
98-
99105# Configure the osdeploy parameters; it's an interactive interface, so we must find a way to automate this step
100106osdeploy initialize -u -s -k -l -p -a -t -g
101107
102108# Import the OS ISO file.
103109osdeploy import {isoPath}
104110
105111# distro contains the osversion
106- image={distro}-{arch}
107112
108113rm -rf /tmp/scratchdir || :
114+ rm -rf /var/lib/confluent/public/os/{image}-diskless || :
109115
110116# Create a temporary chroot to work as basis for the boot image
111- imgutil build -y -s ${{ image} } /tmp/scratchdir
117+ imgutil build -y -s { image} /tmp/scratchdir
112118
113119# Pack the image from the temporary chroot and give a name
114- imgutil pack /tmp/scratchdir/ ${{ image} }-diskless
120+ imgutil pack /tmp/scratchdir/ { image}-diskless
115121
116122# Check if the image shows up as available with the defined name
117123osdeploy list
@@ -134,13 +140,9 @@ rm -rf /tmp/scratchdir
134140 answerfile ()->management .con_interface ,
135141 " Internal interface not found in [network_management]"
136142 )),
137- fmt::arg (" gateway" ,
138- utils::optional::unwrap (
139- answerfile ()->management .gateway ,
140- " Internal gateway not found in [network_management]"
141- ))
143+ fmt::arg (" image" , image)
142144 );
143- addNodes ();
145+ addNodes (image );
144146}
145147
146148}
0 commit comments