Ansible is an IT automation tool that brings together many components to specify what exactly needs to be done to the infrastructure. In dynamic environments, such as a cloud-hosted setup, Ansible variables give administrators organization and fine-grained control over host configurations.
The structure of Ansible -- modules, plays, playbooks, variables and facts -- is integral to how IT organizations maintain desired state and scale-up automation. In an Ansible configuration management setup, the control host is the management machine from which tasks execute on managed hosts. The set of instructions in a play defines the tasks to be accomplished, and plays are gathered in a playbook, which is the complete set of instructions to automate hosts. Modules enable tasks scheduled on managed hosts without requiring an administrator to consider every approach necessary to complete the tasks. Managed hosts are listed in the host inventory, and when a playbook is applied, it works on hosts within this inventory.
By organizing the inventory in a smart way, an Ansible administrator can easily decide where to execute specific tasks. It's common to define sections in the inventory file so that the user quickly identifies all hosts, as well as hosts with specific tasks, such as web or database servers. The host inventory can be provided in a static way or can be generated dynamically -- for instance, by using Lightweight Directory Access Protocol. Dynamic host inventory generation makes sense when workloads reside on infrastructure as a service or other frequently changing environments.
Ansible variables organize the rules
Ansible playbooks often manage rapidly changing environments, which makes variables important. Ansible variables allow playbooks to work with static code that is dynamically adapted to specific environments. Instead of including oft-changed values, such as usernames or IP addresses, directly in the playbook, the user refers to external variables.
Ansible variables address a range of scopes. A global variable applies to all managed hosts. Variables with a play scope apply to a play and related structures. The Ansible admin can apply variables to specific hosts as well.
Let a virtualization expert take you through the construction of a playbook and how to set it in motion, all in under 10 minutes.
Because of these layers of scope, the administrator should set an order of precedence for variables. The order of precedence is as-mentioned. If a global variable is specified on the command line while running a playbook, it will always precede the playbook-specific variable. This prioritization convention might seem counterintuitive to some administrators. And it doesn't stop there.
There is an exception to Ansible variable precedence: Variables that are included using the command include_vars take precedence over all others. Many administrators expect the variables specified as a command-line option to come first, and include_vars could create a lot of confusion when structuring an Ansible configuration.
Just the facts
The fact describes a specific type of variable that contains a discovered value about a specific host. The Ansible setup module discovers these values. With facts, Ansible administrators can apply plays only to specific hosts that match a specific value. An overview of all host facts can be generated by running the ansible some.host.com -m setup command against a managed host (some.host.com in this example). Inclusions put variables and facts into playbooks.
Ansible uses Jinja2, a templating language for Python, to apply code to specific hosts. Jinja2 templates modify files before they are distributed to hosts. They make it possible to work with specific control structures that apply code to hosts only after that code is modified.
Beginners sometimes struggle to get insight into the working of Ansible, with so many items interacting with each other. This web of relationships is what makes Ansible such a scalable and powerful configuration management tool. If you are new to Ansible, just start applying playbooks, and once you understand how that really works, seek out more advanced components.
Take a closer look at configuration management options from Puppet
Determine which configuration management tool is best for your organization
The Ansible roadmap is automating its way beyond the DevOps niche
Ansible ni chombo cha automatisering cha IT ambacho kinakusanya vipengele vingi ili kuelezea nini hasa kinahitaji kufanywa kwa miundombinu. Katika mazingira ya nguvu, kama vile kuanzisha cloud-hosted, Ansible vigezo kutoa wasimamizi shirika na udhibiti fine-grained juu ya Configurations mwenyeji. Muundo wa Ansible - modules, michezo, playbooks, vigezo na ukweli - ni sehemu muhimu ya jinsi mashirika ya IT kudumisha hali inayotakiwa na kuongeza automatisering. Katika Ansible Configuration Management kuanzisha, kudhibiti mwenyeji ni usimamizi mashine kutoka ambayo kazi kutekeleza juu ya mwenyeji kusimamiwa. Mfumo wa maelekezo katika mchezo hufafanua kazi zinazopaswa kutimizwa, na michezo hukusanywa katika kitabu cha michezo, ambayo ni seti kamili ya maelekezo ya kuendesha majeshi. Modules kuwezesha kazi iliyopangwa juu ya majeshi kusimamiwa bila kuhitaji msimamizi kuzingatia kila mbinu muhimu ya kukamilisha kazi. Managed majeshi ni waliotajwa katika majeshi hesabu, na wakati playbook ni kutumika, ni kazi juu ya majeshi ndani ya hesabu hii. Kwa kuandaa hesabu kwa njia ya akili, msimamizi wa Ansible anaweza kuamua kwa urahisi ambapo kutekeleza kazi maalum. Ni kawaida kufafanua sehemu katika faili ya hesabu hivyo kwamba mtumiaji haraka inatambua majeshi yote, kama vile majeshi na kazi maalum, kama vile mtandao au seva ya hifadhidata. Mfumo wa mwenyeji unaweza kutolewa kwa njia ya static au inaweza kuzalishwa dynamically - kwa mfano, kwa kutumia Lightweight Directory Access Protocol. Dynamic mwenyeji hesabu kizazi ina maana wakati kazi ya kazi kuishi juu ya miundombinu kama huduma au mazingira mengine mara kwa mara kubadilisha. Ansible vigezo kuandaa sheria Ansible playbooks mara nyingi kusimamia mabadiliko ya haraka mazingira, ambayo inafanya vigezo muhimu. Ansible vigezo kuruhusu playbooks kufanya kazi na kanuni static kwamba ni dynamically ilichukuliwa kwa mazingira maalum. Badala ya kujumuisha maadili ya mara kwa mara kubadilishwa, kama vile majina ya mtumiaji au anwani za IP, moja kwa moja katika kitabu cha kucheza, mtumiaji anataja vigezo vya nje. Ansible vigezo kushughulikia mbalimbali ya scope. Mabadiliko ya kimataifa inatumika kwa majeshi yote kusimamiwa. Variables na mchezo wigo kutumika kwa mchezo na miundo kuhusiana. Ansible msimamizi inaweza kutumia vigezo kwa majeshi maalum pia. Hebu mtaalamu wa virtualization kukuongoza kupitia ujenzi wa kitabu cha kucheza na jinsi ya kuanzisha, wote katika chini ya dakika 10. Kwa sababu ya tabaka hizi za wigo, msimamizi anapaswa kuweka utaratibu wa kipaumbele kwa vigezo. Utaratibu wa kipaumbele ni kama ilivyoelezwa. Kama mabadiliko ya kimataifa ni maalum juu ya mstari wa amri wakati wa kuendesha playbook, itakuwa daima kabla ya mabadiliko ya playbook-maalum. Mkataba huu wa kipaumbele inaweza kuonekana kinyume na intuitive kwa baadhi ya wasimamizi. Na jambo hilo halikomi hapo. Kuna ubaguzi kwa Ansible variable kipaumbele: Variables kwamba ni pamoja na kutumia amri include_vars kuchukua kipaumbele juu ya wengine wote. Wasimamizi wengi kutarajia vigezo maalum kama chaguo amri-line kuja kwanza, na include_vars inaweza kuunda mengi ya kuchanganyikiwa wakati wa muundo Ansible Configuration. Ukweli ni aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina ya aina. Ansible kuanzisha moduli hugundua maadili haya. Kwa ukweli, Wasimamizi wa Ansible wanaweza kutumia michezo tu kwa majeshi maalum ambayo mechi thamani maalum. Mtazamo wa ukweli wote mwenyeji inaweza kuzalishwa kwa kuendesha ansible some.host.com -m kuanzisha amri dhidi ya mwenyeji kusimamiwa (some.host.com katika mfano huu). Kuingiza huweka vigezo na ukweli katika vitabu vya kucheza. Ansible hutumia Jinja2, lugha ya templating kwa Python, kutumia kanuni kwa majeshi maalum. Jinja2 templates ni programu ya kuhariri faili kabla ya kusambazwa kwa majeshi. Wao kufanya iwezekane kufanya kazi na miundo maalum ya kudhibiti ambayo kuomba code kwa majeshi tu baada ya kwamba code ni iliyopita. Wanandoa wakati mwingine hujitahidi kupata ufahamu wa jinsi Ansible inavyofanya kazi, na vitu vingi sana vinavyoingiliana. Mtandao huu wa mahusiano ni nini hufanya Ansible kama scalable na nguvu Configuration Management Tool. Kama wewe ni mpya kwa Ansible, tu kuanza kutumia playbooks, na mara moja wewe kuelewa jinsi kwamba kweli kazi, kutafuta vipengele zaidi ya juu. Kuangalia zaidi ya chaguzi za usimamizi wa usanidi kutoka Puppet Kuamua ambayo chombo cha usimamizi wa usanidi ni bora kwa shirika lako Ramani ya barabara ya Ansible ni automatisering njia yake zaidi ya niche DevOps