Build RHEL 7 image with salt-cloud

199 views
Skip to first unread message

Gavin Bundt

unread,
Apr 24, 2017, 5:12:12 PM4/24/17
to Salt-users
I am having a hard time building a complete image of RHEL 7 from a template using salt-cloud.  I have been using RHEL 6 at our company to build them for a while and now we're migrate to RHEL 7.  I can successfully build and image from the template but the network adapter and ip specs aren't being applied.  This prevents the rhel scripts from running and installing salt-minion in the process.  If anyone has an example profile and map files, it would help a lot.  This is what I have

Profile vmware.conf

rhel7:
  provider: vcenter01
  clonefrom: Baseline_RHEL_7.3

  domain: dev.com
  dns_servers:
    - x.x.x.x

  datacenter: DEV
  cluster: DEV-Cluster
  datastore: MainCluster
  folder: DEV
  resourcepool: DEV
  template: False
  power_on: True

  hardware_version: 13
  image: RHEL 7.3 64bit

map file

rhel7:
  - SOADEV-192-rhel7test:
      ## Resource arguments
      num_cpus: 2
      memory: 8GB
      devices:
       network:
        Network adapter 1:
         name: DPortGroup-DEV
         adapter_type: vmxnet3
         switch_type: distributed
         ip: x.x.x.x
         gateway: [x.x.x.x]
         subnet_mask: 255.255.255.0
         domain: dev.com
      script: RHEL7.sh
      deploy: True
      customization: True
      ssh_username: xxxxxxx
      password: xxxxxxxx
      minion:
        master: x.x.x.x
      file_map:
        /srv/salt/dev/files/meis-internal.repo: /etc/yum.repos.d/dev-internal.repo
        /srv/salt/dev/files/rhel7-internal.repo: /etc/yum.repos.d/rhel7-internal.repo
        /srv/salt/dev/files/saltstack.repo: /etc/yum.repos.d/saltstack.repo
        /srv/salt/dev/files/resolv.conf: /etc/resolv.conf

RHEL7.sh script file

#!/bin/bash

# This legacy script pre-dates the salt-bootstrap project. In most cases, the
# bootstrap-salt.sh script is the recommended script for installing salt onto
# a new minion. However, that may not be appropriate for all situations. This
# script remains to help fill those needs, and to provide an example for users
# needing to write their own deploy scripts.

#yum -y install salt-minion --enablerepo epel-testing
yum -y install salt-minion
mkdir -p /etc/salt/pki
echo '{{ vm['priv_key'] }}' > /etc/salt/pki/minion.pem
echo '{{ vm['pub_key'] }}' > /etc/salt/pki/minion.pub
cat > /etc/salt/minion <<EOF
{{minion}}
EOF

systemctl enable salt-minion.service
systemctl start salt-minion.service

Sebastien Wains

unread,
Apr 28, 2017, 5:55:17 AM4/28/17
to Salt-users
We have been deploying RHEL7 for more than a year at work.

I've add issue with custom deploy scripts, while the bootstrap script provided by Salt works perfectly. I've filled a bug report back then https://github.com/saltstack/salt/issues/34547

Have you tried using the bootstrap script?

Odysseaus

unread,
Apr 28, 2017, 9:59:42 AM4/28/17
to Salt-users
I am looked into the script file but haven't used it.  Do you have instructions on how you configured network settings with it?  I am able to build a rhel 7 image with salt-cloud but unable to change any network settings.  I am wondering if there is something I need to change in my template.  My rhel 7 template is a minimum baseline install with no network configurations.  Thoughts?

Odysseaus

unread,
Apr 28, 2017, 10:33:04 AM4/28/17
to Salt-users
Ok, so I read more on bootstrap and it mainly just focuses on install the salt-minion on the distro of choice.  I actually don't have this problem because I deploy a custom RHEL7.sh script during the salt-cloud profile RHEL7 build.  If my template is pre-configured with an IP address than all works well but I need to be able to build multiple VMs at once and have salt-cloud apply different IP addresses per build.  I have this working fine for my RHEL6 template but RHEL7 doesn't accept the profile network configurations I give it.  My guess is there is something I need to pre-configure in the RHEL 7 template prior to using it to build future VMs.


On Friday, April 28, 2017 at 4:55:17 AM UTC-5, Sebastien Wains wrote:

Odysseaus

unread,
Apr 28, 2017, 12:11:35 PM4/28/17
to Salt-users
Found the fix.  Holy cow!!!  A manual install of vmware tools fixed updating the proper network adapter to the RHEL 7 vm.  The issue was with my template build and not salt-cloud configurations.  SOVLED!

Sebastien Wains

unread,
May 2, 2017, 3:02:51 PM5/2/17
to Salt-users
Ah yeah, all the networking setup is done once VMware tools are up and running.

When running salt-cloud in debug, it clearly shows that it is waiting for VMware tools to be running.
Reply all
Reply to author
Forward
0 new messages