diff --git a/group_vars/all/plain.yml b/group_vars/all/plain.yml index bc03e26..e47f0ef 100644 --- a/group_vars/all/plain.yml +++ b/group_vars/all/plain.yml @@ -133,4 +133,144 @@ hetzner_ssh_keys: #harbor_admin_password: "< see vault >" #harbor_postgresql_password: "< see vault >" +#vault_ansible_password: "< see vault >" #vault_replicator_user_password: "< see vault >" + +ansible_ssh_key_private: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 65643563353264343334636337353563623431343931366266623562303835313466623461643434 + 3134313430303831353965613233313537313235316137300a343938643462343163613263363537 + 36643265646338643762376639376232646666343661396435396336353134303764313264663661 + 6438373531626530610a643863323966633264623463313562643830633336303832393032363737 + 65636134613762636234663734636131643631383732663066656363336131353838366230386630 + 64316433313733356636303662643939346536323238633664626365633964323039623937313237 + 62353632356265346438306435336566313461653431316132356636623631653632616663326632 + 38303563653664353165656561363462633662646562386336316234393661333432353832333939 + 62633433623264333139613635353336653639653661383036333139633135373135326430303563 + 36656237393739643337656566346631343131343532396632316639613131633831363666623237 + 63656165653239336663303361396237326463323163323334393732383431633036623834616561 + 65623464626662633138666165363165393064396435626533313338306363383235623439393665 + 62363630623234383463323232623563303435316432626163616265313664343966666164646239 + 64386532333664353366326461343036363732623239343735376636326133653661656565663639 + 39353636346133353631373636316433366231613630343837666530343039343531643038663861 + 36333539643537383535353065633462383738336265356264333232386235646666373739613237 + 66323436613165616331666461653432373037373163303962306434616239663033383331386531 + 34386635633564336534643838383465306436323666616464653139396438373266343564353961 + 38336136393262356338353964323336653438626336316638353934646230326462346134336438 + 32613135653736303730613563383338653936343937366666613562383631363338626537663137 + 35623038333232386236303935353933316238643566613732396134383164303162666637663132 + 63363062626163353933613131626639363966386166333738373064343864643163373566326164 + 61666638643931356430313132636133393163383435653831643664343238633262323133323263 + 38623330353135326239626633326330386231363034613830373236643635373732313633323038 + 38323662343338633930383161663266663666643731346332333535376435356436393835653861 + 33376463616130303330633730323131663537663264383939323930643539653364626534363131 + 65336362623162633263653561393761633238383430663163343236623930623463646638316262 + 30336166663235306133636461323432393362626637383662343762623439363339353238323835 + 62366131313761303866633166346431633539663563363961653437386132656332303066333037 + 35383735303862353966623938363462396330336466363831383964366536623630663362663733 + 38333035636637643461623734326436653030336663646439313239343966326161663963653764 + 30626566653430336232306463313835356333313835353366613332353037336135653334353330 + 36333938393938653735626134653634353130353433356465353035313961646232333362396431 + 61636637646362343132386233373139656133393930343839393430306338353065613638323062 + 63656463303665383939393831343761303061393361396639336565643164353964366366303236 + 30306530636434656335303564626237633663626164373663353237613266646661333566316663 + 66393739313262333834363263383332346130343733343665626264663463376366633264623465 + 66393366363666306262613731303766303933613265386238643161616337376136626339373133 + 63383438666265303537396437396231653937613861353636633565353838613038323633343364 + 62356137373132333234346635663839336330336364666538623835613632323035633530616432 + 37656333666637313831313763643466333237393430623131623037323961636361333939636363 + 61623633646235643633376138313631353531376331383438336561393732363866373962316138 + 33633432356538303334356631353439316531396331623738386232616261336462333932353064 + 65393533643462643039303234646163323663376431373664373866336539643831386664333938 + 32373561386630666463613138373637383665643631356365373639346561333832653534613539 + 63376266633232636335346439363764653961643862663932303931323430396233623761656164 + 65373261336339656164373463626561326666633832386437326632623964653763356236336232 + 63316636313138326230396533653131323533343064373465376135373765303262643531646539 + 64663162363931373834613734353664303266626636653736333336353663626463396662653763 + 32653964656163353864343439393664333835396265656235353531316633313033666465386331 + 34646266323034656462396561633638623330313064356333323262383336656165303536616439 + 30363761653431363733663030626532393939663633623432636330323030666233646231343061 + 31353065633734666332353734646236303131356533356234656161343962313532653935623365 + 38666237373439623236313637313461613462653437396535356437626531373833303236323162 + 62326438353137306539313565346230313864383264373836333535623764376537303538633839 + 38623462643939373664323263326432663362643966663333343131303264366539653539373261 + 36353439373865363633653337316433313635383262373330373862626134653235656234626134 + 33623934353137373931393036613830396336633734616566363365666564373463313962363364 + 66643638613038373634656539373431393466373935663962363436303133323436303365373735 + 32633164363338356633623766346231376663613334643231383263653335613765633162643635 + 39313431643331323132343965343134373933303339323265333739303538353936363362383839 + 63656139376136613732393261653036316261616537643335373965393236356339363432326130 + 31646362653031333261323665633437376534333431666365363933663264303039376265616437 + 63323535363633623461346663646530613932333137343234346130386335363834313765313962 + 35656533336536633636633339653564306366366339363934366663343331393035363236323636 + 62353939666435633065303136636466346262666563646631626530653934633132316537376532 + 62383465353465623262666231623634303831653334313731343764623036303731336532343866 + 39663665386238373338653233306137663333386533333032303433323731346135323566336630 + 32313637353930313633653432643730656230333261356461373139333661626362303531656463 + 63356664343938343735306365303739386563613964306663623762623631393234633063306564 + 33616465363039613936613863303933336132656337383565356338356430663762663236346263 + 31393639386132306133313865373864323433306466343431663033326133623833343339316630 + 64396664353030363662616164346134303062663631353465613637613737646434346561626165 + 37663063613235326236383966343933366131323133373863326634626561386234646363633435 + 31653730636665303266323734393335336463333039323764343436393937313366626437346135 + 36643534323532613939333134666336346163393464366565393761393735383530646535346564 + 37393731303437303063376235616165656563346165613463653636363338316636633864613032 + 37366133636637646165643239303965303232353965383834373865633862363565343431326335 + 61306663633663376539613434663561663032386233376566616339653563373830646463396632 + 36666338646631313763376337643832656233646637633961336266613964336139336361623461 + 32366238636363373531383739396435396134656466343830653638363931323562383338363336 + 32393331653333343864613665316334356531663466663331336335366663353934643638386233 + 30343634303132396663306162613064646135633136663238336537653764306630626137323264 + 34323731353532623534383365633861666334636464356134666536383134643337613566303939 + 61656539626532393833663236663865346661333465383330326239363137363033616530393437 + 39623130623631643062316232613938366631343864656563356165313938393535616166613664 + 34303731396135616135393431636431366336663661656138316161316265393133313136616538 + 37363836313934613866363836636430643134323530653933386536343731613963303664636136 + 34336436653831363966616536623838343562666632623436306534333138393238383938393733 + 34313737316263653935316132346230653439336635636437303465653636656535633262353561 + 37343133306363626432336138366461663431656339343238656465633738306634613334306263 + 31626336653839616639656232383935383630363766313765323264613030656634383438376432 + 62396535313236633237303065333065346362333430336539326633383066353536363162386563 + 35353431373063363436373838633139623230373939636365636135343834623433326238383334 + 33373335656565346636376239633865306135613336396636383461333737666431633562666136 + 34333262393239613835336631626563336333663764356363346235643334336435663963306331 + 31633033613061663138633434656166323963633461386463616463316637353630343438376566 + 66383261316439333331326136616133613566653539646431616331393262613432343662643730 + 33663537666263353565376630313630323265393862313631633461336263656330366230643937 + 31343263643765356433373432623038383638353466333539343961336565333033363439623061 + 30303166326163663935353935633462343863383737633130653566626532643030356265663736 + 32383539626362326563653630386364663565386238366138356661633238333539326132623266 + 62323039313332336239363235323536373561373431663033366230353131376666343138663963 + 36303064646331643365356635303034306331643362326261363031386533613739333435313734 + 32393135653333643336633136353564653534393765376136333863346636663861393364316362 + 39636537303761623536376663393539323735663364313936373137386366633461313933383466 + 32623863393037353262363065643663383462653661333563653935636233366365376538613233 + 39623365323331643535343631353463363436633431643832623534303962633834356532323631 + 65663462653736356235666337323135613465333862316437623839393730363935613732393962 + 63383666626638616138646261616566386365623636616661363766386336313433373635383937 + 31343331316435353033386537643061663165643333396232313531386533393264613235333966 + 63626263633132613438303636336637313934373937353264646264313861376166326663383362 + 38623231336336376665356161653631306662396163613763303838333166653065623062363666 + 35353834623665393762663163613636316663353031653934663336316563626437633066336333 + 65313831333934663261356264616438613631316162323936643838386432316235653134326336 + 39373266376433653036623662343638393564613734363563633462393964386464373739303963 + 61623634393634616239633533393065663333386564326330666564633730656639386439633366 + 66666266366630656537636565623965336232653831333932353330633438303432333438356332 + 33383664373534316233396566633335386438353237306631386161626565653535396231303736 + 61643662336461646538356366623234356531316438333231623162613266396162353438376438 + 63643432316531666161373462343033653366343632653232613132366439333233313438333031 + 30643738383666626162353739386132353662633136373631393964623064636132373062333036 + 34636336623137636538363830666137613237343531333661396663383330313363633238306331 + 63666134336666316266326465333930663732666563306333323866653163306162393034343364 + 33353731633766646337316538643232333234633465656262643633303930636236353638363064 + 34646530626264303338396638343239336137363539353937336265613539303262326566383561 + 30313731323034623465396339636264643637643866393734376162633335326163393863376364 + 33313165643264643364343963353833653332643964653463373737653331633438363861353733 + 36393634343063383934346136316634373564343336636433313862313263633138333663663666 + 65353665626533333663396530646662356633383735626365303731653165336534366539376130 + 62646536386566323066633432666563623161666666343931313635313561663261633164343366 + 62363064363334326637346564323766363462353838363733326130616438353364646631333531 + 66613235333532376231356564316338393939653030386162373435666437323263303462333061 + 33393966346661663964623736663732303439313765636233623136316634623535663639656538 + 393732353362383861623636626530393266 + diff --git a/group_vars/all/vault.yml b/group_vars/all/vault.yml index edc8ad3..97e7683 100644 --- a/group_vars/all/vault.yml +++ b/group_vars/all/vault.yml @@ -1,74 +1,77 @@ $ANSIBLE_VAULT;1.1;AES256 -64363634663737386334633461386262333537616332666562633062666163633664306663343432 -3864363865353062393836646165643138393533396333320a383161323865353734653033656563 -37633463373163336365666639356362306236646236643433613335623734313462303335333635 -3133616330373534350a666334303966383264663833366538376436396535666633616338336163 -30343266323031633139663338306466313230646233623863383334666332353061333235636236 -37333165336461643261356532306262623231343362613037363933356366643363333663613866 -36373963616238666161653432393565636532666665356665633339316363613336386133633766 -38363430303464386165396536633766383263646631653664376262393832323465333837363566 -65646262323430396237396235303962346264363431313235396264363834366230373036396432 -63623063393336326139623334656434303039393966663030653436373834636539646636386331 -35323839663863313733393261363361666261643463363736653663313364363565643564636536 -61396466613237313938623731623735626264373564633263303336383766306163643561376661 -32396139666433393432646463353730383461323139346461346662326535613532623034646162 -35626666653536666630386135613162343165323637646235383363663232343036383035363063 -37653966663836396531303738333564613933366531373738626132333634623261623533373966 -65663063323831393962373439326334363632326339643863613161316532313534613536363537 -35633666643265303461633564336530353136393063333935383163313766643334333234623430 -34656531643637306365353231303532323732353566316433336138656233336365616638303437 -37633366626139366666333466393436313265643935383631393362323666623131383331383464 -37303838386566396239656330636162386566366131616630316566633333333262333534336463 -64353838306238396637623763633464333966653432653732303063326235383830363237313565 -63366563323537616334396330303131363732626136313437363537656665353564373439313831 -34663834623136333961653737363163376636336264643064343635376532326132363035383637 -37336465653933663931376633346538663866363135626465653138353339646161383636663238 -33313831646163353131303234333637306337613561393361616337373537306161616562343331 -33646362366134373339376366616364633263633562613463663936663966613566346638396434 -36313638313663626538373539353437316363646166393866643062353333386533333632333164 -35643463353731306537316465373730666334626235663039316632626430313337303632616237 -37386633373634333238623464353139316236613039313961653535613835636562393335646637 -33326666653532636230343766323937313331666334333830383264653135663962356138313737 -63316431393565323166343164663530356130316335323662323530373233356435323965303866 -35376462306136333565386533366637333265393264303136663161626661666635323136316430 -66623962616365363962393838333133313133323431636530306539303837333731326566396335 -38636464353936363030303764623861373362656237303032653661613262626431353238336536 -30343865633165613433613635376337643632613562656133633435333063313262366561343535 -36363562313766666263653934376161656332626333323062346131346132323331316332646266 -35373562633639386266646439623866336434373536633236316361383233663363643936656339 -35333736663966326166613261626531616530353165326162653564363832386232313764663737 -30336666356463356161613566373661633566303061353439373162306330396437356461663139 -31646465623234343130623736653031326230323432656462366435653564623433393539626537 -36646536313033663937363535366361386535613436313735383931666533646662633831303538 -64306437306631303162336561323431373464623031333932356433363536346533366430366238 -32306166376262616165353635386164633933663732373933376430396362663465343331616636 -66306431626233343564663235376465623665373536653136633932353265666366633235363461 -62623063613730666530333030613463636363383431653130643137373737393134643064333332 -64393134323137303164623238636235623266323466373430393265323637366131333166643666 -32303338656536373539303433383964373862333032363333373333313839353763643061313930 -35333833353465643938633365366261633438316264356234363766383438366161333862383338 -32633433346462353733323761613633343734393439386333346534393564633166646166306236 -62336266373766363332303866393733353263323164646535323066306134623538663532363665 -39366539386362363538653363336639323634366631393732616563393561363333383435363730 -34626166393239656636366562333261346431366330393339356537383034663961306636356633 -31623262323434656465333536376565373736383537613361373062636631353631636433343161 -62356534326239376264303439373033626336303031313661303333636663366366343534636237 -37356438316539643663363237363131666537333562656439323739656635393665366538323462 -30346539393764316435353962363266653439376232656263326262653833313564633636303639 -61373064373164316462346234313536643537373630323339353866646436663538653234643932 -32353238613166336330633434323363363439373339383139393137376337303531346430396637 -61363638353665373364383365613538373962613830666535636339636336646436326433663065 -64643330313666373035653031326535633739616437386261386333356234343334316432313363 -34626637633362343464646565343330383239303431316333323337626531623966316438623839 -37623461303138653030356632623064656333373866633165353062613831313364653135613738 -37666331663532366437393663636237636333636564656131303331643961363737626437353934 -34633463353561313035613261323137386461313362626462626335306433383530313534626539 -30656638396232303031363937643164653230356462663435636436306166383436383231383935 -61653937353163666234333465363237386465656637313235386338626561306531363633626563 -34343431663238663633643165326664346237356337646231653639313234633332623330623734 -66656166303666656565626461626332383261353862366562626231646461323231393162323738 -33303236326362383932643533383165613766376666333338666636316636353062346136623335 -32643966353734616333336665653032363162623035346662386237623663356666303038346137 -61383334643762663865393264343533386666343435313661613133613535336466373638363165 -64623062623932323137633162623832356566393464333061646537613431616339393131333137 -36643639383639326537316434643761653762356130633165373637303938343930 +61653336363762373661306133636238666261646334366539636532303830303534396432363337 +3639643337313965333439663937303937613763326439650a663863646335643432336661326661 +66316266366538393161373334383765363965393035633562383039396631623962663666313762 +6637373237623762620a656261633562366136616562363564346630646236613463316533643663 +39633261643163373535333332356364393465363636316130663030376232303732653339343964 +31303666366264613265336337376433316435396537613937623039623733373663623739363232 +32376435613161643030363739323735346436316436343133373338363232663464363134626663 +35313734666137626335313334666433666562373461653435653862333432343462376430356332 +33373336613766666131646633303834353832383461386362336164643562656562343061383133 +30646430346232303836653032373235633166313233383839386565343266323634306531326366 +30326136613363643766613262393930653864383037656630623434376661646231376335633530 +39303438633230623063643832646164646261343938313334313762323538666530313066666530 +35616664656437383735633831623032316137373133353639666161643962663730613034346635 +39393133346334633461663061386165616562383531316636343734636331613764386339613861 +61623138616334313763356530323533366362366135383962653061353732613937303337663533 +36646435383466316461616563613837393230396232616237663635353534336237663765376433 +35353136373130323564393634313332373936396161316634333362663431643031366435383230 +37343333343636373964363834356337656266616337313035326338353930356561616431383139 +36663966386366656338343561363764313563656238326536383363646363613431626463306263 +39353430623763333935373935306365336165383432633733353536363462373633643663363363 +63613435363763353731653162353538336137303863363136613633306533326134616230383331 +63303561393564353031643639353032386362653733303766303235373365616237353734373765 +65336233343865313961363132616563626664353338666536636463313963326163613864333964 +38306333313938373238373832313131316162316132653861646337333465656433633530303565 +33646565373166353630343031613166623762653737303335316430386334363565663538316433 +37323661366262363735373134623162316630653132666565626632396664326132323439373233 +37613738643463616135626236306665313961376261356466643462396466303234356536393739 +39396338373438316165343566376466343935306237656463356537623230313663306232623562 +31333662316438393131376333323934646165373232393034613763373166333335313634393630 +32303666356338326231613033363863353536373930653132656331653334366539376436393864 +39343863656539306365383563666631376264623862346562333635653934376531356331303737 +30313665343337333762383861373835303339663335346236646361333234393435623663353437 +31396535333163373762333431306563393962303537633763363638616136323231326162386664 +35636161383361323561373236363461616464346535336535666632626435376637326239333738 +33633336643133373461616631613530623636316536633631643034326230376633616563316565 +33363962313762386432613536646334313961383739663339623362336564353339396233326133 +30366464646466636435303531616430326561643630343138633935663966383234356662376637 +39323839376163626633353963633161636432656663343962626337616665323432303735366530 +63383964636665646432646337353634313434343564613139333363303863396663303263363631 +30313366633361386636643134336566326565373861666334623563646133666261333235626537 +37323666333566343430626137313563303336376437366238663234653566653437363633366436 +37633961616337656565323739336435393533663862643632373933633733626165363630353430 +30343536613164343461333464616638313139306535313032303364653765363462646235656230 +64346436613231353334356266613562663032386564633534373332306563656365346534633137 +65346533353035383864643739646631333938613461373234323234383063373138353230323862 +30313062346663336633666231666530613134386236653362396331356330336234393365393062 +34396534393232643764623932633963306461373065643865376239393262616635303230616161 +62643161656237373531373934346461653062636136383533376436383462316538373064656433 +33306638393637316134636663633331643134333532366666316536366233333839356632393038 +38353034326563366235623865616164323530303037306432623761616131633361303237323736 +62346439623131343964323665316438656366376638333362336365393334316132393633376637 +66373037353339383232346437656239383336643436323462663933653031653439393433653265 +38393162356235313733376466633535313463346638613365333235656631343436376138333361 +65653264323861623739613262333365386530373063623332323965383938653465646261633139 +33663235373261653039636630666138363034373662373561386630386633393433386436623530 +30663863646666633865393431356633326634393364396166636639343931333564626437373066 +66383639313738613234626361323564383739396335356632313961376137363735346566653639 +62663838646133653465333139613734356336613762393032363131333961336335633237373535 +31363661636538336435306537343963323938376561643962313730336562323932346334376133 +37396662356165653861346230316335653765666136323930346531363334353035636661333339 +34343836373437666139376662643239616435396438663634653136323836386563366264313332 +37386637396663366332333931613436396337303664653437363931383164323038373036383661 +34313532333732656238643061323735393362343036633039653462626239323739643433343637 +35316331613937643931653264663230643939613136373065343334356131303665656561326437 +36323936373463356665356334363161343130393130646133393339316337333834333163663034 +63623039633266323736623364386665616630633133353138326566363830616233343464363338 +31366165303633636234623363336234376162346233623137386264656236653039373862396337 +35633034306138626464653637626664376638353837303236633134396264383731363931643432 +38623931346432333632653863643362346561653136623361643362616339326138383863386561 +66396435373137396263393132663834393631653461333235303135653962326235646336653463 +63663435313632613337633861653463626363643531356664663735326462353936336539663632 +31356638623939376137663666616664333037653236373135306333316362346361666165633764 +32313532343566363962663166356465303631353764333931323337636261373562666364643266 +64303636623633323736336262636164336164366433343633356362323866306561383966383134 +32633438343238373537373936376365616634396336633634356262393630383333323030663932 +37356437396635356636 diff --git a/roles/awx/defaults/main.yml b/roles/awx/defaults/main.yml index 588ef60..3d51783 100644 --- a/roles/awx/defaults/main.yml +++ b/roles/awx/defaults/main.yml @@ -23,3 +23,6 @@ kubernetes_awx_service_targetPort: "80" awx_admin_username: "awx-admin" awx_admin_password: "awx-admin" + +awx_ansible_username: "ansible" +awx_ansible_password: "ansible" diff --git a/roles/awx/tasks/awx-config-get-typ-id.yml b/roles/awx/tasks/awx-config-get-typ-id.yml new file mode 100644 index 0000000..3809426 --- /dev/null +++ b/roles/awx/tasks/awx-config-get-typ-id.yml @@ -0,0 +1,55 @@ +--- + +- set_fact: + awx_type_id: None + changed_when: False + tags: + - awx_config + +- name: "Search {{ awx_rest_api_type }} informations for {{ awx_search_name }} on awx server" + uri: + url: "{{ awx_base_url }}/api/v2/{{ awx_rest_api_type }}/?search={{ awx_search_name | urlencode }}" + method: GET + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + return_content: true + validate_certs: false + force_basic_auth: yes + status_code: 200 + register: awx_type_info + tags: + - awx_config + +- name: Save result as variable (fact) + set_fact: + awx_type_info_json: "{{ awx_type_info.json }}" + tags: + - awx_config + +- name: "Printing {{ awx_rest_api_type }} informations for {{ awx_search_name }}" + debug: + msg: "{{ awx_type_info_json }}" + delegate_to: 127.0.0.1 + when: + - debug + tags: + - awx_config + +- name: "Search {{ awx_rest_api_type }} id for {{ awx_search_name }} on awx server" + vars: + query: '[? {{ awx_search_key }}==`{{ awx_search_name }}`].id' + set_fact: + awx_type_id: "{{ awx_type_info_json.results | json_query(query) | first | default(None) }}" + when: (awx_type_info_json.results is defined) and (awx_type_info_json.results | length > 0) + tags: + - awx_config + +- name: "Printing {{ awx_rest_api_type }}['{{ awx_search_key }}'='{{ awx_search_name }}'].id" + debug: + msg: "{{ awx_type_id }}" + delegate_to: 127.0.0.1 + when: + - debug + - awx_type_id is defined + tags: + - awx_config diff --git a/roles/awx/tasks/awx-add-credential-to-job-template.yml b/roles/awx/tasks/awx-config-job-template-credential.yml similarity index 52% rename from roles/awx/tasks/awx-add-credential-to-job-template.yml rename to roles/awx/tasks/awx-config-job-template-credential.yml index 3626742..066e511 100644 --- a/roles/awx/tasks/awx-add-credential-to-job-template.yml +++ b/roles/awx/tasks/awx-config-job-template-credential.yml @@ -2,9 +2,9 @@ - set_fact: found_credential_id: "" tags: - - awx_communication + - awx_config -- name: "Get {{jobinfo.name}} job_template credential id's from awx server" +- name: "Get {{ job.name }} job_template credential id's from awx server" uri: url: "{{ awx_base_url }}/api/v2/job_templates/{{ awx_job_template_id }}/credentials" method: GET @@ -17,22 +17,43 @@ register: awx_job_template_info when: (awx_job_template_id | default("") | length > 0) tags: - - awx_communication + - awx_config -- name: "Check for credential id {{ awx_credential_id }} in {{ jobinfo.name }} job_template" +- name: Save result as variable (fact) + set_fact: + awx_job_template_info_json: "{{ awx_job_template_info.json }}" + tags: + - awx_config + +- name: "Printing..." + debug: + msg: "{{ awx_job_template_info_json }}" + delegate_to: 127.0.0.1 + when: + - debug + tags: + - awx_config + +- name: "Search <{{ awx_credential_id }}> in <{{ job.name }}> job_template" vars: query: '[? id==`{{ awx_credential_id }}`].id' set_fact: - found_credential_id: "{{ item.results | json_query(query) | first }}" - when: > - (item.results is defined) and (item.results | length > 0) and - (item.results | json_query(query) | length > 0) - loop: - - "{{ awx_job_template_info['content'] }}" + found_credential_id: "{{ awx_job_template_info_json.results | json_query(query) | first | default(None) }}" + when: (awx_job_template_info_json.results is defined) and (awx_job_template_info_json.results | length > 0) + tags: + - awx_config + +- name: "Printing..." + debug: + msg: "{{ awx_type_id }}" + delegate_to: 127.0.0.1 + when: + - debug + - awx_type_id is defined tags: - - awx_communication + - awx_config -- name: "Add credential id {{ awx_credential_id }} to {{ jobinfo.name }} job_template" +- name: "Add credential id {{ awx_credential_id }} to {{ job.name }} job_template" uri: url: "{{ awx_base_url }}/api/v2/job_templates/{{ awx_job_template_id }}/credentials/" method: POST @@ -51,7 +72,7 @@ validate_certs: false status_code: 204 tags: - - awx_communication + - awx_config when: > (found_credential_id | default("") | length == 0) and (awx_credential_id is defined) and diff --git a/roles/awx/tasks/awx-config-job-template.yml b/roles/awx/tasks/awx-config-job-template.yml new file mode 100644 index 0000000..59ba1d5 --- /dev/null +++ b/roles/awx/tasks/awx-config-job-template.yml @@ -0,0 +1,77 @@ +--- + +- set_fact: + awx_job_template_id: "None" + changed_when: False + tags: + - awx_config + +- name: "Search job template {{ job.name }}" + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: job_templates + awx_search_key: name + awx_search_name: "{{ job.name }}" + tags: + - awx_config + +- name: "Update awx_job_template_id" + set_fact: + awx_job_template_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Add job template {{ job.name }}" + vars: + name: "{{ job.name }}" + description: "{{ job.description | default(name) }}" + inventory_id: "{{ awx_localhost_inventory_id }}" + project_id: "{{ awx_hetzner_ansible_project_id }}" + execution_environment_id: "{{ awx_ee_hetzner_ansible_id }}" + playbook: "{{ job.playbook_file | default(name + '.yml') }}" + ask_variables_on_launch: true + uri: + url: "{{ awx_base_url }}/api/v2/job_templates/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-job-template.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: awx_job_template_id == "None" + tags: + - awx_config + +- name: "Search job template {{ job.name }}" + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: job_templates + awx_search_key: name + awx_search_name: "{{ job.name }}" + when: awx_job_template_id == "None" + tags: + - awx_config + +- name: "Update awx_job_template_id" + set_fact: + awx_job_template_id: "{{ awx_type_id }}" + when: awx_job_template_id == "None" + tags: + - awx_config + +- include_tasks: awx-config-job-template-credential.yml + loop: "{{ job.credentials }}" + loop_control: + loop_var: awx_credential_id + when: awx_job_template_id is defined + tags: + - awx_config \ No newline at end of file diff --git a/roles/awx/tasks/awx-config.yml b/roles/awx/tasks/awx-config.yml new file mode 100644 index 0000000..a0156de --- /dev/null +++ b/roles/awx/tasks/awx-config.yml @@ -0,0 +1,583 @@ +--- + +- name: "Printing..." + debug: + msg: "{{ ansible_ssh_key_private }}" + delegate_to: 127.0.0.1 + when: + - debug + tags: + - awx_config + +- name: "Authenticating with awx server" + uri: + url: "{{ awx_base_url }}/api/v2/me/" + method: GET + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + return_content: true + validate_certs: false + force_basic_auth: yes + status_code: 200 + tags: + - awx_config + +- name: "Search user <{{ awx_ansible_username }}>" + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: users + awx_search_key: username + awx_search_name: "{{ awx_ansible_username }}" + tags: + - awx_config + +- name: "Update ansible_awx_user_id" + set_fact: + ansible_awx_user_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Add user <{{ awx_ansible_username }}>" + vars: + username: "{{ awx_ansible_username }}" + password: "{{ awx_ansible_password }}" + uri: + url: "{{ awx_base_url }}/api/v2/users/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-user.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: ansible_awx_user_id is not defined + tags: + - awx_config + +- name: "Search user <{{ awx_ansible_username }}>" + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: users + awx_search_key: username + awx_search_name: "{{ awx_ansible_username }}" + when: ansible_awx_user_id is not defined + tags: + - awx_config + +- name: "Update ansible_awx_user_id" + set_fact: + ansible_awx_user_id: "{{ awx_type_id }}" + when: ansible_awx_user_id is not defined + tags: + - awx_config + +- name: "Search credential type id for " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credential_types + awx_search_key: name + awx_search_name: "Machine" + tags: + - awx_config + +- name: "Update awx_credential_type_machine_id" + set_fact: + awx_credential_type_machine_id: "{{ awx_type_id }}" + when: + - awx_type_id | default(None) != None + tags: + - awx_config + +- name: "Search credentials " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credentials + awx_search_key: name + awx_search_name: "hetzner-ansible-ssh" + tags: + - awx_config + +- name: "Update awx_credential_hetzner_ansible_id" + set_fact: + awx_credential_hetzner_ansible_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Add credentials " + vars: + name: "hetzner-ansible-ssh" + user_id: "{{ ansible_awx_user_id }}" + credential_type_id: "{{ awx_credential_type_machine_id }}" + credential_type_name: "Machine" + username: "Ansible" + ssh_public_key_data: "{{ lookup('file', '{{ playbook_dir }}/users/ansible/id_rsa.pub') }}" + ssh_key_data: "{{ ansible_ssh_key_private }}" + uri: + url: "{{ awx_base_url }}/api/v2/credentials/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-credential.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: awx_credential_hetzner_ansible_id is not defined + tags: + - awx_config + +- name: "Search credentials " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credentials + awx_search_key: name + awx_search_name: "hetzner-ansible-ssh" + when: awx_credential_hetzner_ansible_id is not defined + tags: + - awx_config + +- name: "Update awx_credential_hetzner_ansible_id" + set_fact: + awx_credential_hetzner_ansible_id: "{{ awx_type_id }}" + when: awx_credential_hetzner_ansible_id is not defined + tags: + - awx_config + +- name: "Search credential type id for " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credential_types + awx_search_key: name + awx_search_name: "Vault" + tags: + - awx_config + +- name: "Update awx_credential_type_vault_id" + set_fact: + awx_credential_type_vault_id: "{{ awx_type_id }}" + when: + - awx_type_id | default(None) != None + tags: + - awx_config + +- name: "Search credentials " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credentials + awx_search_key: name + awx_search_name: "hetzner-ansible-vault" + tags: + - awx_config + +- name: "Update awx_credential_hetzner_ansible_vault_id" + set_fact: + awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Add credentials " + vars: + name: "hetzner-ansible-vault" + user_id: "{{ ansible_awx_user_id }}" + credential_type_id: "{{ awx_credential_type_vault_id }}" + credential_type_name: "Vault" + vault_password: "{{ vault_ansible_password }}" + uri: + url: "{{ awx_base_url }}/api/v2/credentials/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-credential.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: awx_credential_hetzner_ansible_vault_id is not defined + tags: + - awx_config + +- name: "Search credentials " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credentials + awx_search_key: name + awx_search_name: "hetzner-ansible-vault" + when: awx_credential_hetzner_ansible_vault_id is not defined + tags: + - awx_config + +- name: "Update awx_credential_hetzner_ansible_vault_id" + set_fact: + awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}" + when: awx_credential_hetzner_ansible_vault_id is not defined + tags: + - awx_config + +- name: "Search credential type id for " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credential_types + awx_search_key: name + awx_search_name: "Container Registry" + tags: + - awx_config + +- name: "Update awx_credential_type_container_registry_id" + set_fact: + awx_credential_type_container_registry_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Search credentials " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credentials + awx_search_key: name + awx_search_name: "dev-docker-registry-01.smardigo.digital" + tags: + - awx_config + +- name: "Update awx_credential_docker_registry_id" + set_fact: + awx_credential_docker_registry_id: "{{ awx_type_id }}" + when: + - awx_type_id | default(None) != "None" + tags: + - awx_config + +- name: "Add credentials " + vars: + name: "{{ shared_service_docker_registry_hostname }}" + description: "{{ shared_service_docker_registry_hostname }}" + user_id: "{{ ansible_awx_user_id }}" + credential_type_id: "{{ awx_credential_type_container_registry_id }}" + credential_type_name: "Container Registry" + host: "{{ shared_service_docker_registry_hostname }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_token }}" + uri: + url: "{{ awx_base_url }}/api/v2/credentials/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-credential.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: awx_credential_docker_registry_id is not defined + tags: + - awx_config + +- name: "Search credentials " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: credentials + awx_search_key: name + awx_search_name: "dev-docker-registry-01.smardigo.digital" + when: awx_credential_docker_registry_id is not defined + tags: + - awx_config + +- name: "Update awx_credential_docker_registry_id" + set_fact: + awx_credential_docker_registry_id: "{{ awx_type_id }}" + when: awx_credential_docker_registry_id is not defined + tags: + - awx_config + +- name: "Search execution environment for " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: execution_environments + awx_search_key: name + awx_search_name: "hetzner-ansible" + tags: + - awx_config + +- name: "Update awx_ee_hetzner_ansible_id" + set_fact: + awx_ee_hetzner_ansible_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Add execution environment " + vars: + name: "hetzner-ansible" + description: "hetzner-ansible" + image: "dev-docker-registry-01.smardigo.digital/awx/awx-custom-ee" + credential: "{{ awx_credential_docker_registry_id }}" + pull: "always" + uri: + url: "{{ awx_base_url }}/api/v2/execution_environments/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-execution-environment.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: awx_ee_hetzner_ansible_id is not defined + tags: + - awx_config + +- name: "Search execution environment for " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: execution_environments + awx_search_key: name + awx_search_name: "hetzner-ansible" + when: awx_ee_hetzner_ansible_id is not defined + tags: + - awx_config + +- name: "Update awx_ee_hetzner_ansible_id" + set_fact: + awx_ee_hetzner_ansible_id: "{{ awx_type_id }}" + when: awx_ee_hetzner_ansible_id is not defined + tags: + - awx_config + +- name: "Search inventory " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: inventories + awx_search_key: name + awx_search_name: "localhost" + tags: + - awx_config + +- name: "Update awx_localhost_inventory_id" + set_fact: + awx_localhost_inventory_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Add inventory " + vars: + name: "localhost" + description: "localhost" + uri: + url: "{{ awx_base_url }}/api/v2/inventories/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-inventory.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: awx_localhost_inventory_id is not defined + tags: + - awx_config + +- name: "Search inventory " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: inventories + awx_search_key: name + awx_search_name: "localhost" + when: awx_localhost_inventory_id is not defined + tags: + - awx_config + +- name: "Update awx_localhost_inventory_id" + set_fact: + awx_localhost_inventory_id: "{{ awx_type_id }}" + when: awx_localhost_inventory_id is not defined + tags: + - awx_config + +- name: "Create archive for repository " + shell: cd {{ playbook_dir }} && git archive --format tar.gz -o /tmp/hetzner-ansible.tar.gz HEAD + delegate_to: 127.0.0.1 + become: false + tags: + - awx_config + +- name: "Remove old rpository folder for " + file: + state: absent + path: "{{ awx_project_path }}/hetzner-ansible" + tags: + - awx_config + +- name: "Create project folder for " + file: + path: "{{ awx_project_path }}/hetzner-ansible" + state: directory + owner: root + group: root + mode: '0555' + tags: + - awx_config + +- name: "Extract repository archive for " + unarchive: + src: /tmp/hetzner-ansible.tar.gz + dest: "{{ awx_project_path }}/hetzner-ansible" + tags: + - awx_config + +- name: "Remove repository archive for " + file: + state: absent + path: /tmp/hetzner-ansible.tar.gz + tags: + - awx_config + +- name: "Search project " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: projects + awx_search_key: name + awx_search_name: "hetzner-ansible" + tags: + - awx_config + +- name: "Update awx_hetzner_ansible_project_id" + set_fact: + awx_hetzner_ansible_project_id: "{{ awx_type_id }}" + when: + - (awx_type_id | default(None)) != "None" + tags: + - awx_config + +- name: "Add project " + vars: + name: "hetzner-ansible" + description: "hetzner-ansible" + local_path: "hetzner-ansible" + default_environment_id: "{{ awx_ee_hetzner_ansible_id }}" + uri: + url: "{{ awx_base_url }}/api/v2/projects/" + method: POST + user: "{{ awx_rest_api_access_user }}" + password: "{{ awx_rest_api_access_pw }}" + headers: + Content-Type: "application/json" + Accept: "application/json" + body_format: "json" + body: "{{ lookup('template','awx-create-project.json.j2') }}" + force_basic_auth: true + validate_certs: false + status_code: 201 + register: response + changed_when: response.status == 201 + when: awx_hetzner_ansible_project_id is not defined + tags: + - awx_config + +- name: "Search project " + include_tasks: awx-config-get-typ-id.yml + vars: + awx_rest_api_type: projects + awx_search_key: name + awx_search_name: "hetzner-ansible" + when: (awx_hetzner_ansible_project_id is not defined) + tags: + - awx_config + +- name: "Update awx_hetzner_ansible_project_id" + set_fact: + awx_hetzner_ansible_project_id: "{{ awx_type_id }}" + when: awx_hetzner_ansible_project_id is not defined + tags: + - awx_config + +- name: "Create job templates on awx server" + include_tasks: awx-config-job-template.yml + loop: + - { + name: "create-server", + #description: "create-server", + #playbook_file: "create-server.yml", + credentials: [ + "{{ awx_credential_hetzner_ansible_vault_id }}", + "{{ awx_credential_hetzner_ansible_id }}", + ] + } + - { + name: "create-database-container", + #description: "create-database-container", + #playbook_file: "create-database-container.yml", + credentials: [ + "{{ awx_credential_hetzner_ansible_vault_id }}", + "{{ awx_credential_hetzner_ansible_id }}", + ] + } + - { + name: "create-database-cluster", + #description: "create-database-cluster", + #playbook_file: "create-database-cluster.yml", + credentials: [ + "{{ awx_credential_hetzner_ansible_vault_id }}", + "{{ awx_credential_hetzner_ansible_id }}", + ] + } + - { + name: "create-realm", + #description: "create-realm", + #playbook_file: "create-realm.yml", + credentials: [ + "{{ awx_credential_hetzner_ansible_vault_id }}", + "{{ awx_credential_hetzner_ansible_id }}", + ] + } + - { + name: "create-service", + #description: "create-service", + #playbook_file: "create-service.yml", + credentials: [ + "{{ awx_credential_hetzner_ansible_vault_id }}", + "{{ awx_credential_hetzner_ansible_id }}", + ] + } + loop_control: + loop_var: job + tags: + - awx_config diff --git a/roles/awx/tasks/awx-configurator.yml b/roles/awx/tasks/awx-configurator.yml deleted file mode 100644 index 01e4456..0000000 --- a/roles/awx/tasks/awx-configurator.yml +++ /dev/null @@ -1,586 +0,0 @@ ---- -- name: "Add basic configuration awx server" - block: - - name: "Authenticating with awx server" - uri: - url: "{{ awx_base_url }}/api/v2/me/" - method: GET - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - return_content: true - validate_certs: false - force_basic_auth: yes - status_code: 200 - tags: - - awx_communication - - - name: "Search 'Ansible' user to awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: users - awx_search_key: username - awx_search_name: "Ansible" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update ansible_awx_user_id" - set_fact: - ansible_awx_user_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Add Ansible user to awx server" - vars: - username: "Ansible" - password: "Ansible" - uri: - url: "{{ awx_base_url }}/api/v2/users/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-create-user-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - when: (ansible_awx_user_id is not defined) and (ansible_awx_user_id | length > 0) - tags: - - awx_communication - - - name: "Search 'Ansible' user on awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: users - awx_search_key: username - awx_search_name: "Ansible" - awx_type_id: "" - when: (ansible_awx_user_id is not defined) - tags: - - awx_communication - - - name: "Update ansible_awx_user_id" - set_fact: - ansible_awx_user_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (ansible_awx_user_id is not defined) and - (awx_type_id is defined) and - (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Get 'Machine' type id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credential_types - awx_search_key: name - awx_search_name: "Machine" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_credential_type_machine_id" - set_fact: - awx_credential_type_machine_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Get 'Machine' type 'Hetzner-Ansible' type id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credentials - awx_search_key: name - awx_search_name: "Hetzner-Ansible" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_credential_hetzner_ansible_id" - set_fact: - awx_credential_hetzner_ansible_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Add 'Machine' type 'Hetzner_Ansible' credential to awx server" - vars: - name: "Hetzner-Ansible" - user_id: "{{ ansible_awx_user_id }}" - credential_type_id: "{{ awx_credential_type_machine_id }}" - credential_type_name: "Machine" - username: "Ansible" - ssh_public_key_data: "{{ lookup('file', '{{ playbook_dir }}/users/ansible/id_rsa.pub') | replace('\n', '') }}" - ssh_key_data: "{{ lookup('file', '{{ playbook_dir }}/users/ansible_ssh_key') | replace('\n', '') }}" - uri: - url: "{{ awx_base_url }}/api/v2/credentials/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-create-credential-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - tags: - - awx_communication - when: > - (awx_credential_hetzner_ansible_id is not defined) and - (ansible_awx_user_id is defined) and - (ansible_awx_user_id | length > 0) and - (awx_credential_type_machine_id is defined) and - (awx_credential_type_machine_id | length > 0) - - - name: "Get 'Machine' type 'Hetzner_Ansible' type id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credentials - awx_search_key: name - awx_search_name: "Hetzner-Ansible" - awx_type_id: "" - when: (awx_credential_hetzner_ansible_id is not defined) - tags: - - awx_communication - - - name: "Update awx_credential_hetzner_ansible_id" - set_fact: - awx_credential_hetzner_ansible_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (awx_credential_hetzner_ansible_id is not defined) and - (awx_type_id is defined) and - (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Get 'Vault' type id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credential_types - awx_search_key: name - awx_search_name: "Vault" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_credential_type_vault_id" - set_fact: - awx_credential_type_vault_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Get 'Vault' type 'Hetzner_Ansible_Vault' type id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credentials - awx_search_key: name - awx_search_name: "Hetzner-Ansible-Vault" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_credential_hetzner_ansible_vault_id" - set_fact: - awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Add 'Vault' type 'Hetzner-Ansible-Vault' credential to awx server" - vars: - name: "Hetzner-Ansible-Vault" - user_id: "{{ ansible_awx_user_id }}" - credential_type_id: "{{ awx_credential_type_vault_id }}" - credential_type_name: "Vault" - #should be more secure - vault_password: devops123 - uri: - url: "{{ awx_base_url }}/api/v2/credentials/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-create-credential-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - tags: - - awx_communication - when: > - (awx_credential_hetzner_ansible_vault_id is not defined) and - (ansible_awx_user_id is defined) and - (ansible_awx_user_id | length > 0) and - (awx_credential_type_vault_id is defined) and - (awx_credential_type_vault_id | length > 0) - - - name: "Get 'Vault' type 'Hetzner-Ansible-Vault' type id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credentials - awx_search_key: name - awx_search_name: "Hetzner-Ansible-Vault" - awx_type_id: "" - when: (awx_credential_hetzner_ansible_vault_id is not defined) - tags: - - awx_communication - - - name: "Update awx_credential_hetzner_ansible_vault_id" - set_fact: - awx_credential_hetzner_ansible_vault_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (awx_credential_hetzner_ansible_vault_id is not defined) and - (awx_type_id is defined) and - (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Search 'Container Registry' type id to awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credential_types - awx_search_key: name - awx_search_name: "Container Registry" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_credential_type_container_registry_id" - set_fact: - awx_credential_type_container_registry_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Get 'Docker Registry' id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credentials - awx_search_key: name - awx_search_name: "Docker Registry" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_credential_docker_registry_id" - set_fact: - awx_credential_docker_registry_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Add 'Container Registry' credential to awx server" - vars: - name: "Docker Registry" - description: "Docker Registry Smardigo Credentials" - user_id: "{{ ansible_awx_user_id }}" - credential_type_id: "{{ awx_credential_type_container_registry_id }}" - credential_type_name: "Container Registry" - host: "dev-docker-registry-01.smardigo.digital" - username: "{{ docker_registry_username }}" - password: "{{ docker_registry_token }}" - uri: - url: "{{ awx_base_url }}/api/v2/credentials/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-create-credential-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - tags: - - awx_communication - when: > - (awx_credential_docker_registry_id is not defined) and - (ansible_awx_user_id is defined) and - (ansible_awx_user_id | length > 0) and - (awx_credential_type_container_registry_id is defined) and - (awx_credential_type_container_registry_id | length > 0) - - - name: "Get 'Docker Registry' id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: credentials - awx_search_key: name - awx_search_name: "Docker Registry" - awx_type_id: "" - when: (awx_credential_docker_registry_id is not defined) - tags: - - awx_communication - - - name: "Update awx_credential_docker_registry_id" - set_fact: - awx_credential_docker_registry_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (awx_credential_docker_registry_id is not defined) and - (awx_type_id is defined) and - (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Get 'Hetzner-Ansible' execution environment id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: execution_environments - awx_search_key: name - awx_search_name: "Hetzner-Ansible" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_ee_hetzner_ansible_id" - set_fact: - awx_ee_hetzner_ansible_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Register execution environment container image to awx server" - vars: - name: "Hetzner-Ansible" - description: "test" - image: "dev-docker-registry-01.smardigo.digital/awx/awx-custom-ee" - credential: "{{ awx_credential_docker_registry_id }}" - pull: "always" - uri: - url: "{{ awx_base_url }}/api/v2/execution_environments/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-add-ee-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - tags: - - awx_communication - when: > - (awx_ee_hetzner_ansible_id is not defined) and - (awx_credential_docker_registry_id is defined) and - (awx_credential_docker_registry_id | length > 0) - - - name: "Get 'Hetzner-Ansible' execution environment id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: execution_environments - awx_search_key: name - awx_search_name: "Hetzner-Ansible" - awx_type_id: "" - when: (awx_ee_hetzner_ansible_id is not defined) - tags: - - awx_communication - - - name: "Update awx_ee_hetzner_ansible_id" - set_fact: - awx_ee_hetzner_ansible_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (awx_ee_hetzner_ansible_id is not defined) and - (awx_type_id is defined) and - (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Get 'localhost' inventory id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: inventories - awx_search_key: name - awx_search_name: "localhost" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_localhost_inventory_id" - set_fact: - awx_localhost_inventory_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Add a empty 'localhost' inventory to awx server" - vars: - name: "localhost" - description: "localhost" - uri: - url: "{{ awx_base_url }}/api/v2/inventories/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-add-inventory-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - tags: - - awx_communication - when: (awx_localhost_inventory_id is not defined) - - - name: "Get 'localhost' inventory id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: inventories - awx_search_key: name - awx_search_name: "localhost" - awx_type_id: "" - when: (awx_localhost_inventory_id is not defined) - tags: - - awx_communication - - - name: "Update awx_localhost_inventory_id" - set_fact: - awx_localhost_inventory_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (awx_localhost_inventory_id is not defined) and - (awx_type_id is defined) and - (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Tar hetzner-ansible repository" - shell: cd {{ playbook_dir }} && git archive --format tar.gz -o /tmp/hetzner-ansible.tar.gz HEAD - delegate_to: localhost - become: false - tags: - - awx_communication - - - name: "Remove old archive awx project folder" - file: - state: absent - path: "{{ awx_project_path }}/hetzner-ansible" - tags: - - awx_communication - - - name: "Create Project Folder 'hetzner-ansible'" - file: - path: "{{ awx_project_path }}/hetzner-ansible" - state: directory - owner: root - group: root - mode: '0555' - tags: - - awx_communication - - - name: "Extract hetzner-ansible repository to the awx project folder" - unarchive: - src: /tmp/hetzner-ansible.tar.gz - dest: "{{ awx_project_path }}/hetzner-ansible" - tags: - - awx_communication - - - name: "Cleanup created hetzner-ansible archive" - file: - state: absent - path: /tmp/hetzner-ansible.tar.gz - tags: - - awx_communication - - - name: "Get 'Hetzner-Ansible' projects id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: projects - awx_search_key: name - awx_search_name: "Hetzner-Ansible" - awx_type_id: "" - tags: - - awx_communication - - - name: "Update awx_hetzner_ansible_project_id" - set_fact: - awx_hetzner_ansible_project_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Add 'Hetzner-Ansible' project to awx server" - vars: - name: "Hetzner-Ansible" - description: "Hetzner-Ansible" - local_path: "hetzner-ansible" - default_environment_id: "{{ awx_ee_hetzner_ansible_id }}" - uri: - url: "{{ awx_base_url }}/api/v2/projects/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-add-project-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - tags: - - awx_communication - when: > - (awx_hetzner_ansible_project_id is not defined) and - (awx_ee_hetzner_ansible_id is defined) - - - name: "Get 'hetzner-ansible' projects id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: projects - awx_search_key: name - awx_search_name: "Hetzner-Ansible" - awx_type_id: "" - when: (awx_hetzner_ansible_project_id is not defined) - tags: - - awx_communication - - - name: "Update awx_hetzner_ansible_project_id" - set_fact: - awx_hetzner_ansible_project_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (awx_hetzner_ansible_project_id is not defined) and - (awx_type_id is defined) and - (awx_type_id | length > 0) - tags: - - awx_communication - - - name: "Create job templates on awx server" - include_tasks: awx-create-job-template.yml - loop: - - { name: "create-database", desc: "create-database", playbook_file: "create-database.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] } - - { name: "create-realm", desc: "create-realm", playbook_file: "create-realm.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] } - - { name: "create-server", desc: "create-server", playbook_file: "create-server.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] } - - { name: "create-service", desc: "create-service", playbook_file: "create-service.yml", credentials: ["{{ awx_credential_hetzner_ansible_vault_id }}", "{{ awx_credential_hetzner_ansible_id }}"] } - loop_control: - loop_var: jobinfo - tags: - - awx_communication diff --git a/roles/awx/tasks/awx-create-job-template.yml b/roles/awx/tasks/awx-create-job-template.yml deleted file mode 100644 index 7b7f2f4..0000000 --- a/roles/awx/tasks/awx-create-job-template.yml +++ /dev/null @@ -1,83 +0,0 @@ ---- - -- set_fact: - awx_job_template_id: "" - tags: - - awx_communication - -- name: "Get {{jobinfo.name}} job_templates id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: job_templates - awx_search_key: name - awx_search_name: "{{jobinfo.name}}" - awx_type_id: "" - tags: - - awx_communication - -- name: "Update awx_create_database_job_template_id" - set_fact: - awx_job_template_id: "{{ awx_type_id }}" - awx_type_id: "" - when: (awx_type_id is defined) and (awx_type_id | length > 0) - tags: - - awx_communication - -- name: "Add {{jobinfo.name}} job_template to awx server" - vars: - name: "{{jobinfo.name}}" - description: "{{jobinfo.desc}}" - inventory_id: "{{ awx_localhost_inventory_id }}" - project_id: "{{ awx_hetzner_ansible_project_id }}" - execution_environment_id: "{{ awx_ee_hetzner_ansible_id }}" - playbook: "{{jobinfo.playbook_file}}" - ask_variables_on_launch: true - uri: - url: "{{ awx_base_url }}/api/v2/job_templates/" - method: POST - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - body_format: "json" - body: "{{ lookup('template','awx-add-job-template-config.json.j2') }}" - force_basic_auth: true - validate_certs: false - status_code: 200, 201 - tags: - - awx_communication - when: > - (awx_job_template_id | default("") | length == 0) and - (awx_localhost_inventory_id is defined) and - (awx_hetzner_ansible_project_id is defined) and - (awx_ee_hetzner_ansible_id is defined) - -- name: "Get {{jobinfo.name}} job_templates id from awx server" - include_tasks: awx-get-typ-id.yml - vars: - awx_rest_api_type: job_templates - awx_search_key: name - awx_search_name: "{{jobinfo.name}}" - awx_type_id: "" - tags: - - awx_communication - -- name: "Update awx_job_template_id for {{jobinfo.name}}" - set_fact: - awx_job_template_id: "{{ awx_type_id }}" - awx_type_id: "" - when: > - (awx_type_id is defined) and - (awx_type_id | length > 0) -# no_log: true - tags: - - awx_communication - -- include_tasks: awx-add-credential-to-job-template.yml - loop: "{{ jobinfo.credentials }}" - loop_control: - loop_var: awx_credential_id - when: (jobinfo is defined) and (jobinfo.credentials is defined ) - tags: - - awx_communication \ No newline at end of file diff --git a/roles/awx/tasks/awx-get-typ-id.yml b/roles/awx/tasks/awx-get-typ-id.yml deleted file mode 100644 index 03ebf28..0000000 --- a/roles/awx/tasks/awx-get-typ-id.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- - -- name: "Search {{ awx_rest_api_type }} informations for {{ awx_search_name }} on awx server" - uri: - url: "{{ awx_base_url }}/api/v2/{{ awx_rest_api_type }}/?search={{ awx_search_name | urlencode }}" - method: GET - user: "{{ awx_rest_api_access_user }}" - password: "{{ awx_rest_api_access_pw }}" - return_content: true - validate_certs: false - force_basic_auth: yes - status_code: 200 - no_log: true - register: awx_type_info - tags: - - awx_communication - -- name: "Get {{ awx_rest_api_type }} id for {{ awx_search_name }} on awx server" - vars: - query: '[? {{ awx_search_key }}==`{{ awx_search_name }}`].id' - set_fact: - awx_type_id: "{{ item.results | json_query(query) | first }}" - when: (item.results is defined) and (item.results | length > 0) - loop: - - "{{ awx_type_info['content'] }}" - no_log: true - tags: - - awx_communication \ No newline at end of file diff --git a/roles/awx/tasks/main.yml b/roles/awx/tasks/main.yml index 5f616e2..189e8c7 100644 --- a/roles/awx/tasks/main.yml +++ b/roles/awx/tasks/main.yml @@ -3,7 +3,7 @@ ### tags: ### kube_apply ### kube_install -### awx_communication +### awx_config - name: "Install pip3 for {{ service_name }}" apt: @@ -130,11 +130,11 @@ tags: - kube_apply -- include_tasks: awx-configurator.yml +- include_tasks: awx-config.yml vars: awx_base_url: "http://{{ stage_server_ip }}" awx_rest_api_access_user: "{{ awx_admin_username }}" awx_rest_api_access_pw: "{{ awx_admin_password }}" awx_project_path: "{{ kubernetes_awx_project_volume_path }}" tags: - - awx_communication + - awx_config diff --git a/roles/awx/templates/awx-add-ee-config.json.j2 b/roles/awx/templates/awx-add-ee-config.json.j2 deleted file mode 100644 index f069521..0000000 --- a/roles/awx/templates/awx-add-ee-config.json.j2 +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "{{ name }}", - "description": "{{ description | default("") }}", - {% if organization_id is defined %} - "organization": "{{ organization_id }}", - {% endif %} - "image": "{{ image }}", - "credential": "{{ credential }}", - "pull": "{{ pull }}" {# "": "---------", "always": "Always pull container before running.", - "missing": "Only pull the image if not present before running.", - "never": "Never pull container before running." #} -} \ No newline at end of file diff --git a/roles/awx/templates/awx-create-credential-config.json.j2 b/roles/awx/templates/awx-create-credential.json.j2 similarity index 96% rename from roles/awx/templates/awx-create-credential-config.json.j2 rename to roles/awx/templates/awx-create-credential.json.j2 index 5a4fc43..a97d956 100644 --- a/roles/awx/templates/awx-create-credential-config.json.j2 +++ b/roles/awx/templates/awx-create-credential.json.j2 @@ -20,7 +20,7 @@ } {% elif credential_type_name == "Container Registry" %} "inputs": { - "host": "{{ username }}", + "host": "{{ host }}", "username": "{{ username }}", "password": "{{ password }}" } diff --git a/roles/awx/templates/awx-create-execution-environment.json.j2 b/roles/awx/templates/awx-create-execution-environment.json.j2 new file mode 100644 index 0000000..7e1701d --- /dev/null +++ b/roles/awx/templates/awx-create-execution-environment.json.j2 @@ -0,0 +1,10 @@ +{ + "name": "{{ name }}", + "description": "{{ description | default("") }}", + {% if organization_id is defined %} + "organization": "{{ organization_id }}", + {% endif %} + "image": "{{ image }}", + "credential": "{{ credential }}", + "pull": "{{ pull }}" +} \ No newline at end of file diff --git a/roles/awx/templates/awx-add-inventory-config.json.j2 b/roles/awx/templates/awx-create-inventory.json.j2 similarity index 100% rename from roles/awx/templates/awx-add-inventory-config.json.j2 rename to roles/awx/templates/awx-create-inventory.json.j2 diff --git a/roles/awx/templates/awx-add-job-template-config.json.j2 b/roles/awx/templates/awx-create-job-template.json.j2 similarity index 100% rename from roles/awx/templates/awx-add-job-template-config.json.j2 rename to roles/awx/templates/awx-create-job-template.json.j2 diff --git a/roles/awx/templates/awx-add-project-config.json.j2 b/roles/awx/templates/awx-create-project.json.j2 similarity index 100% rename from roles/awx/templates/awx-add-project-config.json.j2 rename to roles/awx/templates/awx-create-project.json.j2 diff --git a/roles/awx/templates/awx-create-user-config.json.j2 b/roles/awx/templates/awx-create-user.json.j2 similarity index 100% rename from roles/awx/templates/awx-create-user-config.json.j2 rename to roles/awx/templates/awx-create-user.json.j2 diff --git a/smardigo.yml b/smardigo.yml index 6225ab6..4a5ee57 100644 --- a/smardigo.yml +++ b/smardigo.yml @@ -22,7 +22,7 @@ become: false tags: - update_networks - - awx_communication + - awx_config - name: "Set current server infos as fact: hetzner_server_infos_json" set_fact: @@ -31,7 +31,7 @@ become: false tags: - update_networks - - awx_communication + - awx_config - name: "Read ip address for {{ inventory_hostname }}" set_fact: @@ -42,7 +42,7 @@ become: false tags: - update_networks - - awx_communication + - awx_config - name: Print the gathered infos debug: @@ -51,7 +51,7 @@ become: false tags: - update_networks - - awx_communication + - awx_config roles: - role: postfix diff --git a/smardigo/provisioning/datasource-file/master_data.xlsx b/smardigo/provisioning/datasource-file/master_data.xlsx deleted file mode 100644 index 8bde9f3..0000000 Binary files a/smardigo/provisioning/datasource-file/master_data.xlsx and /dev/null differ diff --git a/smardigo/provisioning/datasource/accounts.json b/smardigo/provisioning/datasource/accounts.json deleted file mode 100644 index 5fdd039..0000000 --- a/smardigo/provisioning/datasource/accounts.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name" : "Accounts", - "restApi" : true, - "configKey" : "accounts", - "payloadType" : "EXCEL", - "config" : [ { - "name" : "file", - "type" : "FILE", - "value" : "master_data.xlsx" - }, { - "name" : "columnNames", - "type" : "STRING", - "value" : "" - }, { - "name" : "sqlStatement", - "type" : "STRING", - "value" : "select * from accounts" - }, { - "name" : "columnNameLineNumber", - "type" : "INT", - "value" : 1 - }, { - "name" : "skipEmptyLines", - "type" : "BOOLEAN", - "value" : false - }, { - "name" : "skipEmptyColumns", - "type" : "BOOLEAN", - "value" : false - } ] -} \ No newline at end of file diff --git a/smardigo/provisioning/datasource/awx-job-templates-plain.json b/smardigo/provisioning/datasource/awx-job-templates-plain.json new file mode 100644 index 0000000..b9a07b5 --- /dev/null +++ b/smardigo/provisioning/datasource/awx-job-templates-plain.json @@ -0,0 +1,19 @@ +{ + "name" : "awx-job-templates-plain", + "restApi" : true, + "configKey" : "awx-job-templates-plain", + "payloadType" : "REST", + "config" : [ { + "name" : "connection", + "type" : "CONNECTION", + "value" : "awx" + }, { + "name" : "resource", + "type" : "STRING", + "value" : "api/v2/job_templates?search=${name}" + }, { + "name" : "sqlStatement", + "type" : "STRING", + "value" : "SELECT results FROM default_table" + } ] +} \ No newline at end of file diff --git a/smardigo/provisioning/datasource/awx-job-templates.json b/smardigo/provisioning/datasource/awx-job-templates.json new file mode 100644 index 0000000..e0b9d21 --- /dev/null +++ b/smardigo/provisioning/datasource/awx-job-templates.json @@ -0,0 +1,15 @@ +{ + "name" : "awx-job-templates", + "restApi" : true, + "configKey" : "awx-job-templates", + "payloadType" : "POST_PROCESSING", + "config" : [ { + "name" : "datasource_key", + "type" : "STRING", + "value" : "awx-job-templates-plain" + }, { + "name" : "groovy_script", + "type" : "STRING", + "value" : "def result = []\ndata.each{templates ->\n templates.results.each{ template ->\n if (parameters['name'] == template.name) {\n result.add([id: template.id, name: template.name])\n }\n }\n}\nresult" + } ] +} \ No newline at end of file diff --git a/smardigo/provisioning/process/simple-connect.bpmn b/smardigo/provisioning/process/simple-connect.bpmn index 4a3b9e3..497eeb3 100644 --- a/smardigo/provisioning/process/simple-connect.bpmn +++ b/smardigo/provisioning/process/simple-connect.bpmn @@ -217,7 +217,6 @@ Variables.userId(authenticatedUserId) ${5} - Flow_1f0iyrk Flow_11k5c1y @@ -252,9 +251,11 @@ Variables.userId(authenticatedUserId) + + datasources.query('awx-templates-filtered').processScope(contextScopeId, contextProcessId).parameters([name:'create-server']).list()[0]; + ${2} - Flow_11ki58f Flow_1eku1o4 @@ -263,12 +264,11 @@ Variables.userId(authenticatedUserId) - + ${3} - Flow_1eku1o4 Flow_0pvr263 @@ -282,7 +282,6 @@ Variables.userId(authenticatedUserId) ${4} - Flow_0pvr263 Flow_1f0iyrk @@ -346,7 +345,6 @@ Variables.userId(authenticatedUserId) ${5} - Flow_1d2gl8q Flow_1c6reic @@ -360,7 +358,6 @@ Variables.userId(authenticatedUserId) ${2} - Flow_07sf9z8 Flow_0dc3zbr @@ -369,12 +366,11 @@ Variables.userId(authenticatedUserId) - + ${3} - Flow_0dc3zbr Flow_1leflml @@ -388,7 +384,6 @@ Variables.userId(authenticatedUserId) ${4} - Flow_1leflml Flow_1d2gl8q @@ -639,14 +634,6 @@ Datenbanken erstellen - (wordpress) - Credentials in Vorgang ablegen - - Service auf Server installieren - -- Domain (Services) -- connect -- (wordpress) - - Service auf Server installieren @@ -666,6 +653,14 @@ Datenbanken erstellen - Database + + + Service auf Server installieren + +- Domain (Services) +- connect +- (wordpress) + @@ -685,40 +680,54 @@ Datenbanken erstellen - - Flow_1ow8whd - - - Flow_1ow8whd - Flow_0qfq760 + + Flow_1ju13h8 + + + + Flow_0gcsmj7 + Flow_1ju13h8 - + + Flow_0rau5wd + Flow_0gcsmj7 + + + - + - Neue Aufgabe - ${smardigoManagementAction} - https://img.welt.de/img/vermischtes/bilder-des-tages/mobile207066931/1242503207-ci102l-w1024/Coronavirus-USA.jpg + ${extra_vars} - + - Flow_0qfq760 - Flow_1j21m5x - - + Flow_1nqz9ya + Flow_0rau5wd + + - - - ${section} - + /api/v2/job_templates/${job_template_id}/launch/ + + + ${contextScopeId} + ${execution.getProcessInstanceId()} + ${smardigoManagementAction} + ${cluster.name} + ${cluster.service} + ${cluster.size} + ${cluster.stage} + ${tenant.key} + ${tenant.name} + ${tenant.key} + - Flow_1j21m5x - Flow_1d97y1d + Flow_0jzgu8o + Flow_1nqz9ya @@ -737,55 +746,41 @@ Datenbanken erstellen Flow_1d97y1d Flow_0jzgu8o - + - /api/v2/job_templates/${job_template_id}/launch/ - - - ${contextScopeId} - ${execution.getProcessInstanceId()} - ${smardigoManagementAction} - ${cluster.name} - ${cluster.service} - ${cluster.size} - ${cluster.stage} - ${tenant.key} - ${tenant.name} - ${tenant.key} - + + + ${section} + - Flow_0jzgu8o - Flow_1nqz9ya + Flow_1j21m5x + Flow_1d97y1d - + - + - ${extra_vars} + Neue Aufgabe + ${smardigoManagementAction} + https://img.welt.de/img/vermischtes/bilder-des-tages/mobile207066931/1242503207-ci102l-w1024/Coronavirus-USA.jpg - + - Flow_1nqz9ya - Flow_0rau5wd - - - Flow_0rau5wd - Flow_0gcsmj7 - - - - Flow_0gcsmj7 - Flow_1ju13h8 + Flow_0qfq760 + Flow_1j21m5x + + + Flow_1ow8whd + Flow_0qfq760 - - Flow_1ju13h8 - - + + Flow_1ow8whd + @@ -793,15 +788,26 @@ Datenbanken erstellen - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -1030,26 +1036,6 @@ Datenbanken erstellen - - - - - - - - - - - - - - - - - - - - @@ -1080,48 +1066,6 @@ Datenbanken erstellen - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1270,6 +1214,48 @@ Datenbanken erstellen + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1288,18 +1274,15 @@ Datenbanken erstellen - - - - - - - - - - - - + + + + + + + + + @@ -1327,6 +1310,18 @@ Datenbanken erstellen + + + + + + + + + + + + diff --git a/smardigo/provisioning/script/ansible-start.groovy b/smardigo/provisioning/script/ansible-start.groovy index 638784c..953e81f 100644 --- a/smardigo/provisioning/script/ansible-start.groovy +++ b/smardigo/provisioning/script/ansible-start.groovy @@ -19,6 +19,6 @@ ansibleEnvironment+= '\"' ansibleCommand += ansibleEnvironment processes.byId(contextScopeId, contextProcessId).createComment(comment + ' gestartet') -//processes.byId(contextScopeId, contextProcessId).createComment(ansibleCommand) +processes.byId(contextScopeId, contextProcessId).createComment(ansibleCommand) ansibleCommand \ No newline at end of file