stejzyy23

Untitled

Jul 8th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ADMIN_LOGIN="admin"
  4. ADMIN_PASSW="changeme"
  5. FOREMAN_URL="http://centos7-katello-devel-stable.example.com"
  6.  
  7. ORGANIZATION="Default_Organization"
  8. ACTIVATION_KEY="key1"
  9.  
  10. #
  11. # Host Registration to Satellite
  12. #
  13. curl --insecure --output katello-ca-consumer-latest.noarch.rpm $FOREMAN_URL/pub/katello-ca-consumer-latest.noarch.rpm
  14. yum localinstall katello-ca-consumer-latest.noarch.rpm -y
  15. subscription-manager register --org=$ORGANIZATION --activationkey=$ACTIVATION_KEY
  16.  
  17. #
  18. # Host configuration from Satellite
  19. #
  20. yum install jq -y
  21. subscription-manager identity
  22. SUB_UUID=$(subscription-manager identity | grep "^system identity" | awk '{print $3}')
  23.  
  24. # Get Host Foreman ID
  25. HOST_ID=$(curl -X GET -s --user $ADMIN_LOGIN:$ADMIN_PASSW \
  26. -H "Content-type: application/json" \
  27. -H "Accept: application/json" \
  28. -d "{\"search\":\"subscription_uuid = $SUB_UUID\"}" \
  29. "$FOREMAN_URL/api/hosts" | jq ".results[0].id")
  30.  
  31. # Get registration template and run it
  32. curl -X GET -s --user $ADMIN_LOGIN:$ADMIN_PASSW \
  33. -H "Content-type: application/json" \
  34. -H "Accept: application/json" \
  35. "$FOREMAN_URL/api/hosts/$HOST_ID/template/registration" | jq -j ".template" | bash
Add Comment
Please, Sign In to add comment