public
Last active

Script to create an Organization with custom providers, users and roles.

  • Download Gist
lenovo.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
#!/bin/bash -x
 
function kk() {
KATELLO_PATH=/usr/bin/katello
user=$1
password=$2
shift 2
date && $KATELLO_PATH -u $user -p $password "$@"
}
 
# Fetch fake dummy GPG key
wget https://raw.github.com/gist/3667453/0046825fdeb4c75bb563e2434ccab4617054654b/dummy.gpg
 
# Create i18n org and products
kk admin admin user create --username "Mane" --password redhat --email "mane@somecorp.com"
kk admin admin user assign_role --username "Mane" --role "Administrator"
kk Mane redhat org create --name "São Paulo" --label saopaulo
kk Mane redhat environment create --name "Xingú" --label xingu --prior Library --org "São Paulo"
 
kk Mane redhat provider create --name São_Paulo_prov --org "São Paulo"
kk Mane redhat product create --name São_Paulo_prod --label saopaulo_product --provider São_Paulo_prov --org "São Paulo"
kk Mane redhat repo create --name Zoológico --label zoologico --url http://tstrachota.fedorapeople.org/dummy_repos/zoo/ --product São_Paulo_prod --org "São Paulo"
 
kk Mane redhat provider synchronize --name São_Paulo_prov --org "São Paulo"
 
katello -u admin -p admin org create --name Tupinambá
katello -u admin -p admin environment create --name Mild --prior Library --org Tupinambá
katello -u admin -p admin provider create --name Animals --org Tupinambá
katello -u admin -p admin product create --name Zoo --provider Animals --org Tupinambá
katello -u admin -p admin repo create --name Animals1 --url http://omaciel.fedorapeople.org/fakerepo01/ --product Zoo --org Tupinambá
katello -u admin -p admin repo create --name Pererê --url http://omaciel.fedorapeople.org/fakerepo01/ --product Zoo --org Tupinambá
katello -u admin -p admin provider synchronize --name Animals --org Tupinambá
 
# Create the QE organization and environments
kk admin admin org create --name QE
kk admin admin environment create --name DEV --prior Library --org QE
kk admin admin environment create --name QE --prior DEV --org QE
kk admin admin environment create --name GA --prior QE --org QE
 
kk admin admin provider create --name Community --org QE
kk admin admin product create --name Nightly --provider Community --org QE
kk admin admin repo create --name Katello --url "http://fedorapeople.org/groups/katello/releases/yum/nightly/RHEL/6Server/x86_64/" --product Nightly --org QE
kk admin admin repo create --name Pulp --url "http://fedorapeople.org/groups/katello/releases/yum/katello-pulp/RHEL/6Server/x86_64/" --product Nightly --org QE
kk admin admin repo create --name Candlepin --url "http://fedorapeople.org/groups/katello/releases/yum/katello-candlepin/RHEL/6Server/x86_64/" --product Nightly --org QE
kk admin admin repo create --name Foreman --url "http://fedorapeople.org/groups/katello/releases/yum/katello-foreman/RHEL/6Server/x86_64/" --product Nightly --org QE
 
kk admin admin provider create --name Generic --org QE
kk admin admin product create --name Dependencies --provider Generic --org QE
kk admin admin repo create --name Epel --url "http://ftp.osuosl.org/pub/fedora-epel/6/x86_64/" --product Dependencies --org QE
 
kk admin admin provider synchronize --name="Community" --org QE
kk admin admin provider synchronize --name="Generic" --org QE
 
kk admin admin changeset create --name promote01 --environment DEV --org QE
kk admin admin changeset update --name promote01 --environment DEV --org QE --add_product Nightly
kk admin admin changeset update --name promote01 --environment DEV --org QE --add_product Dependencies
kk admin admin changeset apply --name promote01 --environment DEV --org QE
 
kk admin admin sync_plan create --org QE --interval daily --date `date +"%Y-%m-%d"` --time "06:00:00" --name "Testing Daily"
kk admin admin product set_plan --org QE --name "Nightly" --plan "Testing Daily"
 
# Create activation key
kk admin admin activation_key create --name katellome --org QE --environment DEV
for i in `kk admin admin org subscriptions --name QE | grep ^Id: | awk '{print $2}'`; do kk admin admin activation_key update --name katellome --org QE --add_subscription $i; done
 
 
# Create the Alphabet Soup organization and environments
kk admin admin org create --name "AlphabetSoup"
kk admin admin environment create --name Cook --prior Library --org AlphabetSoup
kk admin admin environment create --name Taste --prior Cook --org AlphabetSoup
kk admin admin environment create --name Sell --prior Taste --org AlphabetSoup
 
kk admin admin provider create --name Animals --org AlphabetSoup
kk admin admin product create --name Zoo --provider Animals --org AlphabetSoup
kk admin admin gpg_key create --name Zoo --file dummy.gpg --org AlphabetSoup
kk admin admin product update --name Zoo --gpgkey Zoo --org AlphabetSoup
kk admin admin repo create --name Animals --url "http://omaciel.fedorapeople.org/fakerepo01/" --product Zoo --org AlphabetSoup
kk admin admin repo create --name Countries --url "http://omaciel.fedorapeople.org/fakerepo02/" --product Zoo --org AlphabetSoup
kk admin admin repo synchronize --name Animals --product Zoo --org AlphabetSoup
kk admin admin repo synchronize --name Countries --product Zoo --org AlphabetSoup
# Promote it to Cook environment
kk admin admin changeset create --name Cooked1 --environment Cook --org AlphabetSoup
kk admin admin changeset update --name Cooked1 --environment Cook --org AlphabetSoup --add_product Zoo
kk admin admin changeset update --name Cooked1 --environment Cook --org AlphabetSoup --from_product Zoo --add_repo Animals
kk admin admin changeset update --name Cooked1 --environment Cook --org AlphabetSoup --from_product Zoo --add_repo Countries
kk admin admin changeset apply --name Cooked1 --org=AlphabetSoup --environment Cook
# Promote it to Taste environment
kk admin admin changeset create --name TasteBatch1 --environment Taste --org AlphabetSoup
kk admin admin changeset update --name TasteBatch1 --environment Taste --org AlphabetSoup --add_product Zoo
kk admin admin changeset update --name TasteBatch1 --environment Taste --org AlphabetSoup --from_product Zoo --add_repo Animals
kk admin admin changeset update --name TasteBatch1 --environment Taste --org AlphabetSoup --from_product Zoo --add_repo Countries
kk admin admin changeset apply --name TasteBatch1 --environment Taste --org AlphabetSoup
# Promote it to Sell environment
kk admin admin changeset create --name SellBatch1 --environment Sell --org AlphabetSoup
kk admin admin changeset update --name SellBatch1 --environment Sell --org AlphabetSoup --add_product Zoo
kk admin admin changeset update --name SellBatch1 --environment Sell --org AlphabetSoup --from_product Zoo --add_repo Animals
kk admin admin changeset update --name SellBatch1 --environment Sell --org AlphabetSoup --from_product Zoo --add_repo Countries
kk admin admin changeset apply --name SellBatch1 --environment Sell --org AlphabetSoup
# Changed my mind, delete Animals from Sell environment
kk admin admin changeset create --deletion --name DeleteAnimals --environment Sell --org AlphabetSoup
kk admin admin changeset update --name DeleteAnimals --environment Sell --org AlphabetSoup --from_product Zoo --add_repo Animals
kk admin admin changeset apply --name DeleteAnimals --environment Sell --org AlphabetSoup
 
 
# Create Lenovo organization and environments
kk admin admin org create --name Lenovo
kk admin admin environment create --org Lenovo --name Development --prior Library
kk admin admin environment create --org Lenovo --name QA --prior Development
kk admin admin environment create --org Lenovo --name Release --prior QA
# Create Lenovo administrator role
kk admin admin user_role create --name "Lenovo Admin"
kk admin admin permission create --user_role "Lenovo Admin" --name "Lenovo Administrator" --org Lenovo --scope all
# Create Lenovo administrator user and assign role
kk admin admin user create --username lenovo_admin --password katello --email "lenovo_admin@somecorp.com"
kk admin admin user assign_role --username lenovo_admin --role "Lenovo Admin"
# Switch context to Lenovo organization
kk lenovo_admin katello client remember --option org --value Lenovo
kk lenovo_admin katello client remember --option env --value Development
# Custom provider1
kk lenovo_admin katello provider create --name="FedoraHosted"
# Pulp product
kk lenovo_admin katello product create --name="Pulp" --provider="FedoraHosted"
kk lenovo_admin katello repo create --name="6Server x86_64" --product="Pulp" --org="Lenovo" --url=http://fedorapeople.org/groups/katello/releases/yum/katello-pulp/RHEL/6Server/x86_64/
# Candlepin product
kk lenovo_admin katello product create --name="Candlepin" --provider="FedoraHosted"
kk lenovo_admin katello repo create --name="6Server x86_64" --product="Candlepin" --org="Lenovo" --url=http://fedorapeople.org/groups/katello/releases/yum/katello-candlepin/RHEL/6Server/x86_64/
# Custom provider2
kk lenovo_admin katello provider create --name="Google"
# Google product
kk lenovo_admin katello product create --name="Chrome" --provider="Google"
kk lenovo_admin katello repo create --name="google-chrome-32bit" --product="Chrome" --org="Lenovo" --url=http://dl.google.com/linux/chrome/rpm/stable/i386
kk lenovo_admin katello repo create --name="google-chrome-x86_64" --product="Chrome" --org="Lenovo" --url=http://dl.google.com/linux/chrome/rpm/stable/x86_64
 
# "Empty" promotion to Development
kk lenovo_admin katello changeset create --name "empty-products-2-dev" --description "Empty products to Development" --environment Development
kk lenovo_admin katello changeset update --name "empty-products-2-dev" --add_product "Pulp" --environment Development
kk lenovo_admin katello changeset update --name "empty-products-2-dev" --add_product "Candlepin" --environment Development
kk lenovo_admin katello changeset update --name "empty-products-2-dev" --add_product "Chrome" --environment Development
kk lenovo_admin katello changeset apply --name "empty-products-2-dev" --environment Development
# "Empty" promotion to QA
kk lenovo_admin katello changeset create --name "empty-products-2-qa" --description "Empty products to QA" --environment QA
kk lenovo_admin katello changeset update --name "empty-products-2-qa" --add_product "Pulp" --environment QA
kk lenovo_admin katello changeset update --name "empty-products-2-qa" --add_product "Candlepin" --environment QA
kk lenovo_admin katello changeset update --name "empty-products-2-qa" --add_product "Chrome" --environment QA
kk lenovo_admin katello changeset apply --name "empty-products-2-qa" --environment QA
# "Empty" promotion to Release
kk lenovo_admin katello changeset create --name "empty-products-2-release" --description "Empty products to Release" --environment Release
kk lenovo_admin katello changeset update --name "empty-products-2-release" --add_product "Pulp" --environment Release
kk lenovo_admin katello changeset update --name "empty-products-2-release" --add_product "Candlepin" --environment Release
kk lenovo_admin katello changeset update --name "empty-products-2-release" --add_product "Chrome" --environment Release
kk lenovo_admin katello changeset apply --name "empty-products-2-release" --environment Release
# Sync 1
kk lenovo_admin katello provider synchronize --name="FedoraHosted"
# Full promote to development
kk lenovo_admin katello changeset create --name "all-to-development" --description "Promote all products and packages to Development" --environment Development
kk lenovo_admin katello changeset update --name "all-to-development" --add_product "Pulp" --environment Development
kk lenovo_admin katello changeset update --name "all-to-development" --add_product "Candlepin" --environment Development
kk lenovo_admin katello changeset apply --name "all-to-development" --environment Development
# Partial promote 1-0
kk lenovo_admin katello changeset create --name "few-pulp-qa" --description "Promote 3 Pulp packages to QA." --environment QA
kk lenovo_admin katello changeset update --name "few-pulp-qa" --from_product Pulp --add_package "gofer" --environment QA
kk lenovo_admin katello changeset update --name "few-pulp-qa" --from_product Pulp --add_package "gofer-package" --environment QA
kk lenovo_admin katello changeset update --name "few-pulp-qa" --from_product Pulp --add_package "grinder" --environment QA
kk lenovo_admin katello changeset apply --name "few-pulp-qa" --environment QA
# Promote Candlepin to QA
kk lenovo_admin katello changeset create --name "candlepin-to-qa" --description "First time promoting Candlepin to QA." --environment QA
kk lenovo_admin katello changeset update --name "candlepin-to-qa" --add_product "Candlepin" --environment QA
kk lenovo_admin katello changeset apply --name "candlepin-to-qa" --environment QA
# Partial promote 2-0
kk lenovo_admin katello changeset create --name "few-candlepin-release" --description "Promote 2 Candlepin packages to Release." --environment Release
kk lenovo_admin katello changeset update --name "few-candlepin-release" --from_product Candlepin --add_package "akuma" --environment Release
#kk lenovo_admin katello changeset update --name "few-candlepin-release" --from_product Candlepin --add_package "akuma-debuginfo" --environment Release
kk lenovo_admin katello changeset apply --name "few-candlepin-release" --environment Release
## Sync plans
kk lenovo_admin katello sync_plan create --org Lenovo --interval hourly --date `date +"%Y-%m-%d"` --time `date -d "+20 minute" +"%H:%M:%S-04:00"` --name "Hourly"
kk lenovo_admin katello product set_plan --org Lenovo --name "Pulp" --plan Hourly
kk lenovo_admin katello sync_plan create --org Lenovo --interval weekly --date `date +"%Y-%m-%d"` --name "Weekly"
kk lenovo_admin katello product set_plan --org Lenovo --name "Candlepin" --plan Weekly
# Create Lenovo restricted role
kk admin admin user_role create --name "Lenovo Viewer"
kk admin admin permission create --user_role "Lenovo Viewer" --name "read-fedorahosted-provider" --org Lenovo --scope providers --verbs read --tag FedoraHosted
kk admin admin permission create --user_role "Lenovo Viewer" --name "read-env-dev-qa-content" --org Lenovo --scope environments --verbs read_contents --tag Development,QA
# Create Lenovo restricted user and assign role
kk admin admin user create --username lenovo_user --password katello --email "lenovo_user@somecorp.com"
kk admin admin user assign_role --username lenovo_user --role "Lenovo Viewer"
# Create Lenovo admin user, use French locale and assign role
kk admin admin user create --username french_user --password katello --email "french_user@somecorp.com" --default_organization Lenovo --default_environment Release --default_locale fr
kk admin admin user assign_role --username french_user --role "Lenovo Viewer"
# Create Lenovo user, use Brazilian Portuguese locale
kk admin admin user create --username brazilian_user --password katello --email "brazilian_user@somecorp.com" --default_organization Lenovo --default_environment Development --default_locale pt-BR
kk admin admin user assign_role --username brazilian_user --role "Read Everything"
# Create Lenovo user, use Japanese locale
kk admin admin user create --username japanese_user --password katello --email "japanese_user@somecorp.com" --default_organization Lenovo --default_environment Development --default_locale ja
kk admin admin user assign_role --username japanese_user --role "Read Everything"
 
# Create Starbucks organization and environments
kk admin admin org create --name Starbucks
kk admin admin environment create --org Starbucks --name Demi --prior Library
kk admin admin environment create --org Starbucks --name Grande --prior Demi
kk admin admin environment create --org Starbucks --name Venti --prior Grande
# Create Starbucks administrator role
kk admin admin user_role create --name "Starbucks Admin"
kk admin admin permission create --user_role "Starbucks Admin" --name "Starbucks Administrator" --org Starbucks --scope all
# Create Starbucks administrator user and assign role
kk admin admin user create --username starbucks_admin --password katello --email "starbucks_admin@somecorp.com"
kk admin admin user assign_role --username starbucks_admin --role "Starbucks Admin"
# Switch context to Starbucks organization
kk starbucks_admin katello client remember --option org --value Starbucks
kk starbucks_admin katello client remember --option env --value Demi
# Custom provider1
kk starbucks_admin katello provider create --name="DarkRoasted"
# Verona product
kk starbucks_admin katello product create --name="Verona" --provider="DarkRoasted"
kk starbucks_admin katello repo create --name="Decaf" --product="Verona" --org="Starbucks" --url=http://fedorapeople.org/groups/katello/releases/yum/katello-pulp/RHEL/6Server/x86_64/
# Sumatra product
kk starbucks_admin katello product create --name="Sumatra" --provider="DarkRoasted"
kk starbucks_admin katello repo create --name="Decaf" --product="Sumatra" --org="Starbucks" --url=http://fedorapeople.org/groups/katello/releases/yum/katello-candlepin/RHEL/6Server/x86_64/
# Komodo product
kk starbucks_admin katello product create --name="Komodo" --provider="DarkRoasted"
kk starbucks_admin katello repo create --name="Fair Trade" --product="Komodo" --org="Starbucks" --url=http://dl.google.com/linux/chrome/rpm/stable/i386
kk starbucks_admin katello repo create --name="Gold Coast" --product="Komodo" --org="Starbucks" --url=http://dl.google.com/linux/chrome/rpm/stable/x86_64
# Sync 1
kk starbucks_admin katello provider synchronize --name="DarkRoasted"
# Custom provider2
kk starbucks_admin katello provider create --name="FrenchPress"
# Zoo product
kk starbucks_admin katello product create --name="Ethiopia" --provider="FrenchPress"
kk starbucks_admin katello repo create --name="Decaf" --product="Ethiopia" --org="Starbucks" --url=http://inecas.fedorapeople.org/fakerepos/zoo/
# Sync 2
kk starbucks_admin katello provider synchronize --name="FrenchPress"
# Promote all to Demi
kk starbucks_admin katello changeset create --name "products-2-demi" --description "All products to Demi" --environment Demi
kk starbucks_admin katello changeset update --name "products-2-demi" --add_product "Verona" --environment Demi
kk starbucks_admin katello changeset update --name "products-2-demi" --add_product "Sumatra" --environment Demi
kk starbucks_admin katello changeset update --name "products-2-demi" --add_product "Komodo" --environment Demi
kk starbucks_admin katello changeset update --name "products-2-demi" --add_product "Ethiopia" --environment Demi
kk starbucks_admin katello changeset apply --name "products-2-demi" --environment Demi
# Promote only Sumatra and Komodo to Grande
kk starbucks_admin katello changeset create --name "products-2-grande" --description "Promote only Sumatra and Komodo products to Grande" --environment Grande
kk starbucks_admin katello changeset update --name "products-2-grande" --add_product "Sumatra" --environment Grande
kk starbucks_admin katello changeset update --name "products-2-grande" --add_product "Komodo" --environment Grande
kk starbucks_admin katello changeset apply --name "products-2-grande" --environment Grande
# Promote only Komodo to Venti
kk starbucks_admin katello changeset create --name "products-2-venti" --description "Promote only Komodo product to Venti" --environment Venti
kk starbucks_admin katello changeset update --name "products-2-venti" --add_product "Komodo" --environment Venti
kk starbucks_admin katello changeset apply --name "products-2-venti" --environment Venti
# Delete a single errata item from Demi environment
kk starbucks_admin katello changeset create --name "DeleteBear1" --env Demi --org Starbucks --deletion
kk starbucks_admin katello changeset update --name "DeleteBear1" --env Demi --org Starbucks --from_product Ethiopia --add_erratum "RHEA-2012:0001"
kk starbucks_admin katello changeset apply --name "DeleteBear1" --env Demi --org Starbucks
# Create Starbucks admin user, use Korean locale and assign role
kk admin admin user create --username korean_user --password katello --email "korean_user@somecorp.com" --default_organization Starbucks --default_environment Venti --default_locale ko
kk admin admin user assign_role --username korean_user --role "Starbucks Admin"
# Create Starbucks user, use Chinese Simplified locale
kk admin admin user create --username chinese_user1 --password katello --email "chinese_user1@somecorp.com" --default_organization Starbucks --default_environment Demi --default_locale zh-CN
kk admin admin user assign_role --username chinese_user1 --role "Read Everything"
# Create Starbucks user, use Chinese (Taiwan) locale
kk admin admin user create --username chinese_user2 --password katello --email "chinese_user2@somecorp.com" --default_organization Starbucks --default_environment Grande --default_locale zh-TW
kk admin admin user assign_role --username chinese_user2 --role "Read Everything"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.