anchor.diff: -#!/bin/bash -x
  +#!/bin/bash -xe
  +
  +function revert_back_to_centos() {
  +# Removes redhat-release-server rpm and replaces it with centos-release
  +  echo "Removing Red Hat temporary configuration."
  +  if rpm -q redhat-release-server &>/dev/null; then
  +    rpm -Uvh --force /root/centos-release/centos-release*.rpm
  +    rpm -e --nodeps --noscripts redhat-release-server
  +  fi
  +  #Disable subscription-manager and rhn plugins
  +  for plugin in $rhsm_plugins $rhn_plugins; do
  +    sed -i 's/^enabled.*/enabled=0/' "/etc/yum/pluginconf.d/${plugin}.conf" 2>/dev/null || :
  +  done
  +  rm -f /etc/yum/vars/releasever
  +  yum-config-manager --enable 'nailgun' &> /dev/null
  +}
  +trap revert_back_to_centos EXIT
  +
  +rhsm_plugins="product-id subscription-manager"
  +rhn_plugins="rhnplugin"
  +#Enable subscription-manager plugins
  +for plugin in $rhsm_plugins; do
  +  sed -i 's/^enabled.*/enabled=1/' "/etc/yum/pluginconf.d/${plugin}.conf" 2>/dev/null || :
  +done
  +
   #Register
   subscription-manager register "--username=<%= rh_username %>" "--password=<%= rh_password %>" --autosubscribe --force 
   
  
positive.code: subscription-manager unregister
  rm -rf /etc/yum.repos.d/redhat.repo
  
  #Run registration
  
  rhnreg_ks "--serverUrl=http://<%= sat_hostname %>/XMLRPC" --profilename=fuelweb "--activationkey=<%= activation_key %>" --sslCACert=/etc/sysconfig/rhn/RHNS-CA-CERT --nopackages --nohardware --novirtinfo --norhnsd --force
  
  if [ $? -ne 0 ]; then
    echo "Registration failed. Aborting."
    exit 1
  fi
  #Ensure channels are enabled:
  
negative.code: done
  if [ $errors -gt 0 ]; then
    echo "There were problems enabling channels. Please check puppet manifests and your RHN Satellite channel configuration to ensure the necessary channels are enabled." 1>&2
    revert_back_to_centos
    exit 1
  fi
  
  