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

Commit

Permalink
Fix some lint issues
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 17fc38e commit 57d5b1b
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 56 deletions.
8 changes: 4 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---

allow_duplicates: yes

allow_duplicates: true
dependencies: []
galaxy_info:
role_name: beats
author: Dale McDiarmid
description: Beats for Linux
company: "Elastic.co"
issue_tracker_url: https://github.com/elastic/ansible-beats/issues
license: "license (Apache)"
min_ansible_version: 2.0
platforms:
Expand All @@ -20,7 +20,7 @@ galaxy_info:
- name: Ubuntu
versions:
- all
categories:
galaxy_tags:
- beats
- elastic
- elk
Expand Down
56 changes: 38 additions & 18 deletions tasks/beats-config.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
---
# Configure Beats Node

- set_fact: pid_file={{ beats_pid_dir }}/{{beat}}.pid
- set_fact: instance_default_file={{ default_file }}/{{beat}}
- set_fact: conf_file={{ beats_conf_dir }}/{{beat}}.yml

- set_fact:
- name: Set default facts
set_fact:
pid_file: '{{ beats_pid_dir }}/{{ beat }}.pid'
instance_default_file: '{{ default_file }}/{{ beat }}'
conf_file: '{{ beats_conf_dir }}/{{ beat }}.yml'
beat_output_conf:
output: "{{ output_conf }}"
output: '{{ output_conf }}'

- set_fact:
- name: Set beat_shipper_conf
set_fact:
beat_shipper_conf:
shipper: "{{ shipper_conf }}"
shipper: '{{ shipper_conf }}'
when: shipper_conf is defined

- set_fact:
- name: Set beat_logging_conf
set_fact:
beat_logging_conf:
logging: "{{ logging_conf }}"
logging: '{{ logging_conf }}'

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

- name: Create PID Directory
file: path={{ beats_pid_dir }} state=directory
file:
path: '{{ beats_pid_dir }}'
state: directory
when: pid_stat.stat.isdir is not defined or pid_stat.stat.islnk is not defined

#fail if pid and config directories are not links or not directories i.e files

- name: Create Config Directory
file: path={{ beats_conf_dir }} state=directory
file:
path: '{{ beats_conf_dir }}'
state: directory

#Copy the default file
- name: Copy Default File for Instance
template: src=beat.j2 dest={{instance_default_file}} mode=0644 force=yes owner=root group=root
notify: restart {{beat}}
template:
src: beat.j2
dest: '{{ instance_default_file }}'
mode: 0644
force: true
owner: root
group: root
notify: restart {{ beat }}

#Copy templated config file
- name: Copy Configuration File for {{beat}}
template: src=beat.yml.j2 dest={{conf_file}} mode=0644 force=yes owner=root group=root
notify: restart {{beat}}
- name: Copy Configuration File for {{ beat }}
template:
src: beat.yml.j2
dest: '{{conf_file}}'
mode: 0644
force: true
owner: root
group: root
notify: restart {{ beat }}
74 changes: 44 additions & 30 deletions tasks/beats-debian.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,80 @@
---

- name: Debian - Ensure apt-transport-https is installed
apt: name=apt-transport-https state=present cache_valid_time=86400
when: use_repository
apt:
name: apt-transport-https
state: present
cache_valid_time: 86400
when: use_repository | bool
register: beat_install
notify: restart {{beat}}
notify: restart {{ beat }}

- name: Debian - Ensure python-urllib3, python-openssl, python-pyasn1 & python-pip are installed
apt:
name: python-urllib3,python-openssl,python-pyasn1,python-pip
name:
- python-urllib3
- python-openssl
- python-pyasn1
- python-pip
state: present
when: use_repository and ansible_distribution_release == "trusty"
when:
- use_repository | bool
- ansible_distribution_release == "trusty"

- name: Debian - ensure ndg-httpsclient pip is installed
pip:
name: ndg-httpsclient
state: present
when: use_repository and ansible_distribution_release == "trusty"
when:
- use_repository | bool
- ansible_distribution_release == "trusty"

- name: Debian - Add Beats repository key
apt_key:
url: "{{ elastic_repo_key }}"
url: '{{ elastic_repo_key }}'
state: present
when: use_repository
when: use_repository | bool

- name: Debian - add beats repository
apt_repository: repo="deb {{ repo_url }} stable main" state=present
when: use_repository
apt_repository:
repo: 'deb {{ repo_url }} stable main'
state: present
when: use_repository | bool

- name: Debian - unhold {{beat}} version for install
command: apt-mark unhold {{beat}}
- name: Debian - unhold {{ beat }} version for install
command: apt-mark unhold {{ beat }}
changed_when: false

- name: Debian - Ensure {{beat}} is installed
- 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 != "" %}={{ beats_version }}{% endif %}
state: present
cache_valid_time: 86400
when: use_repository
notify: restart {{beat}}
when: use_repository | bool
notify: restart {{ beat }}

- name: Debian - hold {{beat}} version
command: apt-mark hold {{beat}}
- name: Debian - hold {{ beat }} version
command: apt-mark hold {{ beat }}
when: version_lock
changed_when: false

- set_fact: os_arch="i386"

- set_fact: os_arch="amd64"
when: ansible_architecture == "x86_64"
- name: Set os_arch
set_fact:
os_arch: >-
{{ ansible_architecture == 'x86_64' | ternary("amd64", "i386") }}
- name: Debian - Download {{beat}} from url
- 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
when: not use_repository | bool

- name: Debian - Ensure {{beat}} is installed from downloaded package
apt: deb=/tmp/{{beat}}_{{ beats_version }}_{{os_arch}}.deb
when: not use_repository
notify: restart {{beat}}
- name: Debian - Ensure {{ beat }} is installed from downloaded package
apt:
deb: '/tmp/{{ beat }}_{{ beats_version }}_{{os_arch}}.deb'
when: not use_repository | bool
notify: restart {{ beat }}
14 changes: 10 additions & 4 deletions tasks/beats-param-check.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
---
- fail: msg="beat must be specified and cannot be blank e.g. filebeat"
when: beat is not defined or beat == ''
- name: Check beat variable
fail:
msg: "beat must be specified and cannot be blank e.g. filebeat"
when: beat is not defined or (beat | length == 0)

- fail: msg="beat_conf must be specified"
- name: Check beat_conf variable
fail:
msg: "beat_conf must be specified"
when: beat_conf is not defined

- set_fact: "beats_major_version={{ beats_version[0] }}.x"
- name: Set beats_major_version
set_fact:
beats_major_version: '{{ beats_version[0] }}.x'

0 comments on commit 57d5b1b

Please sign in to comment.