vsphere-iso rhel7: sudo: unable to open /etc/sudoers: Too many open files in system

55 views
Skip to first unread message

Rich Meusburger

unread,
May 24, 2019, 12:50:57 PM5/24/19
to Packer
Using vsphere-iso provisioner with packer v1.4.0 am getting the following error.  

After initial reboot, packer connects and uploads files to /var/tmp.  When executing the 1st script it errors:

==> rhel-7.5-company-vmware: Waiting for SSH to become available...
==> rhel-7.5-company-vmware: Connected to SSH!
==> rhel-7.5-company-vmware: Provisioning with shell script: /tmp/packer-shell933587338
==> rhel-7.5-company-vmware: Uploading ansible => /var/tmp/ansible
==> rhel-7.5-company-vmware: Uploading common/mirror_rhel.repo => /home/jetbrains/mirror_rhel.repo
==> rhel-7.5-company-vmware: Uploading common/prep.sh => /home/jetbrains/prep.sh
==> rhel-7.5-company-vmware: Provisioning with shell script: /tmp/packer-shell540974853
    rhel-7.5-company-vmware: sudo: unable to open /etc/sudoers: Too many open files in system
    rhel-7.5-company-vmware: sudo: no valid sudoers sources found, quitting
    rhel-7.5-company-vmware: sudo: unable to initialize policy plugin
==> rhel-7.5-company-vmware: Power off VM...
==> rhel-7.5-company-vmware: Deleting Floppy image ...
==> rhel-7.5-company-vmware: Destroying VM...
Build 'rhel-7.5-company-vmware' errored: Script exited with non-zero exit status:

I increased the default 'ulimit' from 1024 to 3072 using my kickstart file and confirmed the change by logging into the VM during provisioning.

The /etc/sudoers file is 0440 and looks OK (it's the vendor default).  In addition, the 'jetbrains' account can 'sudo su -' with no password.

I get the same error whether I use ssh_user 'root' or 'jetbrains'.  Looking for suggestions? 

---------------------- packer.json ----------------------------

{
  "variables": {
    "template_version": "",
    "template_prefix": "rhel7sm",
    "build_uuid": "{{ uuid }}",

    "disk_size": "65536",
    "memory": "2048",

    "esx_host": "{{ env `ESX_HOST` }}",
    "esx_password": "{{ env `ESX_PASSWORD` }}",

    "lab_vcenter_host": "{{ env `LAB_VCENTER_HOST` }}",
    "lab_vcenter_user": "{{ env `LAB_VCENTER_USER` }}",
    "lab_vcenter_password": "{{ env `LAB_VCENTER_PASSWORD` }}",
    "lab_vcenter_ssl_thumbprint": "{{ env `LAB_VCENTER_SSL_THUMBPRINT` }}",
    "lab_datacenter": "{{ env `LAB_DATACENTER` }}",
    "lab_cluster": "{{ env `LAB_CLUSTER` }}",
    "lab_datastore": "{{ env `LAB_DATASTORE` }}",
    "lab_vm_folder": "{{ env `LAB_VM_FOLDER` }}",
    "lab_vm_network": "{{ env `LAB_VM_NETWORK` }}",

    "proxy_host": "{{ env `PROXY_HOST` }}",
    "proxy_port": "{{ env `PROXY_PORT` }}",

    "chroot_path": "/mnt/sysimage"
  },

  "builders": [
    {
      "name": "rhel-7.5-vmware",
      "type": "vsphere-iso",

      "vcenter_server": "{{ user `lab_vcenter_host` }}",
      "username": "{{ user `lab_vcenter_user` }}",
      "password": "{{ user `lab_vcenter_password` }}",
      "insecure_connection": true,
      "datacenter": "{{ user `lab_datacenter` }}",

      "vm_name": "{{ user `template_prefix` }}-{{ user `build_uuid` }}",
      "notes" : "{{ user `template_version` }} -- {{ user `template_date` }}",
      "folder": "{{ user `lab_base_vm_folder` }}",
      "cluster": "{{ user `lab_cluster` }}",
      "datastore": "{{ user `lab_datastore` }}",

      "iso_checksum": "e53bfe2163ad17cea800d0f89da473ef",
      "iso_checksum_type": "md5",
      "iso_paths": [
        "[nfs01_chddc10sa0101]ISO/rhel-server-7.5-x86_64-boot.iso"
      ],

      "floppy_files": [
        "isolinux.cfg"
      ],

      "shutdown_timeout": "10m",
      "ssh_username": "root",
      "ssh_password": "jetbrains",

      "guest_os_type": "rhel7_64Guest",
      "CPUs": 2,
      "RAM": "{{ user `memory` }}",
      "RAM_reserve_all": true,
      "disk_controller_type": "pvscsi",
      "disk_size": "{{ user `disk_size` }}",
      "disk_thin_provisioned": true,
      "network_card": "vmxnet3",
      "network": "{{ user `lab_vm_network` }}",

      "boot_wait": "20s",
      "boot_order": "disk,cdrom",
      "convert_to_template": true,

      "boot_wait": "20s",
      "boot_command": [
        "<tab> text ks=hd:fd0:/isolinux.cfg<enter><wait>"
      ]
    }
  ],

  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "mkdir -p /var/tmp/ansible"
      ]
    },
    {
      "type": "file",
      "source": "ansible",
      "destination": "/var/tmp/ansible"
    },
    {
      "type": "file",
      "source": "common/mirror_rhel.repo",
      "destination": "/home/jetbrains/mirror_rhel.repo"
    },
    {
      "type": "file",
      "source": "common/prep.sh",
      "destination": "/home/jetbrains/prep.sh"
    },
    {
      "type": "shell",
      "remote_path": "/home/jetbrains/prep.sh",
      "inline": [
      "sudo /home/jetbrains/prep.sh"
      ]
    },
    {
      "type": "shell",
      "pause_before": "50s",
      "inline": [
        "echo about to run ansible-playbook ... wait 30s for services to stabilize",
        "sleep 10",
        "sudo /usr/bin/ansible-playbook -vvv /var/tmp/ansible/ansible/site.yml -c local -i /var/tmp/ansible/ansible/inventory/inventory.txt",
        "sleep 10"
      ]
    }
  ]
}

------------------- isolinux.cfg --------------------------------------- 

text
reboot

zerombr
clearpart --all
bootloader

partition /boot --size=1024
partition pv.01 --grow
volgroup company pv.01
logvol /tmp --vgname=company --name=tmp --size=5000 --fsoptions=nodev,nosuid
logvol /var --vgname=company --name=var --size=5000
logvol /var/tmp --vgname=company --name=var_temp --size=5000 --fsoptions=nodev,nosuid,noexec
logvol /var/log --vgname=company --name=var_log --size=5000
logvol /var/log/audit --vgname=company --name=var_log_audit --size=5000
logvol /home --vgname=company --name=home --size=10000 --fsoptions=nodev
logvol swap --vgname=company --name=swap --size=4000
logvol / --vgname=company --name=root --size=1 --grow


network --activate --bootproto=dhcp

timezone UTC
rootpw --plaintext jetbrains

%packages
aide
oddjob-mkhomedir
iptables-services
-firewalld
openssl
open-vm-tools
perl
samba-common-tools
sssd
tcp_wrappers
%end

%post
systemctl enable sshd
useradd -d /home/jetbrains -m -s /bin/bash jetbrains
echo 'jetbrains:$6$jZX/Fb9Y$NBrEDSmYbOhiFTrzPWO6voNoHcPLzL2Y4sECq0m08jYgpEIj3dM3skhhXjPUTKjZC8Qc4pxSFVQb8.dqnBbQi1' | chpasswd -e
echo "jetbrains   ALL=(ALL)       NOPASSWD: ALL" > /etc/sudoers.d/55-jetbrains
chmod 0600 /etc/sudoers.d/55-jetbrains
echo "* - nofile 3072" > /etc/security/limits.d/userfiles.conf
chmod 0644 /etc/security/limits.d/userfiles.conf
%end

Reply all
Reply to author
Forward
0 new messages