Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%#
- kind: registration
- name: Global registration default
- model: ProvisioningTemplate
- oses:
- - RHEL
- -%>
- #!/bin/bash
- # curl --insecure <%= foreman_server_url %>/unattended/build_default_registration | bash
- <%
- admin = "admin"
- password = "changeme"
- organization = "Default_Organization"
- activation_key = "key1"
- curl_opts = ["-X GET", "--silent", "-H 'Content-Type: application/json'", "-H 'Accept: application/json'", "--user #{admin}:#{password}"]
- %>
- if (( $EUID != 0 )); then
- echo "Please run as root"
- exit 1
- fi
- # Host Registration to Satellite
- curl --insecure --force --output katello-ca-consumer-latest.noarch.rpm <%= foreman_server_url %>/pub/katello-ca-consumer-latest.noarch.rpm
- yum localinstall katello-ca-consumer-latest.noarch.rpm -y
- subscription-manager register --org=<%= organization %> --activationkey=<%= activation_key %>
- subscription-manager identity
- SUB_UUID=$(subscription-manager identity | grep "^system identity" | awk '{print $3}')
- HOST_ID=$(curl <%= curl_opts.join(' ') %> -d "{\"search\":\"subscription_uuid = $SUB_UUID\"}" "<%= foreman_server_url %>/api/hosts" | grep -Po '(?<=\"id\":)\d+' | head -1)
- echo ""
- echo "FOREMAN HOST ID: ${HOST_ID}"
- echo "Run registration template:"
- echo "curl <%= curl_opts.join(" ") %> \\"
- echo " <%= foreman_server_url %>/api/hosts/$HOST_ID/template/registration | grep -Po '(?<=\"template\":)(.*)(?=\"})' | bash"
Add Comment
Please, Sign In to add comment