Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions data/data/agent/files/etc/assisted/agent-installer.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# If NODE_ZERO_IP is changed, additional files need to be updated
# before starting up the agent-based installer services:
#
# In /usr/local/share/assisted-service/assisted-service.env,
# IMAGE_SERVICE_BASE_URL and SERVICE_BASE_URL must be updated.
#
# In /usr/local/share/assisted-service/images.env,
# ASSISTED_SERVICE_HOST must be updated.
#
NODE_ZERO_IP={{.NodeZeroIP}}
12 changes: 12 additions & 0 deletions data/data/agent/files/usr/local/bin/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# shellcheck disable=SC1091
source /usr/local/share/assisted-service/assisted-service.env

wait_for_assisted_service() {
echo "Waiting for assisted-service to be ready"
until curl --output /dev/null --silent --fail "${SERVICE_BASE_URL}/api/assisted-install/v2/infra-envs"; do
printf '.'
sleep 5
done
}
9 changes: 0 additions & 9 deletions data/data/agent/files/usr/local/bin/common.sh.template

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ IMAGE=$(image_for agent-installer-node-agent)

echo "Using agent image: ${IMAGE} to copy bin"

/usr/bin/podman run --privileged --rm -v /usr/local/bin:/hostbin ${IMAGE} cp /usr/bin/agent /hostbin
/usr/bin/podman run --privileged --rm -v /usr/local/bin:/hostbin "${IMAGE}" cp /usr/bin/agent /hostbin
67 changes: 67 additions & 0 deletions data/data/agent/files/usr/local/bin/set-node-zero.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

set -e

# shellcheck disable=SC1091
source /etc/assisted/agent-installer.env
echo "NODE_ZERO_IP: $NODE_ZERO_IP"

timeout=$((SECONDS + 30))

while [[ $SECONDS -lt $timeout ]]
do
IS_NODE_ZERO=$(ip -j address | jq "[.[].addr_info] | flatten | map(.local==\"$NODE_ZERO_IP\") | any")
if [ "${IS_NODE_ZERO}" = "true" ]; then
break
fi
sleep 5
done

if [ "${IS_NODE_ZERO}" = "true" ]; then
echo "Node 0 IP ${NODE_ZERO_IP} found on this host" 1>&2

NODE0_PATH=/etc/assisted/node0
mkdir -p "$(dirname "${NODE0_PATH}")"

NODE_ZERO_MAC=$(ip -j address | jq -r ".[] | select(.addr_info | map(select(.local == \"$NODE_ZERO_IP\")) | any).address")
echo "MAC Address for Node 0: ${NODE_ZERO_MAC}"

cat >"${NODE0_PATH}" <<EOF
# This file exists if the agent-based installer has determined the host is node 0.
# The host is determined to be node 0 when one of its network interfaces has an
# IP address matching NODE_ZERO_IP in /etc/assisted/agent-installer.env.
# The MAC address of the network interface matching NODE_ZERO_IP is noted below
# as BOOTSTRAP_HOST_MAC.
#
# BOOTSTRAP_HOST_MAC is read by assisted-service. The host with a MAC address
# matching this value in assisted-service is designated to be the bootstrap during
# cluster installation. In assisted-service.service, this file is included as a
# --env-file in the ExecStart command.
#
# This file is also a ConditionPathExists in the following systemd service
# definitions:
# apply-host-config.service
# assisted-service-pod.service
# create-cluster-and-infraenv.service
# install-status.service
# start-cluster-installation.service
BOOTSTRAP_HOST_MAC=${NODE_ZERO_MAC}
EOF

echo "Created file ${NODE0_PATH}"

rendezvousHostMessage="This host ${NODE_ZERO_IP} is the rendezvous host."

cat <<EOF >/etc/motd
The primary service is assisted-service.service. To watch its status, run:

journalctl -u assisted-service.service
EOF
else

rendezvousHostMessage="This host is not the rendezvous host. The rendezvous host is at ${NODE_ZERO_IP}."
fi
mkdir -p /etc/motd.d/
echo "$rendezvousHostMessage" > /etc/motd.d/60-rendezvous-host
echo "$rendezvousHostMessage" > /etc/issue.d/60-rendezvous-host.issue
agetty --reload
45 changes: 0 additions & 45 deletions data/data/agent/files/usr/local/bin/set-node-zero.sh.template

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash

# shellcheck disable=SC1091
source common.sh

>&2 echo "Waiting for infra-env-id to be available"
INFRA_ENV_ID=""
until [[ $INFRA_ENV_ID != "" && $INFRA_ENV_ID != "null" ]]; do
sleep 5
>&2 echo "Querying assisted-service for infra-env-id..."
INFRA_ENV_ID=$(curl -s -S '{{.ServiceBaseURL}}/api/assisted-install/v2/infra-envs' | jq -r .[0].id)
INFRA_ENV_ID=$(curl -s -S "${SERVICE_BASE_URL}/api/assisted-install/v2/infra-envs" | jq -r .[0].id)
done
echo "Fetched infra-env-id and found: $INFRA_ENV_ID"

Expand All @@ -19,4 +20,4 @@ IMAGE=$(image_for agent-installer-node-agent)
echo "Using agent image: ${IMAGE} to start agent"

# use infra-env-id to have agent register this host with assisted-service
exec /usr/local/bin/agent --url '{{.ServiceBaseURL}}' --infra-env-id '{{.InfraEnvID}}' --agent-version ${IMAGE} --insecure=true
exec /usr/local/bin/agent --url "${SERVICE_BASE_URL}" --infra-env-id "${INFRA_ENV_ID}" --agent-version "${IMAGE}" --insecure=true
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source issue_status.sh

wait_for_assisted_service

BASE_URL="{{.ServiceBaseURL}}api/assisted-install/v2"
BASE_URL="${SERVICE_BASE_URL}api/assisted-install/v2"

cluster_id=""
while [[ "${cluster_id}" = "" ]]
Expand All @@ -18,8 +18,7 @@ do
fi
done

infra_env_id="{{.InfraEnvID}}"
echo -e "\nInfra env id is $infra_env_id" 1>&2
echo -e "\nInfra env id is ${INFRA_ENV_ID}" 1>&2

required_master_nodes={{.ControlPlaneAgents}}
required_worker_nodes={{.WorkerAgents}}
Expand All @@ -33,7 +32,7 @@ status_issue="90_start-install"
num_known_hosts() {
local known_hosts=0
local insufficient_hosts=0
host_status=$(curl -s -S "${BASE_URL}/infra-envs/${infra_env_id}/hosts" | jq -r .[].status)
host_status=$(curl -s -S "${BASE_URL}/infra-envs/${INFRA_ENV_ID}/hosts" | jq -r .[].status)
if [[ -n ${host_status} ]]; then
for status in ${host_status}; do
if [[ "${status}" == "known" ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ Wants=network-online.target
Requires=create-cluster-and-infraenv.service
PartOf=assisted-service-pod.service
After=network-online.target create-cluster-and-infraenv.service
ConditionPathExists=/etc/assisted-service/node0
ConditionPathExists=/etc/assisted/node0

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Environment=SERVICE_BASE_URL={{.ServiceBaseURL}}
Environment=INFRA_ENV_ID={{.InfraEnvID}}
EnvironmentFile=/usr/local/share/assisted-service/agent-images.env
EnvironmentFile=/usr/local/share/assisted-service/assisted-service.env
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStartPre=/bin/mkdir -p %t/agent-installer /etc/assisted/hostconfig
ExecStartPre=/usr/local/bin/wait-for-assisted-service.sh
Expand Down
2 changes: 1 addition & 1 deletion data/data/agent/systemd/units/assisted-service-pod.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Description=Assisted Service pod
Wants=network.target node-zero.service
After=network-online.target node-zero.service
ConditionPathExists=/etc/assisted-service/node0
ConditionPathExists=/etc/assisted/node0
RequiresMountsFor=
Requires=assisted-service-db.service assisted-service.service
Before=assisted-service-db.service assisted-service.service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Restart=on-failure
TimeoutStartSec=500
TimeoutStopSec=300
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run --net host --cidfile=%t/%n.ctr-id --cgroups=no-conmon --log-driver=journald --rm --pod-id-file=%t/assisted-service-pod.pod-id --sdnotify=conmon --replace -d --name=service -v /opt/agent/tls:/opt/agent/tls:z {{ if .HaveMirrorConfig }}-v /etc/containers:/etc/containers{{ end }} -v /etc/pki/ca-trust:/etc/pki/ca-trust --env-file=/usr/local/share/assisted-service/assisted-service.env --env-file=/usr/local/share/assisted-service/images.env --env-file=/etc/assisted-service/node0 --env-file=/usr/local/share/assisted-service/agent-images.env $SERVICE_IMAGE
ExecStart=/usr/bin/podman run --net host --cidfile=%t/%n.ctr-id --cgroups=no-conmon --log-driver=journald --rm --pod-id-file=%t/assisted-service-pod.pod-id --sdnotify=conmon --replace -d --name=service -v /opt/agent/tls:/opt/agent/tls:z {{ if .HaveMirrorConfig }}-v /etc/containers:/etc/containers{{ end }} -v /etc/pki/ca-trust:/etc/pki/ca-trust --env-file=/usr/local/share/assisted-service/assisted-service.env --env-file=/usr/local/share/assisted-service/images.env --env-file=/etc/assisted/node0 --env-file=/usr/local/share/assisted-service/agent-images.env $SERVICE_IMAGE
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Description=Service that creates initial cluster and infraenv
Wants=network-online.target assisted-service.service
PartOf=assisted-service-pod.service
After=network-online.target assisted-service.service
ConditionPathExists=/etc/assisted-service/node0
ConditionPathExists=/etc/assisted/node0

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Environment=SERVICE_BASE_URL={{.ServiceBaseURL}}
Environment=OPENSHIFT_INSTALL_RELEASE_IMAGE_MIRROR={{.ReleaseImageMirror}}
EnvironmentFile=/usr/local/share/assisted-service/agent-images.env
EnvironmentFile=/usr/local/share/assisted-service/assisted-service.env
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStartPre=/usr/local/bin/wait-for-assisted-service.sh
ExecStart=podman run --net host --cidfile=%t/%n.ctr-id --cgroups=no-conmon --log-driver=journald --rm --pod-id-file=%t/assisted-service-pod.pod-id --replace --name=create-cluster-and-infraenv --restart=on-failure -v /etc/assisted/manifests:/manifests -v /etc/assisted/extra-manifests:/extra-manifests -v /etc/pki/ca-trust:/etc/pki/ca-trust:z --env SERVICE_BASE_URL --env OPENSHIFT_INSTALL_RELEASE_IMAGE_MIRROR $SERVICE_IMAGE /usr/local/bin/agent-installer-client register
Expand Down
2 changes: 1 addition & 1 deletion data/data/agent/systemd/units/install-status.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Description=Service that monitors host-specific configuration status
Wants=network-online.target create-cluster-and-infraenv.service
After=network-online.target create-cluster-and-infraenv.service
ConditionPathExists=/etc/assisted-service/node0
ConditionPathExists=/etc/assisted/node0

[Service]
ExecStart=/usr/local/bin/install-status.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Wants=network-online.target
Requires=apply-host-config.service
PartOf=assisted-service-pod.service
After=network-online.target apply-host-config.service
ConditionPathExists=/etc/assisted-service/node0
ConditionPathExists=/etc/assisted/node0

[Service]
ExecStart=/usr/local/bin/start-cluster-installation.sh
Expand Down