krishna kanth Gade
krishna kanth Gade

Reputation: 3

packer nutanix template unable to recognize the kickstart config file

The packer template looks like following where i tried to pass the ks.cfg using user data and cd_files.in both the cases while vm launched its not processing through

packer {
  required_plugins {
    nutanix = {
      version = ">= 0.8.0"
      source  = "github.com/nutanix-cloud-native/nutanix"
    }
    ansible = {
      version = ">= 1.1.1"
      source  = "github.com/hashicorp/ansible"
    }
  }
}
source "nutanix" "rhel-kickstart" {
  nutanix_username  = "" # Prism Central username
  nutanix_password  = "" # Prism Central password
  nutanix_endpoint  = "" # Prism central IP / Hostname
  nutanix_insecure =  "true"
  nutanix_port     = 9440
  cluster_name      = "" # Prism Cluster name
  vm_name       = "IFactory_packer_nutanix"
  os_type           = "Linux"   # "Linux" or "Windows"
  user_data = base64encode(file("/mnt/agent/_work/1/s/Nutanix/scripts/cent-config.yaml"))
  vm_disks {
      image_type = "ISO_IMAGE"
      source_image_name =    "rhel-8.6-x86_64-dvd_htf728.iso"
  
      disk_size_gb     = 40   
  }

  vm_disks {
      image_type = "DISK"
      disk_size_gb = 40
  }

  vm_nics {
    subnet_name = "Network_vlan-2031"
  }

  cd_files          = ["/home/vm-admin/krishna/cent_ks.cfg"]
  cd_label          = "oemdrv"

  image_name        ="rhel8.6-{{isotime `Jan-_2-15:04:05`}}"
  shutdown_command  = "echo 'packer' | sudo -S shutdown -P now"
  shutdown_timeout = "2m"
  ssh_password     = "packer"
  ssh_username     = "root"
}
build {
  sources = ["nutanix.rhel-kickstart"]
  provisioner "shell" {
    environment_vars = [
      "FOO=hello world",
    ]
    inline = [
      "echo \"FOO is $FOO\" > example.txt",
    ]
  }
}

the following is the kickstart config

#  Author: Tomasz Filipiec <[email protected]>
#   Desc.: Simple kickstart file for automated installation
#      OS: CentOS 7 Minimal (core)
# Version: 1.0

# Turning on text-mode installation (little quicker than GUI)
text

# Setting up authentication and keyboard
auth --enableshadow --passalgo=sha512
keyboard --vckeymap=us --xlayouts='us'

# Installation files source (CentOS-7.0-1406-x86_64-Minimal.iso)
cdrom

# Using only primary disk, ignoring others
ignoredisk --only-use=sda

# Setting up language to English
lang en-US.UTF-8

# Setting up network interface to DHCP
network --bootproto=dhcp --ipv6=auto --hostname=centos-ks.local --activate

# Root password (remember that plaintext only for information purposes)
rootpw --plaintext packer

# Setting up firewall and enabling SSH for remote management
firewall --enabled --service=ssh

# Setting timezone
timezone Europe/Berlin --isUtc

# Setting up Security-Enhanced Linux into enforcing
selinux --enforcing

# Setting up MBR
bootloader --location=mbr --boot-drive=sda

# Setting up Logical Volume Manager and autopartitioning
clearpart --all --drives=sda --initlabel
autopart --type=lvm

# Eject cdrom and reboot
reboot --eject

# Installing only packages for minimal install 
%packages
@Core
chrony
%end

i tried approaches such as adding the kick starter file through cd files and also through userdata. while i am working to create golden image of rhel 8.6

Upvotes: 0

Views: 155

Answers (0)

Related Questions