View Categories

Build a RHEL instance on Nutanix

5 min read

​

Here are some instructions on how to build a RHEL VM using Nutanix and customizing the install with cloud-init

DEPLOY RHEL using cloud-int to customize some common settings

Here are some example cloud-init files that have worked for me

YAML
#cloud-config
keyboard:
  layout: us
manage_etc_hosts: true
hostname: nginx-rhel-tst01
chpasswd:
  list: |
    root:Pa55w0rD!
  expire: false
runcmd:
  - nmcli con modify "System eth0" ipv4.method manual ipv4.address 10.11.12.13 gw4 10.11.12.1 ipv4.dns "8.8.8.8 8.8.4.4"
  - nmcli con down "System eth0"
  - nmcli con up "System eth0"
  - subscription-manager register --org="MWG" --activationkey="RHEL_8"

Another cloud-init file with a bit more for reference for your cloud-init file

YAML
networkData: |
  version: 2
  config:
    - type: physical
      name: enp1s0
      subnets:
         - type: static
           address: 10.11.12.13/27
           gateway: 10.11.12.1
    - type: physical
      name: enp2s0
      subnets:
         - type: static
           address: 10.11.12.43/27
           gateway: 10.11.12.33
    - type: nameserver
      address:
        - 8.8.8.8
        - 8.8.4.4
        - 9.9.9.9
userData: | -
  #cloud-config
  user: cloud-user
  password: 730a-xb5w-issv
  chpasswd: { expire: False }
  write_files:
  - path: /etc/vpm/user_data
    content: |
      token: eyJhbGciOiJIUzI1NiIsInR5cC
    owner: root
    permissions: '0644'
  - path: /etc/vpm/config.yaml
    permissions: '0644'
    owner: root
    encoding: base64
    content: |
      S3ViZXJuZXRlczoKICBFdGNkVXNlVExTOiB0cnVlCiAgU2VydmVyOiB2aXAKVnBtOgogIENsdXN0ZXJOYW1lOiBDSEFOR0UtTUUKICBMYXRpdHVkZTogMjkuNDY2NjEwCiAgTG9uZ2l0dWRlOiAtOTguNjg4MTkwCiAgTnRwU2VydmVyczoKICAtIG50cDEubXl3aXNlZ3V5cy5jb20KICAtIG50cDIubXl3aXNlZ3V5cy5jb20=

YUM/DNF Update

When you first bootup you need to update your repos and here are the commands I first run that seem to work for me

First check your repolist by running sudo yum -v repolist

sudo yum -v repolist
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, notify-packagekit, playground, product-id, repoclosure, repodiff, repograph, repomanage, reposync, subscription-manager, system-upgrade, uploadprofile
Not root, Subscription Management repositories not updated
YUM version: 4.14.0
cachedir: /var/tmp/dnf-https://eventguyz.com/wp-content/uploads/2024/05/hosang-i-t-python-02-2.png-lcfs6afa
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)                                                                                                         27 MB/s |  32 MB     00:01
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)                                                                                                      28 MB/s |  41 MB     00:01
infratools_ansible                                                                                                                                           291 kB/s | 155 kB     00:00
Last metadata expiration check: 0:00:01 ago on Thu Oct 17 05:20:52 2024.
Repo-id            : MYWISEGUYS_infrtools_ansible_infratools_ansible
Repo-name          : infratools_ansible
Repo-revision      : 1680861588
Repo-updated       : Fri Apr  7 05:59:48 2023
Repo-pkgs          : 3
Repo-available-pkgs: 3
Repo-size          : 34 M
Repo-baseurl       : https://capsule-us-east-2.9395.aws.mywiseguys.com/pulp/content/MYWISEGUYS/Library/RHEL_9_CCV/custom/infrtools_ansible/infratools_ansible
Repo-expire        : 1 second(s) (last: Thu Oct 17 05:20:52 2024)
Repo-filename      : /etc/yum.repos.d/redhat.repo

Repo-id            : rhel-9-for-x86_64-appstream-rpms
Repo-name          : Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)
Repo-revision      : 1727703639
Repo-updated       : Mon Sep 30 09:40:38 2024
Repo-pkgs          : 19501
Repo-available-pkgs: 18789
Repo-size          : 67 G
Repo-baseurl       : https://capsule-us-east-2.9395.aws.mywiseguys.com/pulp/content/MYWISEGUYS/Library/RHEL_9_CCV/content/dist/rhel9/9/x86_64/appstream/os
Repo-expire        : 1 second(s) (last: Thu Oct 17 05:20:45 2024)
Repo-filename      : /etc/yum.repos.d/redhat.repo

Repo-id            : rhel-9-for-x86_64-baseos-rpms
Repo-name          : Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)
Repo-revision      : 1727703439
Repo-updated       : Mon Sep 30 09:37:18 2024
Repo-pkgs          : 7061
Repo-available-pkgs: 7061
Repo-size          : 17 G
Repo-baseurl       : https://capsule-us-east-2.9395.aws.mywiseguys.com/pulp/content/MYWISEGUYS/Library/RHEL_9_CCV/content/dist/rhel9/9/x86_64/baseos/os
Repo-expire        : 1 second(s) (last: Thu Oct 17 05:20:40 2024)
Repo-filename      : /etc/yum.repos.d/redhat.repo
Total packages: 26565 

show what repos are enabled

sudo yum repolist enabled

sudo yum update -y

NTP Setup

timedatectl status shows if System clock in synchronized and here it says No and the time is about 4 hours behind the actual time

timedatectl status
               Local time: Thu 2024-10-17 05:32:07 EDT
           Universal time: Thu 2024-10-17 09:32:07 UTC
                 RTC time: Thu 2024-10-17 09:32:06
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

First we need to make sure we have chrony installed and how I do that is just see if it will install.  I run sudo dnf install chrony and you see it says its already installed

sudo dnf install chrony
Updating Subscription Management repositories.
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)                                                                                                         22 kB/s | 4.1 kB     00:00
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)                                                                                                      26 kB/s | 4.5 kB     00:00
infratools_ansible                                                                                                                                            12 kB/s | 2.0 kB     00:00
Package chrony-4.5-1.el9.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete! 

Next step is to make sure that chrony is pointing to the ntp servers you want chrony pointing to so edit /etc/chrony.conf

sudo vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
pool 2.rhel.pool.ntp.org iburst
server ntp2.mywiseguys.corp
server ntp1.mywiseguys.corp

Now lets restart chronyd and make sure chronyd starts up everytime the VM reboots

sudo systemctl restart chronyd 
sudo systemctl enable chronyd

You can check to see if chronyd is connecting to the sources you provided by running sudo chronyc sources 

sudo chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? 99-119-214-210.lightspee>     0   7     0     -     +0ns[   +0ns] +/-    0ns
^? t1.time.bf1.yahoo.com         0   7     0     -     +0ns[   +0ns] +/-    0ns
^? time.ecansol.net              0   7     0     -     +0ns[   +0ns] +/-    0ns
^? ovh.maxhost.io                0   7     0     -     +0ns[   +0ns] +/-    0ns
^? fnt1lvmap1500.mywiseguys.corp 2   6     1    63  -14400s[-14400s] +/-   33ms
^? ntp1.mywiseguys.corp          2   6     1    63  -14400s[-14400s] +/-   26ms 

Here we see the last two are connected to Stratum 2 servers so we should have accurate time now sync’d from NTP servers.  Let’s check with timedatectl status

timedatectl status
               Local time: Thu 2024-10-17 09:35:13 EDT
           Universal time: Thu 2024-10-17 13:35:13 UTC
                 RTC time: Thu 2024-10-17 13:35:13
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no 

Here we have the accurate time and System clock synchronized says yes so NTP is good to go

Protected By
Shield Security