Skip to content

Commit

Permalink
Merge pull request #1579 from jcpowermac/vsphere_ipi_hostname
Browse files Browse the repository at this point in the history
vsphere ipi: set hostname using vmtoolsd and VM extra config
  • Loading branch information
openshift-merge-robot authored Mar 27, 2020
2 parents 9ae739e + 41d45f0 commit 68bf465
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions templates/common/vsphere/files/vsphere-hostname.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
filesystem: "root"
mode: 0755
path: "/usr/local/bin/vsphere-hostname.sh"
contents:
inline: |
#!/usr/bin/env bash
set -e
if [ $(hostname -s) = "localhost" ]; then
if hostname=$(/bin/vmtoolsd --cmd 'info-get guestinfo.hostname'); then
/usr/bin/hostnamectl --transient --static set-hostname ${hostname}
fi
fi
16 changes: 16 additions & 0 deletions templates/common/vsphere/units/vsphere-hostname.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "vsphere-hostname.service"
enabled: true
contents: |
[Unit]
Description=vSphere hostname
After=vmtoolsd.service
Before=kubelet.service
[Service]
ExecStart=/usr/local/bin/vsphere-hostname.sh
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target

0 comments on commit 68bf465

Please sign in to comment.