zoukankan      html  css  js  c++  java
  • playbook详解—YAML格式的文本

    在playbook中有一些核心的指令

    hosts:指明命令运行在哪个node之上 
    remote_user:在远端的node之上以什么用户的身份运行命令 
    var:给模板传递变量值 
    tasks:指明需要执行的命令 
    template:指明模板文件 
    handler:指明句柄所在文件目录名 
    Roles:指明需要运行的角色名

    (一)检查playbook是否正确

    ansible-playbook --syntax-check first.yml

    (二)预执行playbook

    ansible-playbook --check first.yml

    (三)查看执行命令的node节点的IP地址或主机名

    ansible-playbook --list-hosts first.yml
    first.yml
     
    - hosts: webservers
    remote_user: root
    tasks:
    - name: install httpd
    yum: name=httpd state=latest
    - name: distribute config file
    copy: src=config/httpd.conf dest=/etc/httpd/conf/httpd.conf
    tags: redistibute
    notify: restart httpd
    - name: start httpd
    service: name=httpd state=started enabled=yes
    - name: check httpd started
    shell: netstat -lntup | grep 80
     
     
    handlers:
    - name: restart httpd
    service: name=httpd state=restarted enabled=yes

    (四)使用vars定义变量

    - hosts: dbservers
    remote_user: root
    vars:
    - username: home
    - groupname: uplooking
    tasks:
    - name: add group
    group: name={{ groupname }}
    - name: add user
    user: name={{ username }} state=present
  • 相关阅读:
    jQuery插件实现简单的圆角
    提高网页效率的14条准则
    jQuery插件sdmenu导航插件
    Using MVC Pattern in Web Interactions
    jQuery插件源代码显示.(Ajax加载方式).
    jQuery插件jLook(表单美化)
    jQuery关于 序列化
    jQueryblockUIV2翻译.
    cssimagemap
    jQuerySlide menu
  • 原文地址:https://www.cnblogs.com/liu1026/p/7639720.html
Copyright © 2011-2022 走看看