ansible 示例

ansible-doc  文档帮助命令  
ansible-doc -l  查看有哪些模块
ansible-doc MOD 查看每个模块的文档

推荐一个 很好的修改文件内容的模块  lineinfile


1、通过ansible安装salt
#/etc/ansible/salt.yml

 - name: install salt-minion
   hosts: init_salt
   user: root
   #sudo: yes
   #sudo_user: root
   roles:
     - salt-minion
  
#/etc/ansible/roles 
 salt-minion/
├── handlers
│   └── main.yml
  - name: restart salt-minion
     service: name=salt-minion state=restarted
        
├── tasks
│   └── main.yml
  - name: salt.repo sync
   sudo: yes
   copy: src=/etc/yum.repos.d/saltstack.repo dest=/etc/yum.repos.d/saltstack.repo
 - name: python update
   sudo: yes
   yum: name=python state=latest
 - name: yum install salt-minion
   sudo: yes
   yum: name=salt-minion state=installed
 - name: copy salt-minion configuration
   sudo: yes
   template: src=minion dest=/etc/salt/minion
   notify:
      - restart salt-minion       
└── templates
    └── minion      

##################################################################

2 批量创建日志目录
#/etc/ansible/mk_log_dir.yml
 - name: init pay-serv env
   hosts: new-pay-serv
   user: root
   #sudo: yes
   #sudo_user: root
   roles:
     - pay_env_init
#/etc/ansible/roles 
pay_env_init/
├── handlers
│   └── main.yml
├── tasks
│   └── main.yml
 - name: add  users
   user: name={{item.name}} state=present
   with_items:
   - {name: 'webuser'}
   - {name: 'search'}
   - {name: 'tuanbuydev'}
 - name: create dir
   file: state=directory recurse=yes path=/var/log/java/{{item.dir}} owner={{item.owner}}
   with_items:
    - {dir: 'cashier-bill', owner: 'webuser'}
    - {dir: 'coupon-manage', owner: 'webuser'}
    - {dir: 'coupon-server', owner: 'webuser'}
    - {dir: 'pay-server', owner: 'webuser'}
    - {dir: 'pay-serverfkaRefund', owner: 'webuser'}
    - {dir: 'pay-serverfkaTransferLog', owner: 'webuser'}
    - {dir: 'search', owner: 'search'}
    - {dir: 'supervisor', owner: 'root'}
    - {dir: 'tuanbuy', owner: 'webuser'}
    - {dir: 'tuanbuy-pub-api', owner: 'webuser'}
    - {dir: 'tuanbuy-pub-manage', owner: 'webuser'}
    - {dir: 'tuan-pay-api', owner: 'webuser'}
    - {dir: 'tuan-pay-manage', owner: 'webuser'}
    - {dir: 'webuser', owner: 'webuser'}
    - {dir: 'zhebuy-api', owner: 'webuser'}
    - {dir: 'zhebuy-manage', owner: 'webuser'}
    - {dir: 'zhebuy-opt-server', owner: 'webuser'}
    - {dir: 'zhebuy-task', owner: 'webuser'}
    - {dir: 'zhepay-pos', owner: 'webuser'}
    - {dir: 'zhepay-payway', owner: 'webuser'}
 - name: rsync hosts
   template: src=hosts dest=/etc/hosts
└── templates
    └── hosts
######################################################
3、node 环境初始化、node项目安装
#/etc/ansible/node_env_init.yml
 - name: node_env_init
   hosts: pina_pre
   user: root       # ssh as with root
   sudo: yes        # sudo on 
   sudo_user: webuser #sudo user
   roles:
     - node_env_init
#/etc/ansible/roles/node_env_init
node_env_init/
├── handlers
│   └── main.yml
├── tasks
│   └── main.yml
 - name: install depention rpms
   yum: name={{item.name}} state=installed
   with_items:
   - {name: 'cairo'}
   - {name: 'cairo-devel'}
   - {name: 'cairomm-devel'}
   - {name: 'libjpeg-turbo-devel'}
   - {name: 'pango'}
   - {name: 'pango-devel'}
   - {name: 'pangomm'}
   - {name: 'pangomm-devel'}
   - {name: 'giflib-devel'}
 - name: useradd
   user: name=webuser state=present generate_ssh_key=yes
 - name: sync git keys
   copy: src={{item}} dest=/home/webuser/.ssh/ mode=0600 owner=webuser group=webuser
   with_fileglob:
   - /root/keys/*
 - name: maker dir
   file: path={{item.dir}} owner=webuser group=webuser state=directory recurse=yes
   with_items:
   - {dir: '/var/www/ued'}
   - {dir: '/var/www/node'}
   - {dir: '/var/www/sites/'}
   - {dir: '/home/webuser'}
 - name: wget node-v0.12.7
   get_url: dest=/root/ force=yes url=https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz 
 - name: install node
   shell: tar xf /root/node-v0.12.7.tar.gz -C /root/ && cd /root/node-v0.12.7 && ./configure && make && make install
 - name: npm install pm2
   npm: name=pm2@0.14.3  global=yes  registry=http://npm.tuan800-inc.com
 - name: git clone
   sudo: yes
   git : repo={{item.giturl}} dest={{item.dir}} update=yes accept_hostkey=yes   #key_file=/home/webuser/.ssh/update 
   with_items:
#   - {giturl: 'git@tuan800:trade_ued/serv_pin.git' ,dir: '/var/www/sites/serv_pin/'}
   - {giturl: 'git@tuan800:trade_ued/serv_p8.git' ,dir: '/var/www/sites/serv_p8/serv_p8'}
   #- {giturl: 'git@git.tuan800-inc.com:trade_ued/serv_pin.git' ,dir: '/var/www/node/'}
   register: test
 - debug: var=test
 - name: npm i based on package.json
   sudo: yes
   npm: path={{item.dir}}/package.json global=no registry=http://npm.tuan800-inc.com
   with_items:
   - {dir: '/var/www/sites/serv_p8/serv_p8'}
#   - {dir: '/var/www/sites/serv_pin/serv_pin'}

└── templates

###########################################################################

Pingbacks已打开。

引用地址

评论
  1. JackGal JackGal 发布于 2021年1月23日 02:09 #

    <a href="https://avanapill.com/">dapoxetine brand name</a> <a href="https://ventolinmed.com/">albuterol 0.08</a> <a href="https://zyloprimallopurinol.com/">allopurinol uk buy</a> <a href="https://lexaprossri.com/">cipralex coupons</a> <a href="https://ozzpharmacy.com/">online pharmacy without scripts</a> <a href="https://viagra10x.com/">viagra online usa pharmacy</a> <a href="https://chloroquinelab.com/">aloquin</a> <a href="https://wherecialis.com/">canada cialis generic</a>

  2. JackGal JackGal 发布于 2021年1月23日 04:11 #

    <a href="https://bactrimtabs.com/">generic for bactrim</a> <a href="https://arimidexanastrozole.com/">buying arimidex mexico</a> <a href="https://levitravardena.com/">generic levitra 40mg</a> <a href="https://buytretinoinretina.com/">50 retin a cream</a> <a href="https://inderalpropranolol.com/">inderal 10 mg price in india</a> <a href="https://zoviraxaciclovir.com/">acyclovir pills online order</a> <a href="https://zithromaxazithromycin24.com/">azithromycin 250 mg tablet price in india</a> <a href="https://viagravpro.com/">sildenafil cost us</a>

  3. AmyGal AmyGal 发布于 2021年1月23日 05:01 #

    <a href="http://levitrart.com/">generic levitra free shipping</a>

  4. JimGal JimGal 发布于 2021年1月23日 05:12 #

    <a href="https://buytretinoinretina.com/">where to buy retin a tretinoin</a> <a href="https://azithromycinzithromax.com/">buying zithromax online</a>

  5. MiaGal MiaGal 发布于 2021年1月23日 05:58 #

    <a href="https://levitrart.com/">best price on levitra</a> <a href="https://hicialis.com/">buy tadalafil 20mg price</a> <a href="https://viagramn.com/">5 viagra</a> <a href="https://citamoxifen.com/">nolvadex pharmacy</a> <a href="https://cialistore.com/">36 hour cialis</a>

  6. JaneGal JaneGal 发布于 2021年1月23日 06:10 #

    <a href="https://chloroquinelab.com/">chloroquine cost uk</a>

  7. JackGal JackGal 发布于 2021年1月23日 06:53 #

    <a href="https://metformindrug.com/">glucophage xr 500</a> <a href="https://celebrexnsaid.com/">celebrex 200mg tablets</a> <a href="https://lexaprossri.com/">lexapro 5mg cost</a> <a href="https://viagrasildenafilotc.com/">where can i buy viagra online in india</a> <a href="https://metforminsale.com/">glucophage pills</a> <a href="https://wellbutrinbupropionpill.com/">wellbutrin 1000 mg</a> <a href="https://viagrasr.com/">viagra 100 coupon</a> <a href="https://elitadalafil.com/">best price for cialis</a>

  8. JoeGal JoeGal 发布于 2021年1月23日 07:13 #

    <a href="https://zithromaxazithromycin24.com/">azithromycin canadian pharmacy to us</a> <a href="https://trazodonesari.com/">trazodone 450 mg</a> <a href="https://tadalafilxl.com/">how to get cialis prescription</a>

  9. JimGal JimGal 发布于 2021年1月23日 07:49 #

    <a href="https://synthroidlevo.com/">purchase synthroid</a> <a href="https://quetiapineseroquel.com/">how much is seroquel cost</a> <a href="https://buyazithromycinzithromax.com/">how much is zithromax 500mg</a> <a href="https://tadalafilxl.com/">cheap cialis uk</a> <a href="https://cialisdrug.com/">online pharmacy cialis</a> <a href="https://finasteridepropecia.com/">propecia prescription cost uk</a> <a href="https://bactrimtabs.com/">bactrim tablets 400mg 80mg</a> <a href="https://wherecialis.com/">brand cialis 20 mg</a>

  10. NickGal NickGal 发布于 2021年1月23日 07:49 #

    <a href="http://finasteridepropecia.com/">propecia malaysia</a> <a href="http://amoxicillindrug.com/">augmentin 875 price</a> <a href="http://lyricamedication.com/">medicine lyrica 75 mg</a> <a href="http://zithromaxazithromycin24.com/">azithromycin price canada</a> <a href="http://ventolinmed.com/">buy albuterol no prescription</a> <a href="http://hicialis.com/">cialis medicine</a> <a href="http://levothyroxinesynthroid.com/">canadian price for synthroid</a> <a href="http://quetiapineseroquel.com/">seroquel epocrates</a>

  11. SamGal SamGal 发布于 2021年1月23日 08:55 #

    <a href="http://elitadalafil.com/">buy tadalafil from india</a> <a href="http://fildenasildenafil.com/">buying viagra</a> <a href="http://diflucanfluconazol.com/">diflucan 1</a> <a href="http://finasteridepropecia.com/">finpecia tablet</a> <a href="http://levitravardena.com/">levitra 3000mg</a> <a href="http://metforminsale.com/">canadian pharmacy metformin</a>

  12. EvaGal EvaGal 发布于 2021年1月23日 12:15 #

    <a href="http://levitrart.com/">levitra soft pills</a>

  13. A Payday Loan A Payday Loan 发布于 2021年1月23日 14:47 #

    <a href="http://urglending.com/">payday loans no fax</a> <a href="http://usploans.com/">cash advance</a>

  14. EvaGal EvaGal 发布于 2021年1月23日 15:24 #

    <a href="http://levitrart.com/">buy levitra generic online</a>

  15. IvyGal IvyGal 发布于 2021年1月23日 15:33 #

    <a href="https://citamoxifen.com/">tamoxifen pill</a> <a href="https://synthroidlevo.com/">buy synthroid online canada</a> <a href="https://opcialis.com/">cialis pharmacy coupon</a> <a href="https://diflucanfluconazol.com/">diflucan 150 mg tabs</a> <a href="https://lasixfurosemidepill.com/">furosemide 20 mg coupon</a> <a href="https://arimidexanastrozole.com/">arimidex cost in india</a> <a href="https://lasixfurosemidemed.com/">can you buy furosemide over the counter</a> <a href="https://zyloprimallopurinol.com/">allopurinol singapore</a> <a href="https://ataraxhydroxyzine.com/">atarax 10mg tablet price</a> <a href="https://wherecialis.com/">where to buy tadalafil online</a> <a href="https://upsildenafil.com/">best price generic viagra online</a> <a href="https://ozzpharmacy.com/">online pharmacy india</a> <a href="https://finasteridefinpecia.com/">online propecia canada</a> <a href="https://viagrasupp.com/">can you buy generic viagra in canada</a> <a href="https://celexacitaloprampill.com/">brand name celexa 40 mg</a>

  16. JackGal JackGal 发布于 2021年1月23日 18:16 #

    <a href="https://viagramn.com/">cheap generic viagra 100mg</a> <a href="https://bactrimtabs.com/">para que sirve el bactrim</a> <a href="https://amoxicillindrug.com/">amoxil pill</a> <a href="https://indocindrug.com/">indocin medication</a> <a href="https://zithromaxazithromycin24.com/">azithromycin 9 pills</a> <a href="https://phenerganpromethazine.com/">buy phenergan medicine</a>

  17. JaneGal JaneGal 发布于 2021年1月23日 19:23 #

    <a href="https://tetracyclineonline.com/">tetracycline 500mg price</a>

  18. NickGal NickGal 发布于 2021年1月23日 19:36 #

    <a href="http://milpharmacy.com/">onlinepharmaciescanada com</a> <a href="http://hydrochlorothiazidepill.com/">buy hydrochlorothiazide 12.5 mg</a> <a href="http://wherecialis.com/">cialis 120</a> <a href="http://ventolinmed.com/">combivent cost price</a> <a href="http://chloroquinelab.com/">hydroxychloroquine 25 mg</a> <a href="http://hicialis.com/">cheapest cialis</a> <a href="http://metformindrug.com/">metformin 500 mg price uk</a>

  19. SueGal SueGal 发布于 2021年1月23日 20:06 #

    <a href="https://prednisoloneprednisone.com/">prednisolone 5mg tablet price in india</a> <a href="https://atenololtenormin.com/">where to buy atenolol</a> <a href="https://zyloprimallopurinol.com/">allopurinol uk prescription</a> <a href="https://tetracyclinepill.com/">tetracycline antibiotic</a> <a href="https://ventolinmed.com/">albuterol 4mg</a> <a href="https://azithromycinzithromax.com/">zithromax tablets price</a> <a href="https://cialistore.com/">cheap cialis from canada</a> <a href="https://propeciaafinasteride.com/">cheap propecia india</a> <a href="https://doxycyclinerem.com/">doxy</a> <a href="https://amoxicillindrug.com/">augmentin 875 mg tab</a>

  20. EvaGal EvaGal 发布于 2021年1月23日 20:29 #

    <a href="http://metformindrug.com/">metformin 500 mg without prescription</a>

发表评论