<address id="bztp3"><nobr id="bztp3"></nobr></address>

      <sub id="bztp3"><listing id="bztp3"><menuitem id="bztp3"></menuitem></listing></sub>

        <form id="bztp3"></form>

        <address id="bztp3"></address>
        <sub id="bztp3"></sub>

          <form id="bztp3"></form>

              Linux基礎教程之ansible進階(roles應用)

              ansible 進階

              一、roles簡介

              一個項目從開始到結束,不是簡單幾十個playbook就可以完事了,當文件數很多,有上百個的話,僅通過簡單的includes不停的引用,那最終的結果錯綜復雜。這個時候ansible roles就可以很好的發揮它的作用了。

              roles,字面意思是角色的含義,可以理解為有相互關聯功能的集合。我們把安裝ntp、mem、nginx、db等等的功能角色放在一個大倉庫里,然后用到哪個,從那里面去拿,拿一個,拿兩個都可以。

              roles:是個目錄,角色集合

              里面放的有:
              
              ????mysql/
              ????httpd/
              ????nginx/
              ????memcached/
              每個角色是一個目錄
              
              每個角色的格式,一特定的層級目錄結構進行組織,如下:
              
              mysql/
              ????files/
              ????templates/
              ????tasks/
              ????handlers/
              ????vars/
              ????meta/
              用到哪個目錄,給出哪個目錄

              二、在playbook中調用角色的方式

              -?hosts:?webservers
              ??remote_user:?root
              ??roles:
              ??-?mysql
              ??-?memcached
              ??-?nginx

              三、以mysql/為例,分別介紹各個目錄的意思

              (1)files/:存放copy或script模塊等調用的文件

              (2)templates/:templates查找所需要模塊文件的目錄;

              (3)tasks/:(必須要有)至少應該包含一個名為main.yml的文件,其他的文件需要在此文件中通過include進行包含;

              (4)handlers/:至少應該包含一個名為main.yml的文件,其他的文件需要在此文件中通過include進行包含;

              (5)vars/:定義的是變量,至少應該包含一個名為main.yml的文件,其他的文件需要在此文件中通過include進行包含;

              (6)meta/:定義此當前角色的特殊設定及其他依賴關系,至少應該包含一個名為main.yml的文件,其他的文件需要在此文件中通過include進行包含;

              (7)default/:為當前角色設定默認變量時使用目錄中的main.yml文件

              四、例子

              (1)mkdir /etc/ansible/roles/nginx{files,tasks,templates,handlers,vars,default,meta} -pv

              (2)tree /etc/ansible/roles/nginx

              (3)cd /etc/ansible/roles/nginx/

              (4)vim tasks/main.yml

              (5)cp /root/working/files/nginx.conf.j2 templates/

              (6)調用,去working目錄下,建立一個ansible文件夾,cd到里面去,然后vim nginx.yml

              (7)運行結果

              五、其他配置添加

              1、定義觸發器

              (1)cd /etc/ansible/roles/nginx 放在handlers目錄下:vim handlers/main.yml

              (2)vim tasks/main.yml

              (3)ansible-playbook –check nginx.yml

              定義tags,直接在tasks/main.yml上加上tags: instconf就可以了

              2、自定義變量的使用

              (1)cd working/ ,vim myuser.yml

              (2)ansible-playbook myuser.yml

              (3)再那兩臺機子上看一下:

              3、調用roles的第二種方法:傳遞變量給角色

              mkdir?-pv?/etc/ansible/roles/memcached/tasks
              cd?/memcached
              vim?tasks/main.yml
              
              -?name:?install?package
              ??yum:?name=memcached?state=present
              -?name:?start?memcached
              ??service:?name=memcached?state=started?enabled=true
              
              調用:vim?lnm.yml
              -?hosts:?all
              ??remote_user:
              ??roles:
              ??-?{?role:nginx,?when:ansible_distribution_major_version?==?'7'?}
              ??-?{?role:memcached,?when:ansible_hostname?==?'memcached'?}
              
              
              ansible-playbook?--check?lnm.yml

              大致先寫到這,ansible是門龐大的課程,未完待續。

              相關新聞

              聯系我們

              400-080-6560

              在線咨詢:點擊這里給我發消息

              郵件:work@magedu.com

              工作時間:周一至周日,09:00-18:30

              QR code
              656彩票平台656彩票主页656彩票网站656彩票官网656彩票娱乐 www.67797k.com | www.pjzhejiang.com | www.717228.com | www.3412277.com | 2649g.com | www.38345f.com | 4167q.com | www.90305b.com | www.js736736.com | 9566362.com | www.5966vvv.com | 461653.com | www.0343s.com | 88807m.com | www.500227.com | www.hg7857.com | tc88.com | www.076wy.com | www.aomen8866.com | 67890dd.com | www.86339u.com | 2373x.com | www.560672.com | www.988300.com | 8668827.com | www.60007c.com | www.363788.com | 7335t.com | www.6939n.com | www.70088hg.com | vip2127.com | www.4058mm.com | 30174444.com | www.99638i.com | www.57800e.com | bdg1100.com | www.567206.com | www.jy959.com | 3522f.cc | www.77210e.com | www.3066gg.com | x87.com | 8881779.com | www.47506n.com | 0080i.com | 4379l.com | www.47506e.com | 3136ee.com | 9649y.com | www.9895.com | 1274kc.com | 7792o.com | www.0600q.cc | www.yh4444.cc | 075tt.com | www.50051g.com | www.hg8375.com | 8159w.cc | 8722.am | www.flb906.com | www.28758q.com | 9149l.com | www.35155h.com | www.815333.com | 53262ww.com | www.770816.com | www.hh635.com | 365qxw.am | www.50064v.com | www.99552gg.com | 80892yy.com | 179.com | www.53536.cc | www.2945a.com | w88zhan.com | www.32123v.com | www.ca8077.com | www.22751.com | 44ii8331.com | www.770816.com | www.26123gg.com | www.033033a.com | j7736.com | www.5578w.com | www.56655r.com | 500000431.com | 80060202.com | www.6769b.com | www.70389.com | t2306.com | 0747bb.com | www.62355.com | www.1168f.com | 0747ll.com | 179.com | www.6fa500.com | www.ktmrocks.com | www.hg9952.com | a62365.com | www.998484.com | www.8884hj.com | www.111xpj22.com | 4022m.com | www.80075o.com | www.2418l.com | www.358vns.com | 28487000.com | mmm5682.com | www.220755.com | drcp666.com | 6403v.com | www.854242.com | www.40288k.com | www.hg246.com | sss5682.com | 452922.com | www.786819.com | www.ls22.vip | www.fc596.com | www.e26055.vip | 7508j.com | www.96386i.com | www.66376f.com | www.818999.com | www.yinhe9507c.com | 1463j.com | www.621416.com | www.984709.com | www.129786.com | www.6033l.com | ff7742.com | www.055983.com | www.73166h.com | www.8516.com | www.aaa6199.com | 88888448.com | 4995q.com | www.026079.com | www.80075z.com | www.4136w.com | www.43677.com | 56988v.com | 55331aa.com | jsok258.com | www.065wy.com | www.xpj53516.com | www.79500v.com | www.3643b.com | 2jsttt.com | 70118u.com | 3678jj.com | www.936250.com | www.0802.cc | www.829797b.com | www.hg6929.com | www.bg999222.com | 365vip700.cc | 88905050.com | 1489.com | 89777s.com | www.938906.com | www.26243.com | www.l69096.com | www.822834.com | www.63877i.com | 0245u.com | 69445555.com | 73055h.com | js58123.com | www.818897.com | www.2373c.com | www.530079.com | www.v1186.com | www.0805e.com | www.js60g.com | 17500.cn | 888365.com | 83377r.com | 22885144.com | 97799u.com | www.342977.com | www.990733.com | www.66332d.com | www.065825.com | www.3577.ag | www.88166b.com | www.pj7608.com | www.swj68.com | www.77788806.com | www.cp2y.com | 4255mm.com | 61326611.com | xpj5007.com | js8068.com | 4508ll.com | i32365.com | 1389zz.com | 8520f.com | 17yy.com | ooo3405.com | 22117o.com | www.009275.com | www.371931.com | www.620477.com | www.976731.com | www.igcp6.com | www.9478l.com | www.60108w.com | www.sx139971.com | www.js338.cn | www.37377v.com | www.pj9050.com | www.pj55712.com | www.7783066.com | www.dingxin598.com | www.2208598.com | www.1851117.com | www.4996lz.com | www.696668.com | www.bwinyz29.com | www.38138o.com | www.bet63j.com | www.3983201.com | www.8080999b.com | www.p2894.com | www.491977.com | www.91779.com | www.2021r.com | www.491977.com | www.2544g8.com | www.77786yh.com | www.751828.com | www.00797b.com | www.ribo80.cc | www.16065d.com | www.83993b.com | www.3933j.cc | www.806726.com | www.394689.com | www.022184.com | n00351.com | 7742kk.com | 32126l.net | 52688s.com | 2383hh.com | 66332007.com | 3258s.com | 61652r.com | www.kf5656.com | www.828685.com | www.567000.com | www.353560.com | www.ag0345.com | www.598282c.com | www.80844.com | www.9149h.com | www.684344.com | www.80075o.com | 6699734.com | bet35365.com | 3890s.com | 0080x.com | www.657suncity.com | www.117390.com | www.333980.com | www.9737xx.com | www.v2662.com | www.68689f.com | www.777768a.com | www.211873.com | 9539t.com | 8901q.com | 9339999y.com | www.65533b.com | www.k0678.com | www.232060.com | www.8c333.com | www.83033m.com | www.901576.com | 19990aa.com | 3404e.cc | w5050w.com | www.1333zx.com | www.xpj269.com | www.bwinyz31.com | www.7714h.com | www.976381.com | ylg12.com | 6645365.com | 11pp8331.com | www.m1862.com | www.613177.com | www.v1058.com | www.622by.com | www.095069.com | 33318v.com | 8869emc.com | www.881215.com | www.198hg.com | www.984701.com | www.975961.com | 6150h.com | 2383.com | 1466j.com | www.fbs333.com | www.38775vv.com | www.2875w.com | jxdebon.cn | 3333744.com | 5589a.com | www.xh4499.com | www.99552bb.com | www.yi648.com | hg999333t.com | 561633.com | www.0686777.com | www.3171114.com | www.win1236.com | www.538950.com | 1389u.com | 2677ttt.com | www.6707555.com | www.60886u.com | www.ck5578.com | 38244x.com | dadicp.com | www.kc19.com | js66661.com | 23800i.com | www.350698.com | www.u94600.com | www.544096.com | 00555004.com | www.0686222.com | www.c44jj.com | www.66653x.com | 2078x.com | 2324ttt.com | www.2846f.com | www.06820i.com | www.fc78.com | 4107b.com | www.1869q.com | www.rgcp444.com | www.52005.cc | 38238d.com | 6830dd.com | www.666629.com | www.bet73q.com | bet009900.com | 2211buyu.com | www.501333.com | www.0601e.com | 0033l.cc | lixingyoulun.cc | www.sb5542.com | www.60108r.com | 99567z.com | 9949o.com | www.3846v.com | www.8499c.com | 2222k11.com | 66005156.com | www.89677i.com | www.740707.com | 33qq8332.com | www.9679900.com | www.288sb.21.sb | qjdy037.com | g7742.com | www.996sun.com | www.5086n.com | x8519.com | www.ylg268.com | www.2021g.com | www.225863.com | 8381x.com | www.6882f.com | www.6364c.com | 6878.am | www.2090900.com | www.36456.com | 0241h.com | 996622jj.com | www.695044.com | www.355911.com | 2757q.com | www.3211msc.com | www.bai355.com | hggjtg11.com | www.9949r.com | www.66653j.com | 28824c.com | www.3643y.com | www.954321x.com | 1294y.com | www.3xinhao.com | www.6678698.com | 123456hh.cc | www.pj6522.com | www.393968.com | 57157f.com | www.88365.net | www.6939h.com | 00tt8332.com | www.j2367.com | www.80065g.com | 3258v.com | www.v99950.com | www.20995.cc | 38365i.com | www.54mscc.com | www.730625.com | 7508e.com | www.472701.com | www.132031.com | 33115cc.com | www.xpj7707.com | 2127vv.com | www.21365bb.com | www.52072z.com | pj3508.com | www.yh98mm.com | www.368200.com | 228888g.com | www.883399h.com | 1594003.com | www.32666i.com | www.31330.cc | 3522f.vip | www.x80288.com | kb5454.com | www.7025y.com | www.2632z.com | 908080i.com | www.b35kk.com | 7920.com | www.msc99.la | www.ch8234.com | 7720b.net | www.88000xpj.com | 01234d.com | www.773388.com | www.599487.com | 131xx.net | www.68993278.com | 779644.com | www.5099jj.com | 50128.vip | www.pj8188.com | www.919709.com | 2373j.com | www.16065r.com | u21148.com | www.5981y.com | x5816.com | www.hg2516.com | www.302591.com | www.8134.cc | www.2934k.com | ying58.xyz | www.hg1125.com | 55797m.com | www.16k0048.com | ribo25.cc | www.d22255.com | 2127ss.com | www.4445156.com | www.658960.com | www.6248j.com | www.8816g.com | 3189kk.com | www.rfdc04.com | 4156.com | www.111158.com | 51133v.com | www.730016.com | 170160.com | www.8473j.com | 1697766.com | www.d5680.com | 6999009.com | www.jjjj44444.com | www.370257.com | 3078v.com | www.tai111.com | 3024h.com | www.ra7088.com | 123456xx.cc | www.hg8449.com | 9895m.com | www.021700.com | 1483p.com | www.209558.com | 6245g.com | www.hjcp4.com | xpj238803.com | www.cp009x.com | 44339193.com | www.64566e.com | 61999.com | www.aaa06.cc | kxmapp555.com | www.87668t.com | 55899i.com | www.2350z.com | 5517.com | www.504638.com | www.54549944.com | youfa99.vip | www.5858564.com | 3667yh.com | www.bwinyz42.com | 100404.com | www.6678698.com | xhtd3559.com | www.ptk3.com | www.7380m.com | www.43131q.com | 5906hh.com | www.t69096.com | 82365a.com | www.ra017.com | 626844app.com | www.895010.com | www.www5151msc.com | x5505.com | www.304081.com | ww38648.cc | www.ggr.99233r.com | 4270ee.com | www.55238f.com | xpj29977.com | www.503477.com | www.gf949888.com | 55229193.com | www.1764l.com | hg91778.com | www.01hfcp.com | www.amh008.com | xhgx2.com | www.758567a.com | bet577n.com | www.810872.com | www.6032888.com | 00778b.com | www.7249p.com | feicai0352.com | www.357165.com | www.005mgm.com | 39990011.com | www.33588q.com | www.yh201422.vip | 47749q.com | www.377666m.com | 6150s.com | www.592411.com | www.003113.com | 69443322.com | www.99048.cc | www.6tgpd.com | hg2808dd.com | www.97828d.vip | 9002.com | deerdz.com | www.biying950vip.com | 86811r.com | www.607356.com | www.228778b.com | 22098m.com | www.zhang258.com | www.9005b.com | xinu222.com | www.23579.cc | www.pp224.cc | t8009.com | www.9155a.com | www.888zr61.com | bbs500.com | www.26878y.com | www.ylg29.com | 99995309.com | www.9478b.com | www.f88yule9.com | csj750.com | www.513.vip | www.218003.com | 2214z.com | www.844689.com | www.998855l.com | 00774ff.com | www.498166.com | www.pj88r.com | 97q.com | baifucp11.com | www.vnsr398.com | www.033033m.com | hg168o.com | www.959595.biz | www.3668722.com | 64111b.com | www.43818.cc | www.34kj.com | 2jsyyy.com | www.349677.com | www.068526.com | www.6033k.com | 1654nn.com | www.61655z.com | www.66333666.com | 839555.com | www.368518.com | www.87708e.com | www.cr508.com | 7347999.com | www.5854t.cc | www.4699f.com | 3136oo.com | 3556.com | www.78949h.com | www.49799.com | 00774ff.com | 390626.com | www.7758.com | www.0241mmm.com | 4060pp.com | www.310295.com | www.837292.com | www.56520r.com | 37111w.com | www.482770.com | www.99552.com | www.k27229.com | 32555t.com | www.318016.com | www.12345606.cc | www.44112055.com | 435797.com | so.com | www.32365.Com | www.1112p.com | 2267m.com | 8030f.com | www.1035a.com | www.4694s.com | www.hg8004.com | pu0012.com | www.364877.com | www.48330x.com | www.hg7211m.com | dz1666.com | 0033f.cc | www.771219.com | www.07679b.com | www.5599pj.com | 28839y.com | 32355nn.com | www.am6633.com | www.209752.com | www.9679n.com | 8722ssss.com | 353458.com | www.cai002.vip | www.63606f.com | www.bb8005.com | 8290t.com | 38238y.com | www.412228.com | www.954321i.com | www.98923.com | www.10071007.com | 9506n.com | 44488i.com | www.901758.com | www.xingji01.com | www.hg0817.com | www.1869u.com | 4488i.com | 8894vip2.com | www.902776.com | www.62778811.com | www.998855s.com | www.bet3650814.com | 22uu8332.com | n7454.com | www.325477.com | www.80075l.com | www.673888s.com | www.4270nn.com | 888p1.cc | 9068c.com | 2237pay.com | www.693930.com | www.750877.com | www.7415m.com | www.387411.com | 3024p.com | 7240c.com | 5005s.com | www.210793.com | www.9149m.com | www.yl8553hb.com | www.063262.com | www.9996dd.com | 2643j.com | 3404h.cc | pj8dd.com | x7742.com | www.969751.com | www.0003sc.com | www.bb673888.com | www.00166b.com | www.7669c.net | 88807g.com | 3590.com | 118888k.com | 28288uu.com | www.695093.com | www.50989k.com | www.0099psb.com | www.caipiao88e.com | www.xpj1511.com | www.7720m.com | 76543y.com | 5888.ch | sxpj62579.com | 2443h.com | www.98528i.com | www.bxcp66.com | www.33997z.com | www.4561.am | www.35252d.com | www.55526r.com | www.62007.com | www.h7788y.com | 2998z.com | 500000419.com | dc1104.com | xpjxianlu.com | beiyong.bet | jsjlb33.com | xianboba.com | www.312102.com | www.900248.com | www.3416s.com | www.96386t.com | www.zzw555.com | www.88325l.com | www.4972w.com | www.9611msc.com | www.hg8870.com | www.3844qq.com | www.hg3569.com | www.pu1678.com | 66775002.com | 33511.com | jsh7777.com | 123bocai.com | dzhcp2.com | hga22200.com | bh889933.com | 5019kzc.com | spj08.com | 563460.com | v2894.com | youfa222.vip | 1466z.com | P35s.com | 9964.one | 3078n.com | 5856dd.com | 923910.com | 2649g.com | hg993.cc | 3775w.com | 914903.com | g3405.com | 33313q.com | 5906hh.com | 3232394.com | qq365l.com | 0698.com | 7003dd.com | 7766881.com | 667766xcom | 116060.com | 73055w.com | 4465c.com | 3640x.com | 0015zz.com | 25228.am | zhcpbb.com | 2820i.com | 6hcc66.com | www.a3a555.cc | www.9999wns.com | www.56520s.com | www.7111i.com | www.js7444.com | www.44488.cc | www.9560gg.com | www.mhcp2.com | www.00772j.com | www.3066qq.com | www.86730.com | www.4833043.com | www.3301855.com | www.60123m.com | www.3136aa.com | www.899465.com | www.444160.com | 074a7.com | 11989c.com | 131s.net | 11665003.com | 9646q.com | qy457.com | 034408.com | www.11aicai.com | www.7025s.com | www.84303.com | www.77731f.com | www.8800ra8.com | www.12345606.cc | www.c773776.com | www.2632q.com | www.645411.com | www.35155a.com | 6245k.com | a2848.com | vip4048.com | www.4727088.com | www.2805.com | www.73990e.com | www.js02348.com | www.00665c.com | www.773618.com | 9168b.com | 2466.com | 5350l.com | 3413222.com | www.129494.com | www.071093.com | www.yf230.com | www.280770.com | www.66653g.com | www.808482.com | 1147.com | 4022rr.com | 33382x.com | js910.com | www.ra8804.com | www.30305.com | www.11475.com | www.9478o.com | www.355711.com | 9995z.cc | 3482a.com | 8827ggg.com | www.v15528.com | www.hf9019.com | www.86339u.com | www.37676.cc | www.167686.com | x0066.tv | 8037a.com | www.6806pj.com | www.76568.com | www.91779n.com | www.52072j.com | www.357173.com | xpj677u.com | 3566jj.com | www.86611f.com | www.889029.com | www.xj6003.com | www.25688h.com | www.129029.com | 550111t.com | 3661yh.com | www.7025t.com | www.k3065.com | www.90wb.top | www.598799.com | 80031122.com | 00773cc.com | www.41414688.com | www.79500v.com | www.386123.com | www.616330.com | 2851t.com | 20054477.com | www.hg375.com | www.bwinyz28.com | www.26163t.com | df8o.com | 4022gg.com | www.bjd333.com | www.suncity758.com | www.332333.cc | www.566385.com | 28824x.com | 228888m.com | www.814c.com | www.cb700.cc | www.560723.com | 1775h.com | 3089p.com | www.msc555.com | www.ihg5588.com | www.389044.com | 624815.com | 7335s.com | www.c44vv.com | www.80767s.com | 11422n.com | 3656nn.com | www.87680z.com | www.hgdc600.com | www.aa3126.com | 66119vip.com | 1077oo.com | www.ns1122.com | www.78700c.com | hb61788.com | 76886p.com | www.3844a.com | www.97828o.vip | www.296180.com | dzj224.com | www.4625m.com | www.478378.com | www.770816.com | 61828.me | www.399801.com | www.8800ra8.com | www.934277.com | 13377.com | www.555xin2.com | www.88166h.com | www.hx6611.com | bojue02.com | www.89422.com | www.1851113.com | www.796786.com | xpj62904.com | www.0679555.com | www.vnsr378.com | www.356686.com | 32212t.com | www.5626l.com | www.954321s.com | alpk66.com | feicai0415.com | www.799666v.com | www.033.la | 3656ss.com | www.hj200766.com | www.78680q.com | www.87668e.com | l8381.com | www.12706.com | www.3890v.com | yun889.com | www.77077.com | www.xpj66123.com | www.53900e.com | df8x.com | www.dcyyh.com | www.sxyl9.com | 2459c.com | www.330099x.com | www.68993225.com | 5002d.com | 22296ae.com | www.4521z.com | www.025938.com | 76886t.com | www.99113v.com | www.622989.com | 5856ppp.com | www.hg4089.com | www.58ipo.com | 69441133.com | www.hg6299.com | www.9155e.com | 44p88.cc | www.143vns.com | www.26878n.com | 1306766.com | www.29069.com | P35tt.com | www.y8859.com | v93902.com | 1064f.com | www.56011q.com | 9411aaa.com | www.am22222.com | www.42842816.com | 9420v.com | www.39695g.com | www.8d838.com | 1705l.com | www.71366x.com | www.8816g.com | 19880v.com | www.hg7743.com | www.911283.com | 2096y.com | www.88166j.com | www.025738.com | 3416f.com | www.0088hg.com | blm385.com | www.777444m.com | www.33997r.com | 66112007.com | www.hg8907.com | www.586974.com | 131sss.net | www.3824.com | 28288nn.com | www.7893w01.com | www.50088c.com | ctxcpyh.com | www.28mscc.com | www.330271.com | vv3189.com | www.78919d.com | 1211.cc | www.js541.com | www.672766.com | 3844am.com | www.78680z.com | 40666111.com | www.015456.com | www.915696.com | 00773vv.com | www.5446c.com | 996622cc.com | www.66050.com | www.540877.com | 3146.com | www.js02348.com | 4116p.com | www.c44.com | 339649.com | www.hg77716.com | www.5441h.com | 55855.com | www.6683066.com | 1116076.com | www.4646123.com | www.301871.com | www.yh77706.com | www.80075m.com | 3846bbb.com | www.4058nn.com | 9599wm6.com | www.50tyc.com | www.260929.com | www.k88883.com | www.50024y.com | pjzxyL.cc | www.69567h.com | dd44d.net | www.jxcp4444.com | 2418r.com | www.lfg222.com | www.783090.com | 48283333.com | www.61524s.com | 86811jj.com | www.479.com | 856789.com | www.88.net | r8381.com | www.938h.cc | 861052.com | www.28249.com |