zoukankan      html  css  js  c++  java
  • ansible-playbook基础使用(二)

    一、playbook基本格式如下

    [root@linux-node1 ansible]# cat file.yaml 
    ---
      # 主机
    - hosts: date
      # 用户
      remote_user: root
      
      # 任务
      tasks:
        - name: create new_file
          file: name=/data/newfile state=touch
        - name: create new_user
          user: name=test2 system=yes shell=/sbin/nologin
        - name: install package
          yum: name=httpd
        - name: copy html
          copy: src=/data/html.html dest=/data/html.html
        - name: start service
          service: name=httpd state=started enabled=yes

    检查语法

    ansible-playbook -C file.yaml

    没有问题执行

    ansible-playbook  file.yaml
    

     二、ansible-playbook 、ansible通用命令

    [root@linux-node1 ansible]# ansible-playbook file.yaml --list-host
    
    playbook: file.yaml
    
      play #1 (date): date	TAGS: []
        pattern: [u'date']
        hosts (3):
          192.168.56.11
          192.168.56.12
          192.168.56.13
    [root@linux-node1 ansible]# ansible-playbook file.yaml --list-tag
    
    playbook: file.yaml
    
      play #1 (date): date	TAGS: []
          TASK TAGS: []
    

     

  • 相关阅读:
    基础表达式和运算符
    原型链(_proto_) 与原型(prototype) 有啥关系?
    插件模板
    加减plugin
    原生选项卡、手风琴
    前端基础问题(有答案)
    结构图
    Java环境配置小记
    函数
    砝码称重
  • 原文地址:https://www.cnblogs.com/zhaojingyu/p/12115526.html
Copyright © 2011-2022 走看看