ansible安装kibana

hosts.ini内容

[kibana]                                                                                                             

#s3 ansible_ssh_host=10.57.34.131                                                                                    

s2 ansible_ssh_host=10.57.30.66                                                                                      

#s1 ansible_ssh_host=10.57.16.44                                                                                     

                                                                                                                     

[all:vars]                                                                                                           

appname = kibana-5.6.8-linux-x86_64.tar.gz                                                                           

appfile = kibana-5.6.8-linux-x86_64                                                                                  

username = tdops                                                                                                     

deploy_dir = /data/kibana                                                                                            

this_dir = /etc/ansible/roles/kibana                                                                                 

version = 5.6.8                                                                                                      

elasticsearch_url = http://10.57.34.131:9200                                                                         

server_port = 5601                                                                                                   

server_host = 0.0.0.0

 

 

注意:  此处的变量  server_port  (在配置文件中为server.port,如果将变量写为server.port运行过程中会报错)

 

deploy.yml内容

# 使用方法 ansible-playbook -i hosts.ini deploy.yml

- hosts: kibana

  tags:

    - kibana

  remote_user: root

  tasks:

    - name: 创建deploy目录

      shell: 'mkdir -p {{ deploy_dir }}'

 

    - name: '上传文件'

      # 将本地文件复制到远程服务器

      copy:                                                                                                          

        src: '{{ item.src }}'                                                                                        

        dest: '{{ item.dest }}'                                                                                      

      with_items:                                                                                                    

        - { src: '{{ this_dir }}/{{ appname }}', dest: '{{ deploy_dir }}/{{ appname }}' }                            

                                                                                                                     

    - name: 解压                                                                                                     

      shell: 'tar -zxvf {{ deploy_dir }}/{{ appname }} -C {{ deploy_dir }}/'                                         

                                                                                                                     

- hosts: kibana                                                                                                      

  tags:                                                                                                              

    - config                                                                                                         

  tasks:                                                                                                             

    - name: 修改配置文件

      lineinfile:

        dest: '{{ deploy_dir }}/{{ appfile }}/config/kibana.yml'                                 #目标文件

        line: '{{ item.key }}: {{ item.value }}'                                                            #指定文本输入内容

        regexp: '^{{ item.key }}.*'                                                                           #正式皮配参数

        state: present

      # 定义集合,并循环执行所在的模块

      with_items:

         - { key: "elasticsearch.url", value: "{{ elasticsearch_url }}" }                         #定义参数名和值

- hosts: kibana                                                                                                       

  tasks:                                                                                                              

    - name: limit for user

      shell: chown -R tdops:tdops {{ deploy_dir }}/{{ appfile }}

    - name: 启动 kibana

      shell: su tdops -c   {{ deploy_dir }}/{{ appfile }}/bin/kibana &.             #此处这样写无法启动。。末解。   

      shell: su tdops -c   {{ deploy_dir }}/{{ appfile }}/bin/kibana > /{{ deploy_dir }}/{{ appfile }}/log&

                                                                                                   29,7         顶端 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值