1. 配置相关信息:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    ---
    2 - hosts: mync
    3   remote_user: xgj #在远程主机以哪个身份运行
    4   become: true # 是否允许切换身份
    5   become_method: sudo #切换用户身份的方式,有sudo、su、pbrun等方式,默认为sudo
    6   become_user: root #切换成什么用户身份,默认为root
    7   tasks:
    8   - name: download elasticsearch to /var
    9     get_url:
    

10 url: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.1.tar.gz 11 dest: /var/elastic.tar.gz

```
  1. 运行:ansible-playbook install_elasticsearch.yml --ask-become-pass