zoukankan      html  css  js  c++  java
  • ansible 主机清单 /etc/ansible/hosts




    主机清单 [webservers] ansible01 ansible02 ansible03 ansible04

      

    [root@ftp:/root]
    > ansible webservers -u root -k -m ping -o 
    SSH password: 
    ansible03 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible01 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible02 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible04 | SUCCESS => {"changed": false, "ping": "pong"}
    
    [root@ftp:/root]
    >
    Ansible Inventory 内置参数

    [root@ftp:/root]
    > ansible webservers -m ping -o 
    ansible01 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible04 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible03 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible02 | SUCCESS => {"changed": false, "ping": "pong"}
    
    
    
    
    
    
    [webservers]
    
    ansible01 ansible_ssh_port='22'
    
    ansible[02:04] 
    
    [webservers:vars]
    ansible_ssh_user='root' 
    ansible_ssh_pass='AAbb0101'
    

      

    分组

    [webservers]
    
    ansible[01:04] 
    
    [apache]
    ansible[01:02]
    
    [nginx]
    ansible[03:04]
    
    [webservers:children]
    apache
    nginx
    
    [webservers:vars]
    ansible_ssh_user='root'
    ansible_ssh_pass='AAbb0101'
    [root@ftp:/root]
    > ansible apache -m ping -o 
    ansible01 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible02 | SUCCESS => {"changed": false, "ping": "pong"}
    
    [root@ftp:/root]
    > ansible nginx -m ping -o 
    ansible03 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible04 | SUCCESS => {"changed": false, "ping": "pong"}

    列出主机清单

    [root@ftp:/root]
    > ansible nginx --list-hosts
      hosts (2):
        ansible03
        ansible04
    
    [root@ftp:/root]
    > ansible apache --list-hosts
      hosts (2):
        ansible01
        ansible02
    
    
    [root@ftp:/root]
    > ansible webservers --list-hosts
      hosts (4):
        ansible01
        ansible02
        ansible03
        ansible04
    
    [root@ftp:/root]
    > 

    自定义指定新的主机清单文件:

    [root@ftp:/]
    > ansible -i /home/docker dockers -m ping -o 
    ansible01 | SUCCESS => {"changed": false, "ping": "pong"}
    ansible02 | SUCCESS => {"changed": false, "ping": "pong"}
    
    [root@ftp:/]
    > cat /home/docker
    [dockers]
    ansible01
    ansible02
    [dockers:vars]
    ansible_ssh_user='root'
    ansible_ssh_pass='AAbb0101'
  • 相关阅读:
    ubuntu查看安装的pytorch/cuda版本
    go不使用工具包将大写字符转成小写字符的方法
    使用Nexus搭建Maven私服
    maven setting.xml配置说明
    maven的仓库、生命周期与插件
    maven项目搭建
    maven之详解继承与聚合
    Maven核心概念之依赖,聚合与继承
    commons-logging日志系统
    新建我的 第一个maven项目
  • 原文地址:https://www.cnblogs.com/liweiming/p/10547539.html
Copyright © 2011-2022 走看看