Advertisement
Guest User

Untitled

a guest
Nov 1st, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.37 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Admin Credentials
  3. ADMIN_USER="admin"
  4.  
  5. ADMIN_PASSWORD=""
  6.  
  7. if [[ -z "$ADMIN_PASSWORD" ]]; then
  8. ADMIN_PASSWORD="changeme"
  9. fi
  10.  
  11. # The below values get populated from the compute_resources.conf file.
  12. # Compute Resource Variables.
  13. COMPUTE_RESOURCE_NAME_LIBVIRT="libvirt"
  14. LIBVIRT_URL=""
  15.  
  16. if [[ -z "$LIBVIRT_URL" ]]; then
  17. echo "You need to specify the LIBVIRT_URL to be used as Compute Resource."
  18. exit 1
  19. fi
  20.  
  21. # RHEVM Compute Resource Variables.
  22. RHEV_URL=""
  23. RHEV_USERNAME=""
  24. RHEV_PASSWORD=""
  25. RHEV_DATACENTER_UUID=""
  26.  
  27. if [[ -z "$RHEV_URL" || -z "$RHEV_USERNAME" || -z "$RHEV_PASSWORD" || -z "$RHEV_DATACENTER_UUID" ]]; then
  28. echo "You need to specify RHEV_URL, RHEV_USERNAME, RHEV_PASSWORD and RHEV_DATACENTER_UUID to be used as Compute Resource."
  29. exit 1
  30. fi
  31.  
  32. # Openstack Compute Resource.
  33. OS_URL=""
  34. OS_USERNAME=""
  35. OS_PASSWORD=""
  36.  
  37. if [[ -z "$OS_URL" || -z "$OS_USERNAME" || -z "$OS_PASSWORD" ]]; then
  38. echo "You need to specify OS_URL, OS_USERNAME, OS_PASSWORD to be used as Compute Resource."
  39. exit 1
  40. fi
  41.  
  42.  
  43. # The below values get populated from the satellite6_libvirt_install.conf file.
  44. # DOMAIN and SUBNET Variables.
  45. SUBNET_NAME=""
  46. SUBNET_RANGE=""
  47. SUBNET_MASK=""
  48. SUBNET_GATEWAY=""
  49.  
  50. if [[ -z "$SUBNET_NAME" || -z "$SUBNET_RANGE" || -z "$SUBNET_MASK" || -z "$SUBNET_GATEWAY" ]]; then
  51. echo "You need to specify SUBNET_NAME, SUBNET_RANGE, SUBNET_MASK and SUBNET_GATEWAY to be added as a subnet."
  52. exit 1
  53. fi
  54.  
  55. MANIFEST_LOCATION_URL=""
  56.  
  57. if [[ -z "$MANIFEST_LOCATION_URL" ]]; then
  58. echo "You need to specify MANIFEST_LOCATION_URL which hosts the manifest file."
  59. exit 1
  60. fi
  61.  
  62. DOWNLOAD_POLICY=""
  63.  
  64. if [[ -z "$DOWNLOAD_POLICY" ]]; then
  65. echo "You need to specify DOWNLOAD_POLICY for syncing content."
  66. exit 1
  67. fi
  68.  
  69. SATELLITE_DISTRIBUTION=""
  70.  
  71. if [[ -z "$SATELLITE_DISTRIBUTION" ]]; then
  72. echo "You need to specify SATELLITE_DISTRIBUTION to sync the content from."
  73. exit 1
  74. fi
  75.  
  76. ONLY_POPULATE_TEMPLATE=""
  77.  
  78. if [[ "$ONLY_POPULATE_TEMPLATE" = 'true' ]]; then
  79. if [[ -z "$STY" || -z "$TMUX" ]]; then
  80. echo "Assuming this script is not being run via Jenkins."
  81. echo "As this script could take anywhere between 2 to 5 hrs,"
  82. echo "Recommend to run this script from a SCREEN or TMUX Session Only."
  83. echo "Set ONLY_POPULATE_TEMPLATE to false in this script, to override without Screen or Tmux, if needed."
  84. echo "Example: 'yum install screen -y ; screen', should suffice."
  85. exit 1
  86. fi
  87. fi
  88.  
  89.  
  90. # Below are the default ID's of various Satellite6 entities.
  91. # Basic Variables.
  92. # ORG of ID 1 refers to 'Default Organization'
  93. ORG=1
  94. # LOC of ID 2 refers to 'Default Location'
  95. LOC=2
  96.  
  97. # The ID of the Default/Internal capsule, which is Satellite6 itself.
  98. CAPSULE_ID=1
  99.  
  100. # The default puppet environment which is "production"
  101. PUPPET_ENV=1
  102.  
  103. # Depending upon the below values only certain commands get excuted in this script.
  104. RHELOS=$(awk '{print $7}' /etc/redhat-release | cut -d . -f1)
  105.  
  106. SAT_VERSION=6.3
  107.  
  108. # Plan is to install satellite6 with only RHEL6-x86_4 and RHEL7-x86_64 content
  109. # TODO: If more content is planned to be synced, set it under MINIMAL_INSTALL="false".
  110. MINIMAL_INSTALL="true"
  111.  
  112. # The below values get populated from the sat6_repo_urls.conf file.
  113. # Sat6 Tools and Capsule Repo Variables
  114. if [ "${SATELLITE_DISTRIBUTION}" = "GA" ]; then
  115. RHEL6_TOOLS_PRD="Red Hat Enterprise Linux Server"
  116. RHEL6_TOOLS_REPO="Red Hat Satellite Tools ${SAT_VERSION} for RHEL 6 Server RPMs x86_64"
  117. RHEL7_TOOLS_PRD="Red Hat Enterprise Linux Server"
  118. RHEL7_TOOLS_REPO="Red Hat Satellite Tools ${SAT_VERSION} for RHEL 7 Server RPMs x86_64"
  119. SAT6C6_PRODUCT="Red Hat Satellite Capsule"
  120. CAPSULE6_REPO="Red Hat Satellite Capsule ${SAT_VERSION} for RHEL 6 Server RPMs x86_64"
  121. SAT6C7_PRODUCT="Red Hat Satellite Capsule"
  122. CAPSULE7_REPO="Red Hat Satellite Capsule ${SAT_VERSION} for RHEL 7 Server RPMs x86_64"
  123. else
  124. RHEL6_TOOLS_PRD=Sat6Tools6
  125. RHEL6_TOOLS_REPO=sat6tool6
  126. RHEL6_TOOLS_URL="rhel6_tools_url"
  127. RHEL7_TOOLS_PRD=Sat6Tools7
  128. RHEL7_TOOLS_REPO=sat6tool7
  129. RHEL7_TOOLS_URL="rhel7_tools_url"
  130. SAT6C6_PRODUCT=Sat6Capsule6
  131. CAPSULE6_REPO=capsule6
  132. CAPSULE6_URL="capsule6_url"
  133. SAT6C7_PRODUCT=Sat6Capsule7
  134. CAPSULE7_REPO=capsule7
  135. CAPSULE7_URL="capsule7_url"
  136. fi
  137.  
  138. # Use this directly for ENV_VAR population and non side-effects on Satellite6 setup.
  139. function satellite () {
  140. hammer -u ${ADMIN_USER} -p ${ADMIN_PASSWORD} "$@"
  141. if [ $? -ne 0 ]; then exit 1 ; fi
  142. }
  143.  
  144. # Use this for all side-effects on a Satellite6 setup.
  145. function satellite_runner () {
  146. [ ! -f /root/task_list.txt ] && touch /root/task_list.txt
  147. VAL=`echo "$@"`
  148. grep -Fxq "${VAL}" /root/task_list.txt > /dev/null
  149. RESULT=`echo $?`
  150. if [ "${RESULT}" -ne 0 ]; then
  151. satellite "$@"
  152. echo "$@" >> /root/task_list.txt
  153. fi
  154. }
  155.  
  156. function create-repo () {
  157. PRODUCT=$1
  158. REPO=$2
  159. URL=$3
  160. echo Creating Product "${PRODUCT}"
  161. satellite_runner product create --name "${PRODUCT}" --organization-id "${ORG}"
  162. PRODUCT_ID=$(satellite --csv product list --organization-id "${ORG}" --name "${PRODUCT}" | tail -n1 | cut -f1 -d,)
  163. echo Creating Repository "${REPO}"
  164. satellite_runner repository create --name "${REPO}" --url "${URL}" --product-id "${PRODUCT_ID}" --content-type yum --publish-via-http true
  165. REPO_ID=$(satellite --csv repository list --organization-id "${ORG}" --product-id "${PRODUCT_ID}" | tail -n1 | cut -f1 -d,)
  166. echo Synchronizing repository "${REPO}"
  167. satellite_runner repository synchronize --id "${REPO_ID}"
  168. }
  169.  
  170. # Create 2 lifecycle-environments
  171. satellite_runner lifecycle-environment create --name='DEV' --prior='Library' --organization-id="${ORG}"
  172. satellite_runner lifecycle-environment create --name='QE' --prior='DEV' --organization-id="${ORG}"
  173. satellite_runner lifecycle-environment create --name='PROD' --prior='QE' --organization-id="${ORG}"
  174.  
  175. # Update the DOWNLOAD_POLICY to sync content.
  176. satellite_runner settings set --name default_download_policy --value "${DOWNLOAD_POLICY}"
  177.  
  178. # Fetch the manifest from server.
  179. [ ! -f "${HOME}"/manifest-latest.zip ] && wget -O "${HOME}"/manifest-latest.zip "${MANIFEST_LOCATION_URL}"
  180.  
  181. # Import Manifest.
  182. satellite_runner subscription upload --organization-id "${ORG}" --file "${HOME}"/manifest-latest.zip
  183.  
  184. # Enable Red Hat repositories
  185. # Kickstart trees
  186. satellite_runner repository-set enable --name="Red Hat Enterprise Linux 7 Server (Kickstart)" --basearch="x86_64" --releasever="7.4" --product "Red Hat Enterprise Linux Server" --organization-id="${ORG}"
  187. satellite_runner repository-set enable --name="Red Hat Enterprise Linux 6 Server (Kickstart)" --basearch="x86_64" --releasever="6.8" --product "Red Hat Enterprise Linux Server" --organization-id="${ORG}"
  188.  
  189. # 'Base' OS RPMs
  190. satellite_runner repository-set enable --name="Red Hat Enterprise Linux 7 Server (RPMs)" --basearch="x86_64" --releasever="7Server" --product "Red Hat Enterprise Linux Server" --organization-id="${ORG}"
  191. satellite_runner repository-set enable --name="Red Hat Enterprise Linux 6 Server (RPMs)" --basearch="x86_64" --releasever="6Server" --product "Red Hat Enterprise Linux Server" --organization-id="${ORG}"
  192.  
  193. # Satellite6 CDN RPMS
  194. if [ "${SATELLITE_DISTRIBUTION}" = "GA" ]; then
  195. # Satellite6 Tools RPMS
  196. satellite_runner repository-set enable --name="Red Hat Satellite Tools ${SAT_VERSION} (for RHEL 7 Server) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Server" --organization-id="${ORG}"
  197. satellite_runner repository-set enable --name="Red Hat Satellite Tools ${SAT_VERSION} (for RHEL 6 Server) (RPMs)" --basearch="x86_64" --product "Red Hat Enterprise Linux Server" --organization-id="${ORG}"
  198. # Satellite6 Capsule RPMS
  199. satellite_runner repository-set enable --name="Red Hat Satellite Capsule ${SAT_VERSION} (for RHEL 7 Server) (RPMs)" --basearch="x86_64" --product "Red Hat Satellite Capsule" --organization-id="${ORG}"
  200. satellite_runner repository-set enable --name="Red Hat Satellite Capsule ${SAT_VERSION} (for RHEL 7 Server) (RPMs)" --basearch="x86_64" --product "Red Hat Satellite Capsule" --organization-id="${ORG}"
  201. fi
  202.  
  203. # Synchronize all repositories except for Puppet repositories which don't have URLs
  204. for repo in $(satellite --csv repository list --organization-id="${ORG}" --per-page=1000 | grep -vi 'puppet' | cut -d ',' -f 1 | grep -vi '^ID'); do
  205. satellite_runner repository synchronize --id "${repo}" --organization-id="${ORG}" --async
  206. done
  207.  
  208. # Check the async tasks for completion.
  209. for id in `satellite --csv task list | grep -i synchronize | awk -F "," '{print $1}'`; do satellite_runner task progress --id $id; done
  210.  
  211. # Create Repos and Sync Repositories.
  212. # Create both Tools for RHEL6 and RHEL7 and Capsule for RHEL6 and RHEL7
  213.  
  214. if [ "${SATELLITE_DISTRIBUTION}" != "GA" ]; then
  215. create-repo "${RHEL6_TOOLS_PRD}" "${RHEL6_TOOLS_REPO}" "${RHEL6_TOOLS_URL}"
  216. create-repo "${RHEL7_TOOLS_PRD}" "${RHEL7_TOOLS_REPO}" "${RHEL7_TOOLS_URL}"
  217. create-repo "${SAT6C7_PRODUCT}" "${CAPSULE7_REPO}" "${CAPSULE7_URL}"
  218. if [ "${SAT_VERSION}" != "6.3" ]; then
  219. create-repo "${SAT6C6_PRODUCT}" "${CAPSULE6_REPO}" "${CAPSULE6_URL}"
  220. fi
  221. fi
  222.  
  223. #Create content views
  224. satellite_runner content-view create --name 'RHEL 7 CV' --organization-id="${ORG}"
  225. satellite_runner content-view create --name 'RHEL 6 CV' --organization-id="${ORG}"
  226. satellite_runner content-view create --name 'Capsule RHEL 7 CV' --organization-id="${ORG}"
  227.  
  228. # Add content to content views
  229. # RHEL 7
  230. satellite_runner content-view add-repository --name='RHEL 7 CV' --organization-id="${ORG}" --product='Red Hat Enterprise Linux Server' --repository='Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.4'
  231. satellite_runner content-view add-repository --name='RHEL 7 CV' --organization-id="${ORG}" --product='Red Hat Enterprise Linux Server' --repository='Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server'
  232. satellite_runner content-view add-repository --name='RHEL 7 CV' --organization-id="${ORG}" --product="${RHEL7_TOOLS_PRD}" --repository="${RHEL7_TOOLS_REPO}"
  233. satellite_runner content-view publish --name='RHEL 7 CV' --organization-id="${ORG}"
  234. satellite_runner content-view version promote --content-view='RHEL 7 CV' --organization-id="${ORG}" --to-lifecycle-environment=DEV --from-lifecycle-environment="Library"
  235.  
  236. # RHEL 6
  237. satellite_runner content-view add-repository --name='RHEL 6 CV' --organization-id="${ORG}" --product='Red Hat Enterprise Linux Server' --repository='Red Hat Enterprise Linux 6 Server Kickstart x86_64 6.8'
  238. satellite_runner content-view add-repository --name='RHEL 6 CV' --organization-id="${ORG}" --product='Red Hat Enterprise Linux Server' --repository='Red Hat Enterprise Linux 6 Server RPMs x86_64 6Server'
  239. satellite_runner content-view add-repository --name='RHEL 6 CV' --organization-id="${ORG}" --product="${RHEL6_TOOLS_PRD}" --repository="${RHEL6_TOOLS_REPO}"
  240. satellite_runner content-view publish --name='RHEL 6 CV' --organization-id="${ORG}"
  241. satellite_runner content-view version promote --content-view='RHEL 6 CV' --organization-id="${ORG}" --to-lifecycle-environment=DEV --from-lifecycle-environment="Library"
  242.  
  243. if [ "${RHELOS}" = "7" ]; then
  244. # Capsule RHEL7
  245. satellite_runner content-view add-repository --name='Capsule RHEL 7 CV' --organization-id="${ORG}" --product='Red Hat Enterprise Linux Server' --repository='Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server'
  246. satellite_runner content-view add-repository --name='Capsule RHEL 7 CV' --organization-id="${ORG}" --product="${RHEL7_TOOLS_PRD}" --repository="${RHEL7_TOOLS_REPO}"
  247. satellite_runner content-view add-repository --name='Capsule RHEL 7 CV' --organization-id="${ORG}" --product="${SAT6C7_PRODUCT}" --repository="${CAPSULE7_REPO}"
  248. satellite_runner content-view publish --name='Capsule RHEL 7 CV' --organization-id="${ORG}"
  249. satellite_runner content-view version promote --content-view='Capsule RHEL 7 CV' --organization-id="${ORG}" --to-lifecycle-environment=DEV --from-lifecycle-environment="Library"
  250. else
  251. # Capsule RHEL6
  252. satellite_runner content-view add-repository --name='Capsule RHEL 6 CV' --organization-id="${ORG}" --product='Red Hat Enterprise Linux Server' --repository='Red Hat Enterprise Linux 6 Server RPMs x86_64 6Server'
  253. satellite_runner content-view add-repository --name='Capsule RHEL 6 CV' --organization-id="${ORG}" --product="${RHEL6_TOOLS_PRD}" --repository="${RHEL6_TOOLS_REPO}"
  254. satellite_runner content-view add-repository --name='Capsule RHEL 6 CV' --organization-id="${ORG}" --product="${SAT6C6_PRODUCT}" --repository="${CAPSULE6_REPO}"
  255. satellite_runner content-view publish --name='Capsule RHEL 6 CV' --organization-id="${ORG}"
  256. satellite_runner content-view version promote --content-view='Capsule RHEL 6 CV' --organization-id="${ORG}" --to-lifecycle-environment=DEV --from-lifecycle-environment="Library"
  257. fi
  258.  
  259. # Activation Keys
  260. # Create activation keys
  261. satellite_runner activation-key create --name 'ak-rhel-7' --content-view='RHEL 7 CV' --lifecycle-environment='DEV' --organization-id="${ORG}"
  262. satellite_runner activation-key create --name 'ak-rhel-6' --content-view='RHEL 6 CV' --lifecycle-environment='DEV' --organization-id="${ORG}"
  263. satellite_runner activation-key create --name "ak-capsule-${RHELOS}" --content-view="Capsule RHEL ${RHELOS} CV" --lifecycle-environment='DEV' --organization-id="${ORG}"
  264.  
  265. satellite_runner activation-key update --name 'ak-rhel-7' --auto-attach no --organization-id="${ORG}"
  266. satellite_runner activation-key update --name 'ak-rhel-6' --auto-attach no --organization-id="${ORG}"
  267. satellite_runner activation-key update --name "ak-capsule-${RHELOS}" --auto-attach no --organization-id="${ORG}"
  268.  
  269. # Add both RHEL6 and RHEL7 Activation keys.
  270. # RHEL 7 activation key
  271. RHEL_SUBS_ID=$(satellite --csv subscription list --organization-id=1 | grep -i "Red Hat Enterprise Linux Server, Premium (8 sockets) (Unlimited guests)" | awk -F "," '{print $1}' | grep -vi id)
  272. TOOLS7_SUBS_ID=$(satellite --csv subscription list --organization-id=1 --search="name=${RHEL7_TOOLS_PRD}" | awk -F "," '{print $1}' | grep -vi id)
  273. satellite_runner activation-key add-subscription --name='ak-rhel-7' --organization-id="${ORG}" --subscription-id="${RHEL_SUBS_ID}"
  274.  
  275. # As SATELLITE TOOLS REPO is already part of RHEL subscription.
  276. if [ "${SATELLITE_DISTRIBUTION}" != "GA" ]; then
  277. satellite_runner activation-key add-subscription --name='ak-rhel-7' --organization-id="${ORG}" --subscription-id="${TOOLS7_SUBS_ID}"
  278. fi
  279.  
  280. # RHEL 6 activation key
  281. TOOLS6_SUBS_ID=$(satellite --csv subscription list --organization-id=1 --search="name=${RHEL6_TOOLS_PRD}" | awk -F "," '{print $1}' | grep -vi id)
  282. satellite_runner activation-key add-subscription --name='ak-rhel-6' --organization-id="${ORG}" --subscription-id="${RHEL_SUBS_ID}"
  283.  
  284. # As SATELLITE TOOLS REPO is already part of RHEL subscription.
  285. if [ "${SATELLITE_DISTRIBUTION}" != "GA" ]; then
  286. satellite_runner activation-key add-subscription --name='ak-rhel-6' --organization-id="${ORG}" --subscription-id="${TOOLS6_SUBS_ID}"
  287. fi
  288.  
  289. # Add both RHEL6 and RHEL7 Capsule Activation keys.
  290. SATELLITE_SUBS_ID=$(satellite --csv subscription list --organization-id=1 | grep -i "Red Hat Satellite Employee Subscription" | awk -F "," '{print $1}' | grep -vi id)
  291. if [ "${RHELOS}" = "7" ]; then
  292.  
  293. # Capsule 7 activation key
  294. if [ "${SATELLITE_DISTRIBUTION}" != "GA" ]; then
  295. CAPSULE7_SUBS_ID=$(satellite --csv subscription list --organization-id=1 --search="name=${SAT6C7_PRODUCT}" | awk -F "," '{print $1}' | grep -vi id)
  296. else
  297. CAPSULE7_SUBS_ID="${SATELLITE_SUBS_ID}"
  298. fi
  299.  
  300. satellite_runner activation-key add-subscription --name='ak-capsule-7' --organization-id="${ORG}" --subscription-id="${RHEL_SUBS_ID}"
  301. satellite_runner activation-key add-subscription --name='ak-capsule-7' --organization-id="${ORG}" --subscription-id="${CAPSULE7_SUBS_ID}"
  302.  
  303. # As SATELLITE TOOLS REPO is already part of RHEL subscription.
  304. if [ "${SATELLITE_DISTRIBUTION}" != "GA" ]; then
  305. satellite_runner activation-key add-subscription --name='ak-capsule-7' --organization-id="${ORG}" --subscription-id="${TOOLS7_SUBS_ID}"
  306. fi
  307. else
  308. # Capsule 6 activation key
  309. if [ "${SATELLITE_DISTRIBUTION}" != "GA" ]; then
  310. CAPSULE6_SUBS_ID=$(satellite --csv subscription list --organization-id=1 --search="name=${SAT6C6_PRODUCT}" | awk -F "," '{print $1}' | grep -vi id)
  311. else
  312. CAPSULE6_SUBS_ID="${SATELLITE_SUBS_ID}"
  313. fi
  314.  
  315. satellite_runner activation-key add-subscription --name='ak-capsule-6' --organization-id="${ORG}" --subscription-id="${RHEL_SUBS_ID}"
  316. satellite_runner activation-key add-subscription --name='ak-capsule-6' --organization-id="${ORG}" --subscription-id="${CAPSULE6_SUBS_ID}"
  317.  
  318. # As SATELLITE TOOLS REPO is already part of RHEL subscription.
  319. if [ "${SATELLITE_DISTRIBUTION}" != "GA" ]; then
  320. satellite_runner activation-key add-subscription --name='ak-capsule-6' --organization-id="${ORG}" --subscription-id="${TOOLS6_SUBS_ID}"
  321. fi
  322. fi
  323.  
  324. # Update Domain with Capsule's ID.
  325. DOMAIN_ID=$(satellite --csv domain list --search "$(hostname -d)" | grep -vi ID | awk -F "," '{print $1}')
  326. echo DOMAIN_ID is "${DOMAIN_ID}"
  327. satellite_runner domain update --id "${DOMAIN_ID}" --organization-ids "${ORG}" --location-ids "${LOC}" --dns-id 1
  328.  
  329. # Create subnet and associate various entities to it.
  330. satellite_runner subnet create --name "${SUBNET_NAME}" --network "${SUBNET_RANGE}" --mask "${SUBNET_MASK}" --gateway "${SUBNET_GATEWAY}" --dns-id "${CAPSULE_ID}" --dhcp-id "${CAPSULE_ID}" --tftp-id "${CAPSULE_ID}" --domain-ids "${DOMAIN_ID}" --ipam DHCP --boot-mode DHCP --organization-ids="${ORG}" --location-ids="${LOC}"
  331.  
  332. # Compute Resource Creations
  333.  
  334. # Create Libvirt CR
  335. satellite_runner compute-resource create --name "${COMPUTE_RESOURCE_NAME_LIBVIRT}" --provider Libvirt --url "${LIBVIRT_URL}" --location-ids "${LOC}" --organization-ids "${ORG}" --set-console-password false
  336.  
  337. # Create Ovirt CR
  338. if [ "${SAT_VERSION}" != "6.3" ]; then
  339. satellite_runner compute-resource create --provider Ovirt --url "${RHEV_URL}" --name "rhevm1" --user "${RHEV_USERNAME}" --password "${RHEV_PASSWORD}" --location-ids "${LOC}" --organization-ids "${ORG}" --datacenter "${RHEV_DATACENTER_UUID}"
  340. else
  341. satellite_runner compute-resource create --provider Ovirt --url "${RHEV_URL}" --name "rhevm1" --user "${RHEV_USERNAME}" --password "${RHEV_PASSWORD}" --location-ids "${LOC}" --organization-ids "${ORG}" --uuid "${RHEV_DATACENTER_UUID}"
  342. fi
  343.  
  344. # Create OpenStack CR
  345. # Disabled this temporarily till we investigate the change in login details.
  346. #satellite_runner compute-resource create --name openstack_provider --provider Openstack --url "${OS_URL}" --location-ids "${LOC}" --organization-ids "${ORG}" --user "${OS_USERNAME}" --password "${OS_PASSWORD}"
  347.  
  348. # Associations
  349.  
  350. SMARTPROXYID=$(satellite --csv proxy list | grep "${HOSTNAME}" | awk -F ',' '{print $1}')
  351. echo SMART-PROXY ID: "${SMARTPROXYID}"
  352.  
  353. echo Adding Smart-Proxy to Default location and to 'Default Organization'
  354. satellite_runner location add-smart-proxy --id="${LOC}" --smart-proxy-id="${SMARTPROXYID}"
  355. satellite_runner organization add-smart-proxy --id="${ORG}" --smart-proxy-id="${SMARTPROXYID}"
  356.  
  357. echo Adding Default Organization to Default Location
  358. satellite_runner location add-organization --id="${LOC}" --organization='Default Organization'
  359.  
  360. echo Assign Default ORganization and Default Location to Production Puppet Environment.
  361. satellite_runner environment update --organization-ids "${ORG}" --location-ids "${LOC}" --id 1
  362.  
  363. # Import puppet-classes from default capsule to environment.
  364. satellite_runner capsule import-classes --id 1 --environment-id 1
  365.  
  366. # Populate the RHEL6 and RHEL7 OS ID
  367.  
  368. RHEL7_OS_ID=$(satellite --csv os list | grep "7" | cut -d ',' -f1 | grep -vi "^id")
  369. echo "RHEL7 OS ID is: ${RHEL7_OS_ID}"
  370.  
  371. RHEL6_OS_ID=$(satellite --csv os list | grep "6" | cut -d ',' -f1 | grep -vi "^id")
  372. echo "RHEL6 OS ID is: ${RHEL6_OS_ID}"
  373.  
  374.  
  375. if [ "${SAT_VERSION}" = "6.3" ]; then
  376. # Create Host-Groups and associate activation key as a parameter.
  377.  
  378. satellite_runner hostgroup create --name='RHEL 6 Server 64-bit HG' --content-view='RHEL 6 CV' --environment-id="${PUPPET_ENV}" --lifecycle-environment='DEV' --content-source-id="${CAPSULE_ID}" --puppet-proxy="$(hostname)" --puppet-ca-proxy="$(hostname)" --query-organization-id="${ORG}" --puppet-classes='access_insights_client,foreman_scap_client' --domain-id="${DOMAIN_ID}" --subnet="${SUBNET_NAME}" --architecture='x86_64' --operatingsystem-id="${RHEL6_OS_ID}" --partition-table='Kickstart default' --location-ids="${LOC}" --pxe-loader 'PXELinux BIOS'
  379.  
  380. satellite_runner hostgroup set-parameter --hostgroup='RHEL 6 Server 64-bit HG' --name='kt_activation_keys' --value='ak-rhel-6'
  381.  
  382. satellite_runner hostgroup create --name='RHEL 7 Server 64-bit HG' --content-view='RHEL 7 CV' --environment-id="${PUPPET_ENV}" --lifecycle-environment='DEV' --content-source-id="${CAPSULE_ID}" --puppet-proxy="$(hostname)" --puppet-ca-proxy="$(hostname)" --query-organization-id="${ORG}" --puppet-classes='access_insights_client,foreman_scap_client' --domain-id="${DOMAIN_ID}" --subnet="${SUBNET_NAME}" --architecture='x86_64' --operatingsystem-id="${RHEL7_OS_ID}" --partition-table='Kickstart default' --location-ids="${LOC}" --pxe-loader 'PXELinux BIOS'
  383.  
  384. satellite_runner hostgroup set-parameter --hostgroup='RHEL 7 Server 64-bit HG' --name='kt_activation_keys' --value='ak-rhel-7'
  385. else
  386. # Assign Default Location to RHEL6 and RHEL7 medium.
  387. # NOTE: Medium does not appeat to exist for Satellite6.3
  388.  
  389. echo Assign Default Location to RHEL6 and RHEL7 medium.
  390. RHEL7_MEDIUM_ID=$(satellite --csv medium list --search='name~"Linux_7_Server_Kickstart_x86_64"' | cut -d ',' -f1 | grep -vi 'id')
  391. satellite_runner medium update --location-ids "${LOC}" --id "${RHEL7_MEDIUM_ID}"
  392. RHEL6_MEDIUM_ID=$(satellite --csv medium list --search='name~"Linux_6_Server_Kickstart_x86_64"' | cut -d ',' -f1 | grep -vi 'id')
  393. satellite_runner medium update --location-ids "${LOC}" --id "${RHEL6_MEDIUM_ID}"
  394.  
  395. # Create Host-Groups and associate activation key as a parameter.
  396. satellite_runner hostgroup create --name='RHEL 6 Server 64-bit HG' --content-view='RHEL 6 CV' --environment-id="${PUPPET_ENV}" --lifecycle-environment='DEV' --content-source-id="${CAPSULE_ID}" --puppet-proxy="$(hostname)" --puppet-ca-proxy="$(hostname)" --organization-id="${ORG}" --puppet-classes='access_insights_client,foreman_scap_client' --domain-id="${DOMAIN_ID}" --subnet="${SUBNET_NAME}" --architecture='x86_64' --operatingsystem-id="${RHEL6_OS_ID}" --partition-table='Kickstart default' --location-ids="${LOC}" --medium-id="${RHEL6_MEDIUM_ID}"
  397.  
  398. satellite_runner hostgroup set-parameter --hostgroup='RHEL 6 Server 64-bit HG' --name='kt_activation_keys' --value='ak-rhel-6'
  399.  
  400. satellite_runner hostgroup create --name='RHEL 7 Server 64-bit HG' --content-view='RHEL 7 CV' --environment-id="${PUPPET_ENV}" --lifecycle-environment='DEV' --content-source-id="${CAPSULE_ID}" --puppet-proxy="$(hostname)" --puppet-ca-proxy="$(hostname)" --organization-id="${ORG}" --puppet-classes='access_insights_client,foreman_scap_client' --domain-id="${DOMAIN_ID}" --subnet="${SUBNET_NAME}" --architecture='x86_64' --operatingsystem-id="${RHEL7_OS_ID}" --partition-table='Kickstart default' --location-ids="${LOC}" --medium-id="${RHEL7_MEDIUM_ID}"
  401.  
  402. satellite_runner hostgroup set-parameter --hostgroup='RHEL 7 Server 64-bit HG' --name='kt_activation_keys' --value='ak-rhel-7'
  403. fi
  404.  
  405. # Provision a host with Libvirt Provider.
  406. # Better create hosts from UI, as it has too many parameters to be passed and things appear to keep changing.
  407. #satellite_runner host create --name='rhel-7-libvirt' --root-pass='changeme' --organization-id="${ORG}" --location-id="${LOC}" --hostgroup="RHEL 7 Server 64-bit HG" --compute-resource="$COMPUTE_RESOURCE_NAME_LIBVIRT" --compute-attributes="cpus=1, memory=1073741824, start=1" --interface="primary=true, compute_type=bridge, compute_bridge=${SUBNET_NAME}, compute_model=virtio" --volume="capacity=10G,format_type=qcow2"
  408.  
  409. #satellite_runner host create --name='rhel-6-libvirt' --root-pass='changeme' --organization-id="${ORG}" --location-id="${LOC}" --hostgroup="RHEL 6 Server 64-bit HG" --compute-resource="$COMPUTE_RESOURCE_NAME_LIBVIRT" --compute-attributes="cpus=1, memory=1073741824, start=1" --interface="primary=true, compute_type=bridge, compute_bridge=${SUBNET_NAME}, compute_model=virtio" --volume="capacity=10G,format_type=qcow2"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement