美文网首页运维日常
playbook使用when语句实现elk部署

playbook使用when语句实现elk部署

作者: 大白菜的猪猪 | 来源:发表于2020-04-11 12:32 被阅读0次

---

- hosts: elk

  tasks:

    - name: yum install java

      yum:

        name: java-1.8.0-openjdk

        state: installed

    - name: install the elasticsearch

      yum:

        name: elasticsearch

        state: installed

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'cluster.name:'

        line: 'cluster.name: myelk'

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'network.host:'

        line: 'network.host: 0.0.0.0'

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'discovery.zen.ping.unicast.hosts:'

        line: 'discovery.zen.ping.unicast.hosts: ["byes1","byes2","byes3"]'

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'node.name: '

        line: 'node.name: byes1'

      when: ansible_hostname == "byes1"

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'node.name: '

        line: 'node.name: byes2'

      when: ansible_hostname == "byes2"

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'node.name: '

        line: 'node.name: byes3'

      when: ansible_hostname == "byes3"

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'node.name: '

        line: 'node.name: byes4'

      when: ansible_hostname == "byes4"

    - lineinfile:

        path: /etc/elasticsearch/elasticsearch.yml

        regexp: 'node.name: '

        line: 'node.name: byes5'

      when: ansible_hostname == "byes5"

    - service:

        name: elasticsearch

        state: restarted

        enabled: yes

相关文章

网友评论

    本文标题:playbook使用when语句实现elk部署

    本文链接:https://www.haomeiwen.com/subject/behymhtx.html