Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Fix unhold issue with custom deb packages #146

Merged
merged 5 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ galaxy_info:
company: "Elastic.co"
issue_tracker_url: https://github.com/elastic/ansible-beats/issues
license: "license (Apache)"
min_ansible_version: 2.0
min_ansible_version: 2.5
platforms:
- name: EL
versions:
Expand Down
22 changes: 15 additions & 7 deletions tasks/beats-debian.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Debian - Ensure apt-transport-https is installed
become: yes
apt:
Expand Down Expand Up @@ -40,7 +39,7 @@
- name: Debian - Add Beats repository key
become: yes
apt_key:
url: '{{ elastic_repo_key }}'
url: "{{ elastic_repo_key }}"
state: present
register: apt_key_install
until: apt_key_install is succeeded
Expand All @@ -49,15 +48,22 @@
- name: Debian - add beats repository
become: yes
apt_repository:
repo: 'deb {{ repo_url }} stable main'
repo: "deb {{ repo_url }} stable main"
state: present
register: repo_install
until: repo_install is succeeded
when: beats_add_repository | bool

- name: Debian - Check if {{ beat }} package is installed
package_facts:
manager: apt

- name: Debian - unhold {{ beat }} version for install
become: yes
command: apt-mark unhold {{ beat }}
dpkg_selections:
name: "{{ beat }}"
selection: "install"
when: beat in ansible_facts.packages
changed_when: false

- name: Debian - Ensure {{ beat }} is installed
Expand All @@ -74,7 +80,9 @@

- name: Debian - hold {{ beat }} version
become: yes
command: apt-mark hold {{ beat }}
dpkg_selections:
name: "{{ beat }}"
selection: "hold"
when: version_lock
changed_when: false

Expand All @@ -88,13 +96,13 @@
url: >-
{% if custom_package_url is defined %}{{ custom_package_url }}{%
else %}{{ beats_package_url }}/{{ beat }}/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb{% endif %}
dest: '/tmp/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb'
dest: "/tmp/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb"
validate_certs: false
when: not use_repository | bool

- name: Debian - Ensure {{ beat }} is installed from downloaded package
become: yes
apt:
deb: '/tmp/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb'
deb: "/tmp/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb"
when: not use_repository | bool
notify: restart the service