Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OCPCLOUD-1106] Add afterburn task to update AWS hostname to match instance metadata #2401

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions templates/common/_base/files/usr-local-bin-mco-hostname.yaml
Expand Up @@ -22,6 +22,16 @@ contents:
exit 0
}

set_aws_hostname() {
/usr/bin/afterburn --provider aws --hostname=/run/afterburn.hostname

local host_name=$(cat /run/afterburn.hostname)

echo "setting transient hostname to ${host_name}"
/bin/hostnamectl --transient set-hostname "${host_name}"
exit 0
}

set_gcp_hostname() {
/usr/bin/afterburn --provider gcp --hostname=/run/afterburn.hostname

Expand Down Expand Up @@ -59,6 +69,7 @@ contents:
case "${arg}" in
--wait) wait_localhost;;
--gcp) set_gcp_hostname;;
--aws) set_aws_hostname;;
*) echo "Unhandled arg $arg"; exit 1
esac

10 changes: 10 additions & 0 deletions templates/common/aws/files/etc-networkmanager-conf.d-hostname.yaml
@@ -0,0 +1,10 @@
mode: 0644
path: "/etc/NetworkManager/conf.d/hostname.conf"
contents:
inline: |
# The following configuration allows 90-long-hostname.sh
# to manage setting transient hostname instead of NetworkManager itself.
# See: https://developer.gnome.org/NetworkManager/stable/NetworkManager.conf.html
# https://bugzilla.redhat.com/show_bug.cgi?id=1872885
[main]
hostname-mode=none
20 changes: 20 additions & 0 deletions templates/common/aws/units/aws-hostname.service.yaml
@@ -0,0 +1,20 @@
name: aws-hostname.service
enabled: true
contents: |
[Unit]
Description=Set AWS Transient Hostname
# Block services relying on networking being up.
Before=network-online.target
# Wait for NetworkManager to report it's online
After=NetworkManager-wait-online.service
# Run before hostname checks
Before=node-valid-hostname.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/mco-hostname --aws

[Install]
WantedBy=multi-user.target
WantedBy=network-online.target