---
- name: elasticsearch installed
  community.general.pkgng:
    name: "elasticsearch7"
    state: latest

- name: Elasticearch enabled
  shell: sysrc elasticsearch_enable="YES"

- name: ElasticSearch config file installed
  copy:
    src: elasticsearch.yml
    dest: /usr/local/etc/elasticsearch/elasticsearch.yml
    owner: root
    mode: 0644
  notify: Elasticsearch restarted

- name: Elasticsearch started
  service: name=elasticsearch state=started
