{"id":670,"date":"2016-03-15T18:52:30","date_gmt":"2016-03-15T18:52:30","guid":{"rendered":"https:\/\/www.nicktailor.com\/?p=670"},"modified":"2022-10-21T11:45:04","modified_gmt":"2022-10-21T11:45:04","slug":"how-to-automate-your-redhat-satellite-channel-cloning","status":"publish","type":"post","link":"https:\/\/nicktailor.com\/tech-blog\/how-to-automate-your-redhat-satellite-channel-cloning\/","title":{"rendered":"How to automate your RedHat Satellite 5.x Channel Cloning"},"content":{"rendered":"<ul>\n<li>In order for the scripts to work without sending your password to &#8220;ps&#8221; you will need to setup a config for spacecmd<\/li>\n<\/ul>\n<h2 class=\"editable\">Credential File<a title=\"Edit section\" href=\"http:\/\/172.17.44.129\/Operating_Systems\/Linux\/Deploying_Linux_Servers\/Cloning_scripts_for_Redhat_Satellite?action=edit&amp;sectionId=1\"><span class=\"icon\"><img decoding=\"async\" class=\"sectionedit\" src=\"http:\/\/172.17.44.129\/skins\/common\/icons\/icon-trans.gif\" alt=\"Edit section\"\/><\/span><\/a><\/h2>\n<p>Spacecmd can be configured with a credentials file so you are not prompted for a username\/password each time. This allows for easier scripting.<\/p>\n<ol>\n<li>Create a hidden spacecmd directory in your home. Lock down permissions.\n<div class=\"code\">\n<pre>mkdir ~\/.spacecmd\nchmod 700 ~\/.spacecmd\n<\/pre>\n<\/div>\n<\/li>\n<\/ol>\n<ol start=\"2\">\n<li>Create a config file in the directory and give proper permissions.\n<div class=\"code\">\n<pre>touch ~\/.spacecmd\/config\nchmod 600 ~\/.spacecmd\/config\n<\/pre>\n<\/div>\n<\/li>\n<\/ol>\n<ol start=\"3\">\n<li>Edit the config file and fill in the header, Spacewalk server fqdn, username, and password.\n<div class=\"code\">\n<pre>vim ~\/.spacecmd\/config\n\n<span class=\"o\">[<\/span>spacecmd<span class=\"o\">]<\/span>\n<span class=\"nv\">server<\/span><span class=\"o\">=spacewalk.nicktailor.com<\/span>\n<span class=\"nv\">username<\/span><span class=\"o\">=<\/span>usernamehere\n<span class=\"nv\">password<\/span><span class=\"o\">=<\/span>passwordhere<\/pre>\n<\/div>\n<\/li>\n<\/ol>\n<p><u><strong>Clone scripts<br \/>\n<\/strong><\/u><a href=\"https:\/\/www.nicktailor.com\/files\/clonechannel.redhat7.sh\">https:\/\/www.nicktailor.com\/files\/clonechannel.redhat7.sh<\/a><br \/>\n<a href=\"https:\/\/www.nicktailor.com\/files\/clonechannel.redhat6.sh\">https:\/\/www.nicktailor.com\/files\/clonechannel.redhat6.sh<\/a><br \/>\n<a href=\"https:\/\/www.nicktailor.com\/files\/clonechannel.redhat5.sh\">https:\/\/www.nicktailor.com\/files\/clonechannel.redhat5.sh<\/a><\/p>\n<p><strong><span style=\"text-decoration: underline;\">REDHAT 7 (EXAMPLE)<\/span><\/strong><br \/>\n#!\/bin\/bash<br \/>\nspacewalkServer=spacewalk.nicktailor.com<br \/>\ndefaultOrgAdmin=USER<\/p>\n<p>read -p &#8220;Enter to Continue&#8221;<\/p>\n<div>\n<div>BASE_CHANNEL=&#8221;rhel-x86_64-server-7&#8243;<\/div>\n<div>CHILD_CHANNELS=&#8221;rhel-x86_64-server-7-thirdparty-oracle-java rhel-x86_64-server-7-rhscl-1 rhel-x86_64-server-optional-7 rhel-x86_64-server-supplementary-7 rhn-tools-rhel-x86_64-server-7 epel_rhel7_x86_64 nginx.org-packages&#8221;<\/div>\n<div><\/div>\n<div>SPECIAL=&#8221;rhel-tools-rhel-x86_64-server-6&#8243;<\/div>\n<div>DATESTRING=`date +20%y-%B-%d`<\/div>\n<div>echo Run on $DATESTRING &gt;&gt; clonechannels-$DATESTRING.log<\/div>\n<div><\/div>\n<div>UNDO_FILE=clonechannels-$DATESTRING.undo<\/div>\n<div><\/div>\n<div>rm -f $UNDO_FILE<\/div>\n<div>rm -f clonechannels-$DATESTRING.log<\/div>\n<div><\/div>\n<div>echo Undo file is $UNDO_FILE<\/div>\n<div>echo DATESTRING = $DATESTRING<\/div>\n<div><\/div>\n<div>BASE_CHANNEL_NAME=$BASE_CHANNEL-$DATESTRING<\/div>\n<div><\/div>\n<div>echo BASE_CHANNEL_NAME = $BASE_CHANNEL_NAME<\/div>\n<div><\/div>\n<div>echo spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_clone -n $BASE_CHANNEL_NAME -l $BASE_CHANNEL_NAME -s $BASE_CHANNEL -g &gt;&gt; clonechannels-$DATESTRING.log<\/div>\n<div>spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_clone -n $BASE_CHANNEL_NAME -l $BASE_CHANNEL_NAME -s $BASE_CHANNEL -g<\/div>\n<div><\/div>\n<div>echo spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_setorgaccess $BASE_CHANNEL_NAME -e &gt;&gt; clonechannels-$DATESTRING.log<\/div>\n<div>spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_setorgaccess $BASE_CHANNEL_NAME -e<\/div>\n<div><\/div>\n<div>for CHILD_CHANNEL in ${CHILD_CHANNELS}<\/div>\n<div>do<\/div>\n<div>CHILD_CHANNEL_NAME=$CHILD_CHANNEL-$DATESTRING<\/div>\n<div>echo CHILD_CHANNEL_NAME = $CHILD_CHANNEL_NAME<\/div>\n<div>echo spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_clone -n $CHILD_CHANNEL_NAME -l $CHILD_CHANNEL_NAME -p $BASE_CHANNEL_NAME -s $CHILD_CHANNEL -g &gt;&gt; clonechannels-$DATESTRING.log<\/div>\n<div><\/div>\n<div>spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_clone -n $CHILD_CHANNEL_NAME -l $CHILD_CHANNEL_NAME -p $BASE_CHANNEL_NAME -s $CHILD_CHANNEL -g<\/div>\n<div><\/div>\n<div>if [ $CHILD_CHANNEL == &#8220;rhn-tools-rhel-x86_64-server-7&#8221; ]<\/div>\n<div>then spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_clone -n $SPECIAL -l $SPECIAL -p $BASE_CHANNEL_NAME -s $CHILD_CHANNEL -g<\/div>\n<div>fi<\/div>\n<div><\/div>\n<div>echo spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_setorgaccess $CHILD_CHANNEL_NAME -e &gt;&gt; clonechannels-$DATESTRING.log<\/div>\n<div>spacecmd -u $defaultOrgAdmin -s $spacewalkServer &#8212; softwarechannel_setorgaccess $CHILD_CHANNEL_NAME -e<\/div>\n<div><\/div>\n<div>echo spacecmd -u $defaultOrgAdmin -s $spacewalkServer -y &#8212; softwarechannel_delete $CHILD_CHANNEL_NAME &gt;&gt; $UNDO_FILE<\/div>\n<div>done<\/div>\n<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In order for the scripts to work without sending your password to &#8220;ps&#8221; you will need to setup a config for spacecmd Credential File Spacecmd can be configured with a credentials file so you are not prompted for a username\/password each time. This allows for easier scripting. Create a hidden spacecmd directory in your home. Lock down permissions. mkdir ~\/.spacecmd<a href=\"https:\/\/nicktailor.com\/tech-blog\/how-to-automate-your-redhat-satellite-channel-cloning\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,138,26],"tags":[],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux","category-red-hat-satellite"],"_links":{"self":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":17,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":1608,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/670\/revisions\/1608"}],"wp:attachment":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}