Pib los ntawm kev cog lus thib ob, txhua txoj cai dhau los ua keeb kwm, vim thawj cov tswv yim pib sib txawv ntawm qhov tseeb hnyav. Qhov no tsis yog qhov zoo lossis qhov phem, nws yog ib qho uas nyuaj rau kev sib cav thiab yuav tsum nyob nrog. Ib feem ntawm cov txheej txheem no yog refactoring. Refactoring Infrastructure li Code. Cia zaj dab neeg pib yuav ua li cas refactor Ansible hauv ib xyoos thiab tsis txhob vwm.
Yug Los Ntawm Txoj Cai
Hnub #1: Tus Neeg Mob Zero
Muaj ib zaug muaj ib qhov project uas muaj cai. Nws muaj pab pawg Dev txhim kho thiab Ops engineers. Lawv tau daws qhov teeb meem tib yam: yuav ua li cas xa cov servers thiab khiav daim ntawv thov. Qhov teeb meem yog tias txhua pab neeg daws qhov teeb meem no ntawm nws tus kheej. Ntawm qhov project, nws tau txiav txim siab siv Ansible los synchronize kev paub ntawm pawg Dev thiab Ops.
Hnub #89: Hnub Yug Ntawm Txoj Cai
Yog tsis pom lawv tus kheej, lawv xav ua kom zoo tshaj plaws li qhov ua tau, tab sis nws tau hloov mus ua qub txeeg qub teg. Qhov no tshwm sim li cas?
Peb muaj ib txoj hauj lwm ceev ntawm no, cia peb ua ib tug qias neeg hack thiab ces kho nws.
Koj tsis tas yuav sau cov ntaub ntawv thiab txhua yam yog qhov tseeb tias qhov tshwm sim ntawm no.
Kuv paub Ansible/Python/Bash/Terraform! Saib seb kuv tuaj yeem ua li cas!
Kuv yog Tus Tsim Nyog Tag Nrho Overflow thiab theej qhov no los ntawm stackoverflow, Kuv tsis paub tias nws ua haujlwm li cas, tab sis nws zoo li txias thiab daws qhov teeb meem.
Raws li qhov tshwm sim, koj tuaj yeem tau txais ib qho kev nkag siab tsis zoo ntawm cov cai uas tsis muaj cov ntaub ntawv, nws tsis paub meej tias nws ua dab tsi, txawm tias nws xav tau, tab sis qhov teeb meem yog tias koj yuav tsum tsim kho nws, hloov kho, ntxiv crutches thiab kev txhawb nqa. , ua rau qhov xwm txheej hnyav dua.
Qhov pib xeeb tub thiab ua tiav IaC qauv tsis ua raws li cov kev cai ntawm cov neeg siv / kev lag luam / lwm pab pawg, thiab lub sijhawm los hloov cov kev tsim kho vaj tse yuav tsum tsis kam lees. Lub sijhawm no, kev nkag siab los txog tias nws yog lub sijhawm los nqis tes ua.
IaC refactoring
Hnub #139: Koj puas xav tau refactoring tiag tiag?
Ua ntej koj maj nrawm rau refactor, koj yuav tsum teb ntau cov lus nug tseem ceeb:
Vim li cas koj xav tau tag nrho cov no?
Koj puas muaj sijhawm?
Puas yog kev paub txaus?
Yog tias koj tsis paub yuav ua li cas teb cov lus nug, tom qab ntawd qhov kev rov ua haujlwm yuav xaus ua ntej nws tseem pib, lossis nws tsuas yog mob hnyav dua. Vim muaj kev paub ( Qhov kuv kawm tau los ntawm Kev Xeem 200 Kab ntawm Infrastructure Code), ces qhov project tau txais kev thov kev pab los txhim kho lub luag haujlwm thiab npog lawv nrog kev sim.
Hnub #149: Npaj lub refactoring
Thawj qhov yog npaj. Txiav txim siab seb peb yuav ua li cas. Ua li no, peb sib txuas lus, nrhiav thaj chaw teeb meem thiab nrhiav txoj hauv kev los daws lawv. Peb sau cov ntsiab lus tshwm sim, piv txwv li ib tsab xov xwm hauv kev sib txuas, yog li ntawd thaum lo lus nug tshwm sim "Dab tsi yog qhov zoo tshaj?" los yog "qhov twg yog qhov tseeb?" Peb tsis tau poob peb txoj kev. Hauv peb qhov xwm txheej, peb daig rau lub tswv yim faib thiab kav: peb tawg cov txheej txheem rau hauv me me / cib. Txoj hauv kev no tso cai rau koj los ua ib qho kev sib cais ntawm cov txheej txheem, nkag siab tias nws ua li cas, npog nws nrog kev sim thiab hloov nws yam tsis muaj kev ntshai ntawm kev rhuav tshem dab tsi.
Nws hloov tawm tias kev ntsuam xyuas kev tsim kho vaj tse tau dhau los ua lub hauv paus thiab ntawm no nws tsim nyog hais txog cov txheej txheem kev sim pyramid. Raws nraim tib lub tswv yim uas yog nyob rau hauv txoj kev loj hlob, tab sis rau infrastructure: peb tab tom hloov los ntawm pheej yig ceev kev ntsuam xyuas uas xyuas tej yam yooj yim, xws li indentation, mus rau kim tag nrho-fledged xeem uas deploy tag nrho cov infrastructure.
Kev sim ua kom tiav
Ua ntej peb mus piav qhia yuav ua li cas peb them cov kev xeem Ansible ntawm qhov project, kuv yuav piav qhia txog qhov kev sim thiab cov txheej txheem uas kuv muaj sijhawm los siv ua ntej kom nkag siab txog cov ntsiab lus ntawm kev txiav txim siab.
Hnub No. -997: SDS muab
Thawj zaug kuv sim Ansible yog nyob rau hauv ib qhov project los tsim SDS (Software Defined Storage). Muaj ib tsab xov xwm cais ntawm lub ncauj lus no Yuav ua li cas rhuav cov tsheb kauj vab hla lub crutches thaum kuaj koj qhov kev faib tawm, tab sis nyob rau hauv luv luv, peb xaus nrog ib tug inverted test pyramid thiab kev sim peb siv 60-90 feeb ntawm ib lub luag hauj lwm, uas yog ib tug ntev lub sij hawm. Lub hauv paus yog e2e xeem, i.e. peb deployed ib tug tag nrho-fledged installation thiab ces sim nws. Dab tsi yog qhov hnyav dua yog qhov kev tsim kho ntawm nws tus kheej lub tsheb kauj vab. Tab sis kuv yuav tsum lees, qhov kev daws teeb meem no tau ua haujlwm thiab tso cai rau kev tso tawm ruaj khov.
Feem ntau, cov kev daws tau ua haujlwm, tab sis muaj qee cov sediment vim heterogeneity. Thaum tus naj npawb ntawm cov neeg kuaj tau nce mus rau 13 lub luag haujlwm tseem ceeb thiab 2 lub luag haujlwm meta ua ke nrog cov luag haujlwm me me, tom qab ntawd mam li nco dheev cov kev sim pib khiav rau 70 feeb, uas yuav luag 2 zaug ntev dua. Nws nyuaj rau tham txog XP (kev ua haujlwm siab heev) kev coj ua vim ... tsis muaj leej twg xav tos 70 feeb. Qhov no yog vim li cas thiaj hloov txoj hauv kev
Hnub #-601: Ansible thiab molecule
Conceptually, qhov no zoo ib yam li testkitchen, tsuas yog peb txav lub luag hauj lwm kuaj rau docker thiab hloov pawg. Yog li ntawd, lub sij hawm raug txo kom ruaj khov 20-25 feeb rau 7 lub luag haujlwm.
Los ntawm kev nce tus naj npawb ntawm cov luag haujlwm kuaj rau 17 thiab linting 45 lub luag haujlwm, peb tau khiav qhov no hauv 28 feeb ntawm 2 jenkins qhev.
Hnub #167: Ntxiv Ansible xeem rau qhov project
Feem ntau, nws yuav tsis tuaj yeem ua cov haujlwm refactoring nrawm. Txoj haujlwm yuav tsum ntsuas tau kom koj tuaj yeem tawg mus rau hauv me me thiab noj cov ntxhw ib thooj nrog ib lub teaspoon. Yuav tsum muaj kev nkag siab txog seb koj tab tom txav mus rau qhov raug, mus ntev npaum li cas.
Feem ntau, nws tsis muaj teeb meem li cas nws yuav ua tiav, koj tuaj yeem sau rau ntawm ib daim ntawv, koj tuaj yeem muab cov ntawv nplaum rau ntawm lub txee dai khaub ncaws, koj tuaj yeem tsim cov haujlwm hauv Jira, lossis koj tuaj yeem qhib Google Docs thiab sau cov xwm txheej tam sim no. nyob ntawd. Ob txhais ceg loj hlob los ntawm qhov tseeb tias cov txheej txheem tsis yog tam sim ntawd, nws yuav ntev thiab tedious. Nws tsis zoo li leej twg xav kom koj hlawv tawm ntawm cov tswv yim, nkees, thiab dhau los ua kev ntxhov siab thaum rov kho dua.
Lub refactoring yog yooj yim:
Noj.
Pw tsaug zog.
Cai.
IaC test.
Rov ua dua
thiab peb rov ua qhov no kom txog thaum peb mus txog lub hom phiaj npaj.
Tej zaum nws yuav tsis tuaj yeem pib sim txhua yam tam sim ntawd, yog li peb thawj txoj haujlwm yog pib nrog linting thiab xyuas cov syntax.
Hnub #181: Green Build Master
Linting yog thawj kauj ruam me me rau Green Build Master. Qhov no yuav tsis tawg yuav luag txhua yam, tab sis nws yuav tso cai rau koj los daws cov txheej txheem thiab ua kom ntsuab tsim hauv Jenkins. Lub tswv yim yog los txhim kho tus cwj pwm ntawm pab neeg:
Kev kuaj liab tsis zoo.
Kuv tuaj kho ib yam dab tsi thiab tib lub sij hawm ua tus cai me ntsis zoo dua nws ua ntej koj.
Hnub #193: Los ntawm linting mus rau chav kuaj
Tau tsim cov txheej txheem kom tau txais cov cai rau hauv tus tswv, koj tuaj yeem pib cov txheej txheem ntawm kev txhim kho ib ntus - hloov linting nrog lub luag haujlwm launching, koj tuaj yeem ua nws yam tsis muaj idempotency. Koj yuav tsum nkag siab tias yuav siv lub luag haujlwm thiab lawv ua haujlwm li cas.
Hnub #211: Los ntawm chav tsev mus rau kev xeem sib koom ua ke
Thaum feem ntau lub luag haujlwm tau them nrog cov kev xeem hauv chav tsev thiab txhua yam yog linted, koj tuaj yeem txav mus ntxiv rau kev sib xyaw ua ke. Cov. kev sim tsis yog ib lub cib nyob rau hauv lub infrastructure, tab sis ib tug ua ke ntawm lawv, piv txwv li, tag nrho cov piv txwv configuration.
Siv jenkins, peb tsim ntau theem uas linted lub luag hauj lwm / playbooks nyob rau hauv parallel, ces chav kuaj nyob rau hauv cov thawv, thiab thaum kawg kev sib koom ua ke xeem.
ZOO: Nyob rau hauv lub luag hauj lwm rau cov variables, siv variables prefixed nrog lub luag hauj lwm lub npe; qhov no, los ntawm saib cov khoom muag, yuav ua rau nws yooj yim to taub dab tsi tshwm sim.
Peb tau pom zoo siv cov lus ua ntej sib txawv; nws yuav tsis yog superfluous los xyuas tias lawv tau txhais raws li peb xav tau thiab, piv txwv li, tsis overridden los ntawm tus nqi khoob.
ZOO: Txheeb xyuas qhov sib txawv.
- name: "Verify that required string variables are defined"
assert:
that: ahs_var is defined and ahs_var | length > 0 and ahs_var != None
fail_msg: "{{ ahs_var }} needs to be set for the role to work "
success_msg: "Required variables {{ ahs_var }} is defined"
loop_control:
loop_var: ahs_var
with_items:
- ahs_item1
- ahs_item2
- ahs_item3
Tsis txhob hashes dictionaries, siv cov qauv tiaj tus
Yog tias lub luag haujlwm xav kom muaj hash / phau ntawv txhais lus nyob rau hauv ib qho ntawm nws qhov tsis, ces yog tias peb xav hloov ib qho ntawm cov menyuam tsis muaj, peb yuav tsum tau hla tag nrho cov lus hash / phau ntawv txhais lus, uas yuav ua rau kom muaj kev sib txawv.