zoukankan      html  css  js  c++  java
  • ansible笔记(2)-模块简介

    当我们使用ansible完成某一工作时,需要依赖ansible的各个模块,比如我们ping主机使用的ping模块

    ansible all -m ping
    

    查看模块常用命令:

    1.查看ansible支持的模块:

    [root@myhost ~]# ansible-doc -l | wc -l  #查看支持模块个数
    2834
    

    2.上述命令能够看到各个模块的名称和大致功能(并不详细),想要获得更相信的信息,可用如下命令

    [root@myhost ~]# ansible-doc -s fetch
    - name: Fetch files from remote nodes
      fetch:
          dest:                  # (required) A directory to save the file into. For example, if the `dest' directory is `/backup' a `src' file named `/etc/profile' on host
                                   `host.example.com', would be saved into `/backup/host.example.com/etc/profile'. The host name is based on the
                                   inventory name.
          fail_on_missing:       # When set to `yes', the task will fail if the remote file cannot be read for any reason. Prior to Ansible 2.5, setting this would only fail if the
                                   source file was missing. The default was changed to `yes' in Ansible 2.5.
          flat:                  # Allows you to override the default behavior of appending hostname/path/to/file to the destination. If `dest' ends with '/', it will use the basename
                                   of the source file, similar to the copy module. Obviously this is only handy if the filenames are unique.
          src:                   # (required) The file on the remote system to fetch. This `must' be a file, not a directory. Recursive fetching may be supported in a later release.
          validate_checksum:     # Verify that the source and destination checksums match after the files are fetched.

      从以上信息可以看出fetch模块是用来从远程节点拉取文件的模块,在使用时我们可以加上一些参数

    ansible 192.168.10.60 -m fetch -a "src=/etc/fstab dest=/testdir/ansible/"  
    #在这个命令中-m表示调用什么模块,-a选项用于传递使用fetch模块时需使用的参数,src表示需拉取文件在受管主机的位置,dest表示拉过来存放的位置
  • 相关阅读:
    C# macro function via #define __FILE__ __LINE__ ___FUNCTION__ __DATE__ __TIME__
    3
    2月23号
    3月26
    impala故障
    2月3号日更
    HDFS某个节点的磁盘满了
    3月2
    mq集群
    3月3
  • 原文地址:https://www.cnblogs.com/ltlinux/p/11338457.html
Copyright © 2011-2022 走看看