[root@saltstack-master logstash-update]# cat logstash-update.sls

/data/lk-logstash/new-conf.d:

  file.directory:

    - user: work

    - group: work

    - dir_mode: 755

    - file_mode: 755

    - makedirs: True


default-file-update:

  file.recurse:

    - name: /data/lk-logstash/new-conf.d/

    - source: salt://logstash-update/files/new-conf.d

    - include_empty: True

    - clean: True

    - user: work

    - group: work

    - dir_mode: 755

    - file_mode: 644

    - recurse:

      - user

      - group

      - mode


logstash-service:             #将文件中的内容复制到目标目录中

  file.recurse:

    - name: /etc/service/lk-logstash-sys_secure/

    - source: salt://logstash-update/files/logstash-service/

    - include_empty: True

    - clean: True

    - user: work

    - group: work

    - dir_mode: 755

    - file_mode: 644

    - recurse:

      - user

      - group

      - mode

  cmd.run:

    - name: cd /etc/service/lk-logstash-sys_secure &&  chmod 755 log/run log/config run


motify-service-run:

  cmd.run:

    - name:  sed -i '/chpst/s#$#&file_kafka_sys_secure.yml#g' /etc/service/lk-logstash-sys_secure/run

    - require:

      - file: logstash-service


{% if grains['os'] == 'CentOS' %}

motify:

  cmd.run:

    - name: chmod o+r /var/log/messages /var/log/secure

{% elif grains['os'] == 'Ubuntu' %}

motify:

  cmd.run:

    - name: chmod o+r /var/log/syslog /var/log/auth.log

{% endif %}



update-logstash:

  cmd.run:

    - name: cd /etc/service && sleep 3 && sv restart lk-logstash-sys_secure