zoukankan      html  css  js  c++  java
  • Ansible系列(一):安装

    Ansible系列(一):基本配置和使用

    Ansible是一个批量、自动化部署工具。它基于ssh通信,因此被控制主机不需要安装客户端。
    基于python实现,由paramiko、pyyaml、jinjia2三个关键模块组成。


    安装ansible

    安装方式有多种,yum安装最简单。
    ansible位于epel库,使用阿里云的库。
    [root@ansible-server ~]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
    [root@ansible-server ~]# sed 's#http#https#g' /etc/yum.repos.d/epel.repo -i
    [root@ansible-server ~]# yum clean all
    [root@ansible-server ~]# yum install ansible -y

    ansible版本
    [root@ansible-server ~]# ansible --version
    ansible 2.6.3
    config file = /etc/ansible/ansible.cfg
    configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
    ansible python module location = /usr/lib/python2.7/site-packages/ansible
    executable location = /usr/bin/ansible
    python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

    ansible文档帮助工具
    [root@ansible-server ~]# ansible-doc -h
    Usage: ansible-doc [-l|-F|-s] [options] [-t ] [plugin]

    plugin documentation tool

    Options:
    -a, --all For internal testing only Show documentation for
    all plugins.
    -h, --help show this help message and exit
    -j, --json For internal testing only Dump json metadata for
    all plugins.
    -l, --list List available plugins
    -F, --list_files Show plugin names and their source files without
    summaries (implies --list)
    -M MODULE_PATH, --module-path=MODULE_PATH
    prepend colon-separated path(s) to module library
    (default=[u'/root/.ansible/plugins/modules',
    u'/usr/share/ansible/plugins/modules'])
    -s, --snippet Show playbook snippet for specified plugin(s)
    -t TYPE, --type=TYPE Choose which plugin type (defaults to "module")
    -v, --verbose verbose mode (-vvv for more, -vvvv to enable
    connection debugging)
    --version show program's version number and exit

    查找模块名
    [root@ansible-server ~]# ansible-doc -h|grep command

    使用"-s"选项可以获取指定模块的使用帮助。例如,获取yum模块的使用语法。
    [root@ansible-server ~]# ansible-doc -s yum

    例如使用yum安装wget包。
    [root@ansible-server ~]# ansible 10.0.0.71 -m yum -a "name=wget"
    使用ansible在10.0.0.71安装wget,"-m"表示指定模块名称,"-a"用于指定模块参数,例如name和state等。

  • 相关阅读:
    用DECODE进行排序
    linux下批量替换文件内容
    Linux下chkconfig命令详解
    linux 命令参数列表过长以及find用法
    参数上使用自定义注解在aop中无法获取到该参数
    AOP
    AOP aspect XML 配置
    AOP前世与今生,aspect
    ETL工具之——kettle使用简介
    ETL工具之kittle使用案例整理
  • 原文地址:https://www.cnblogs.com/iwalkman/p/9665330.html
Copyright © 2011-2022 走看看