• Ansible test


    [root@localmesos ansible_test]# ansible all -a "/bin/echo hello"
    192.168.111.111 | SUCCESS | rc=0 >>
    hello

    --------------------------------------------------------------------------------------------------------------------------------

    vi /etc/ansible/hosts

    [webservers]
    192.168.111.111

    [root@localmesos ansible_test]# vi playbook.yml

    ---
    - hosts: webservers
    vars:
    http_port: 80
    max_clients: 200
    remote_user: root
    tasks:
    - name: ensure docker is running (and enable it at boot)
    service: name=docker state=started enabled=yes

    [root@localmesos ansible_test]# ansible-playbook playbook.yml

    PLAY [webservers] ************************************************************************************************************************************************************************

    TASK [Gathering Facts] *******************************************************************************************************************************************************************
    ok: [192.168.111.111]

    TASK [ensure docker is running (and enable it at boot)] **********************************************************************************************************************************
    changed: [192.168.111.111]

    PLAY RECAP *******************************************************************************************************************************************************************************
    192.168.111.111 : ok=2 changed=1 unreachable=0 failed=0

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    [root@localmesos ansible_test]# vi playbook3.yml
    ---
    - hosts: webservers
    vars:
    http_port: 80
    max_clients: 200
    remote_user: root
    tasks:
    - name: add docker container
    add_host:
    name: server
    ansible_connection: docker
    ansible_user: root
    changed_when: false
    - name: create directory for ssh keys
    delegate_to: server
    file:
    path: "/dada"
    state: directory

    ---------------------------------------------------------------------------------

    [root@localmesos ansible_test]# vi playbook3.yml
    ---
    - hosts: webservers
      vars:
        http_port: 80
        max_clients: 200
      remote_user: root
      tasks:


      - name: add docker container
        add_host:
          name: server
          ansible_connection: docker
          ansible_user: root
        changed_when: false


      - name: create directory for ssh keys
        delegate_to: server
        command: rm -rf /test

  • 相关阅读:
    selenium 详解
    验证码破解
    Jupyter Notebook 安装
    分布式
    selenium +scrapy 实现网易新闻
    scrapy 反扒措施_2
    Typora简单使用
    20155215 2016-2017-2 《Java程序设计》第4周学习总结
    20155215 2016-2017-2 《Java程序设计》第3周学习总结
    20155215 2006-2007-2 《Java程序设计》第2周学习总结
  • 原文地址:https://www.cnblogs.com/mhc-fly/p/7082626.html
Copyright © 2020-2023  润新知