zoukankan      html  css  js  c++  java
  • Ansible 简单上手

    Ansible 有很多专业的配置,但是如下简单几步就可以让你先玩起来了 ~_~

    安装:

    # yum install ansible
    

    服务器免密认证:

    如果对方直接有 authorized_keys 文件,则直接添加 key 内容 。
    # ssh root@192.168.1.101 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
    
    如果对方机器没有,就要先建立 .ssh 目录及 authorized_keys 文件,然后再添加 key 内容 。
    # ssh root@192.168.1.101 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
    

    增加群组:

    # vim /etc/ansible/hosts
    [test]
    172.168.1.101
    172.168.1.102
    172.168.1.103
    172.168.1.104
    172.168.1.105
    172.168.1.106
    

    PING:

    # ansible "test" -m ping
    

    执行命令:

    # ansible "test" -m shell -a "ls -l /usr/local/src/"
    

    启动服务:(started/stopped/restarted)

    # ansible "172.16.1.101" -m service -a "name=zabbix-agent state=started"
    

    拷贝文件:

    # ansible "test" -m copy -a "src=/usr/local/src/ansible_test.txt dest=/usr/local/src/ansible_test.txt"
    

    查看机器信息:

    # ansible "test" -m setup
    

    [ TO BE CONTINUE ]

  • 相关阅读:
    第06组 Beta冲刺 总结
    第06组 Beta冲刺 (5/5)
    第06组 Beta冲刺 (4/5)
    第06组 Beta冲刺 (3/5)
    第06组 Beta冲刺 (2/5)
    第06组 Beta冲刺 (1/5)
    第06组 alpha冲刺 总结
    第06组 Alpha冲刺 (6/6)
    数据采集第四次作业
    第06组(67)团队展示
  • 原文地址:https://www.cnblogs.com/configure/p/14837491.html
Copyright © 2011-2022 走看看