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

Commit

Permalink
Fix deb/redhat
Browse files Browse the repository at this point in the history
Signed-off-by: Timur Gadiev <Timur_Gadiev@epam.com>
  • Loading branch information
tgadiev committed Nov 16, 2019
1 parent 57d5b1b commit f9f6b26
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 24 deletions.
4 changes: 2 additions & 2 deletions tasks/beats-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

- name: Check pid_dir status
stat:
path: '{{beats_pid_dir}}'
path: '{{ beats_pid_dir }}'
register: pid_stat

- name: Create PID Directory
Expand Down Expand Up @@ -53,7 +53,7 @@
- name: Copy Configuration File for {{ beat }}
template:
src: beat.yml.j2
dest: '{{conf_file}}'
dest: '{{ conf_file }}'
mode: 0644
force: true
owner: root
Expand Down
21 changes: 16 additions & 5 deletions tasks/beats-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
cache_valid_time: 86400
when: use_repository | bool
register: beat_install
until: beat_install is succeeded
notify: restart {{ beat }}

- name: Debian - Ensure python-urllib3, python-openssl, python-pyasn1 & python-pip are installed
Expand All @@ -17,6 +18,8 @@
- python-pyasn1
- python-pip
state: present
register: libs_install
until: libs_install is succeeded
when:
- use_repository | bool
- ansible_distribution_release == "trusty"
Expand All @@ -25,6 +28,8 @@
pip:
name: ndg-httpsclient
state: present
register: ndg_install
until: ndg_install is succeeded
when:
- use_repository | bool
- ansible_distribution_release == "trusty"
Expand All @@ -33,12 +38,16 @@
apt_key:
url: '{{ elastic_repo_key }}'
state: present
register: apt_key_install
until: apt_key_install is succeeded
when: use_repository | bool

- name: Debian - add beats repository
apt_repository:
repo: 'deb {{ repo_url }} stable main'
state: present
register: repo_install
until: repo_install is succeeded
when: use_repository | bool

- name: Debian - unhold {{ beat }} version for install
Expand All @@ -48,9 +57,11 @@
- name: Debian - Ensure {{ beat }} is installed
apt:
name: >-
{{ beat }}{% if beats_version is defined and beats_version != "" %}={{ beats_version }}{% endif %}
{{ beat }}{% if beats_version is defined and beats_version|length>0 %}={{ beats_version }}{% endif %}
state: present
cache_valid_time: 86400
register: beat_install
until: beat_install is succeeded
when: use_repository | bool
notify: restart {{ beat }}

Expand All @@ -62,19 +73,19 @@
- name: Set os_arch
set_fact:
os_arch: >-
{{ ansible_architecture == 'x86_64' | ternary("amd64", "i386") }}
{{ ansible_architecture == 'x86_64' | ternary('amd64', 'i386') }}
- name: Debian - Download {{ beat }} from url
get_url:
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'
else %}{{ beats_package_url }}/{{ beat }}/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb{% endif %}
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
apt:
deb: '/tmp/{{ beat }}_{{ beats_version }}_{{os_arch}}.deb'
deb: '/tmp/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb'
when: not use_repository | bool
notify: restart {{ beat }}
45 changes: 28 additions & 17 deletions tasks/beats-redhat.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
---

- name: Ensure libselinux-python on CentOS 6.x
yum: name=libselinux-python state=present update_cache=yes
when: ( ansible_distribution == "CentOS" ) and ( ansible_distribution_major_version == "6" )
yum:
name: libselinux-python
state: present
update_cache: true
register: libselinux_install
until: libselinux_install is succeeded
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version == "6"

- name: Redhat - add beats repository
template: src=beats.repo.j2 dest=/etc/yum.repos.d/beats.repo
template:
src: beats.repo.j2
dest: /etc/yum.repos.d/beats.repo
when: use_repository

- name: RedHat - install yum-version-lock
yum: name=yum-plugin-versionlock state=present update_cache=yes
yum:
name: yum-plugin-versionlock
state: present
update_cache: true

- name: RedHat - unlock {{beat}} for install
shell: yum versionlock delete {{beat}} || true
changed_when: False
- name: RedHat - unlock {{ beat }} for install
shell: yum versionlock delete {{ beat }} || true
changed_when: false

- name: RedHat - Ensure {{beat}} is installed
- name: RedHat - Ensure {{ beat }} is installed
yum:
name: >-
{{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %}
{{ beat }}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %}
state: present
update_cache: true
when: use_repository
notify: restart {{beat}}
notify: restart {{ beat }}

- name: RedHat - lock {{beat}} version
- name: RedHat - lock {{ beat }} version
shell: >-
yum versionlock add
{{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %}
{{ beat }}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %}
when: version_lock
changed_when: False
changed_when: false

- name: RedHat - Install {{beat}} from url
- name: RedHat - Install {{ beat }} from url
yum:
name: >-
{% if custom_package_url is defined %}{{ custom_package_url }}{%
else %}{{ beats_package_url }}/{{beat}}-{{ beats_version }}-{{ansible_architecture}}.rpm{% endif %}
else %}{{ beats_package_url }}/{{ beat }}-{{ beats_version }}-{{ ansible_architecture }}.rpm{% endif %}
state: present
when: not use_repository
notify: restart {{beat}}
notify: restart {{ beat }}

0 comments on commit f9f6b26

Please sign in to comment.