diff --git a/elk_metrics_7x/roles/elastic_repositories/defaults/main.yml b/elk_metrics_7x/roles/elastic_repositories/defaults/main.yml index aaf44ae2..829c0d00 100644 --- a/elk_metrics_7x/roles/elastic_repositories/defaults/main.yml +++ b/elk_metrics_7x/roles/elastic_repositories/defaults/main.yml @@ -23,4 +23,9 @@ elastic_repo_distro_packages: [] # elastic_apt_repo: # repo: 'deb https://artifacts.elastic.co/packages/7.x/apt stable main' # state: "{{ ((elk_package_state | default('present')) == 'absent') | ternary('absent', 'present') }}" -# key_url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch" + +# This should be a list of dicts, with each dict +# giving a set of arguments to the applicable +# package module. Defaults to the remote url +# https://artifacts.elastic.co/GPG-KEY-elasticsearch +elastic_gpg_keys: "{{ _elastic_gpg_keys | default([]) }}" diff --git a/elk_metrics_7x/roles/elastic_repositories/files/gpg/46095ACC8548582C1A2699A9D27D666CD88E42B4 b/elk_metrics_7x/roles/elastic_repositories/files/gpg/46095ACC8548582C1A2699A9D27D666CD88E42B4 new file mode 100644 index 00000000..1b50dcca --- /dev/null +++ b/elk_metrics_7x/roles/elastic_repositories/files/gpg/46095ACC8548582C1A2699A9D27D666CD88E42B4 @@ -0,0 +1,31 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v2.0.14 (GNU/Linux) + +mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBD +A+bGFOwyhbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9 +CUliQe324qvObU2QRtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZ +j3SF1SPO+TB5QrHkrQHBsmX+Jda6d4Ylt8/t6CvMwgQNlrlzIO9WT+YN6zS+sqHd +1YK/aY5qhoLNhp9G/HxhcSVCkLq8SStj1ZZ1S9juBPoXV1ZWNbxFNGwOh/NYGldD +2kmBf3YgCqeLzHahsAEpvA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NVDmedwo1SiL03uMoblOvWpMR/Y0j +6rm7IgrMWUDXDPvoPGjMl2q1iTeyHkMZEyUJ8SKsaHh4jV9wp9KmC8C+9CwMukL7 +vM5w8cgvJoAwsp3Fn59AxWthN3XJYcnMfStkIuWgR7U2r+a210W6vnUxU4oN0PmM +cursYPyeV0NX/KQeUeNMwGTFB6QHS/anRaGQewijkrYYoTNtfllxIu9XYmiBERQ/ +qPDlGRlOgVTd9xUfHFkzB52c70E= +=92oX +-----END PGP PUBLIC KEY BLOCK----- diff --git a/elk_metrics_7x/roles/elastic_repositories/tasks/elastic_apt_repos.yml b/elk_metrics_7x/roles/elastic_repositories/tasks/elastic_apt_repos.yml index b46376bb..f046e638 100644 --- a/elk_metrics_7x/roles/elastic_repositories/tasks/elastic_apt_repos.yml +++ b/elk_metrics_7x/roles/elastic_repositories/tasks/elastic_apt_repos.yml @@ -13,13 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: add Elastic search public GPG key - apt_key: - url: "{{ elastic_repo.key_url }}" - state: "present" - register: _apt_task - until: _apt_task is success - retries: 3 +- name: If a keyfile is provided, copy the gpg keyfile to the key location + copy: + src: "gpg/{{ item.id }}" + dest: "{{ item.file }}" + mode: '0644' + with_items: "{{ elastic_gpg_keys | selectattr('file','defined') | list }}" + +- name: Install Elastic gpg keys + apt_key: "{{ key }}" + with_items: "{{ elastic_gpg_keys }}" + loop_control: + loop_var: key + register: _add_apt_keys + until: _add_apt_keys is success + retries: 5 delay: 2 tags: - package_install diff --git a/elk_metrics_7x/roles/elastic_repositories/vars/ubuntu.yml b/elk_metrics_7x/roles/elastic_repositories/vars/ubuntu.yml index 2542fecd..7130b424 100644 --- a/elk_metrics_7x/roles/elastic_repositories/vars/ubuntu.yml +++ b/elk_metrics_7x/roles/elastic_repositories/vars/ubuntu.yml @@ -20,6 +20,9 @@ elastic_repo_distro_packages: _elastic_repo: repo: 'deb https://artifacts.elastic.co/packages/7.x/apt stable main' state: "{{ ((elk_package_state | default('present')) == 'absent') | ternary('absent', 'present') }}" - key_url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch" elastic_repo: "{{ elastic_apt_repo | default(_elastic_repo) }}" + +_elastic_gpg_keys: + - id: 46095ACC8548582C1A2699A9D27D666CD88E42B4 + file: /etc/ssl/elastic-key