- name: Add Elasticsearch repository key
  apt_key:
    url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
    id: "46095ACC8548582C1A2699A9D27D666CD88E42B4"
    state: present

- name: Add Elasticsearch repository
  apt_repository:
    repo: "deb https://artifacts.elastic.co/packages/7.x/apt stable main"
    state: present

- name: Update APT
  apt:
    update_cache: yes

- name: Install Elasticsearch
  apt:
    name: elasticsearch=7.17.11