zoukankan      html  css  js  c++  java
  • ansible 批量重启服务

    ansible 10.1.1.113 -m service -a 'name=puppet state=restarted enabled=yes'
    
    
        - name: Start MySQL 
    
          service: name=mysqld state=started enabled=yes 
    
      handlers: 
    
        - name: restart mysql 
    
          service: name=mysqld state=restarted
    
    
    
    开启ftp
    
    [root@node01 ansible]# ansible 192.168.137.3 -m service -a'name=vsftpd state=started enabled=yes'
    [DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be 
    removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
    192.168.137.3 | SUCCESS => {
        "changed": true, 
        "enabled": true, 
        "failed": false, 
        "name": "vsftpd", 
        "state": "started"
    }
    
    
    关闭ftp:
    
    [root@node01 ansible]# ansible 192.168.137.3 -m service -a'name=vsftpd state=stopped enabled=yes'
    [DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be removed in version 2.8. Deprecation warnings can be disabled by 
    setting deprecation_warnings=False in ansible.cfg.
    192.168.137.3 | SUCCESS => {
        "changed": true, 
        "enabled": true, 
        "failed": false, 
        "name": "vsftpd", 
        "state": "stopped"
    }
    
    
    
    
    重启服务:
    
    [root@node01 ansible]# ansible 192.168.137.3 -m service -a'name=vsftpd state=restarted enabled=yes'
    [DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be removed in version 2.8. Deprecation warnings can be disabled by 
    setting deprecation_warnings=False in ansible.cfg.
    192.168.137.3 | SUCCESS => {
        "changed": true, 
        "enabled": true, 
        "failed": false, 
        "name": "vsftpd", 
        "state": "started"
    }

  • 相关阅读:
    linux系统性能监控常用命令
    如何在windows的DOS窗口中正常显示中文(UTF-8字符)
    在Windows的CMD中如何设置支持UTF8编码?
    设置cmd的codepage的方法
    Oracle字符集转换
    移动端跨平台开发的深度解析
    类型擦除是抽象泛型的实例化的过程
    FP又称为Monadic Programming
    深入剖析Swift性能优化
    真实世界中的 Swift 性能优化
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349478.html
Copyright © 2011-2022 走看看