This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from lean-delivery/master
Update syntax to make it compliant to modern ansible-lint rules
- Loading branch information
Showing
15 changed files
with
261 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,4 +99,4 @@ suites: | |
additional_copy_path: | ||
- "." | ||
run_list: | ||
attributes: | ||
attributes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,91 @@ | ||
--- | ||
|
||
- 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}} | ||
until: beat_install is succeeded | ||
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" | ||
register: libs_install | ||
until: libs_install is succeeded | ||
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" | ||
register: ndg_install | ||
until: ndg_install is succeeded | ||
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 | ||
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 | ||
when: use_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 | ||
command: apt-mark unhold {{beat}} | ||
changed_when: False | ||
- name: Debian - unhold {{ beat }} version for install | ||
command: apt-mark unhold {{ beat }} | ||
changed_when: false | ||
|
||
- name: Debian - Ensure {{beat}} is installed | ||
apt: name={{beat}}{% if beats_version is defined and beats_version != "" %}={{ beats_version }}{% endif %} state=present cache_valid_time=86400 | ||
when: use_repository | ||
notify: restart {{beat}} | ||
- name: Debian - Ensure {{ beat }} is installed | ||
apt: | ||
name: >- | ||
{{ 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 }} | ||
|
||
- 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 | ||
changed_when: false | ||
|
||
- set_fact: os_arch="i386" | ||
- name: Set os_arch | ||
set_fact: | ||
os_arch: >- | ||
{{ ansible_architecture == 'x86_64' | ternary('amd64', 'i386') }} | ||
- set_fact: os_arch="amd64" | ||
when: ansible_architecture == "x86_64" | ||
- 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' | ||
validate_certs: false | ||
when: not use_repository | bool | ||
|
||
- 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 validate_certs=no | ||
when: not use_repository | ||
|
||
- 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
--- | ||
- 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 must be specified and cannot be blank e.g. filebeat" | ||
when: beat is not defined or beat == '' | ||
|
||
- 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,62 @@ | ||
--- | ||
|
||
- 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 | ||
register: versionlock_install | ||
until: versionlock_install is succeeded | ||
|
||
- 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 | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: RedHat - Ensure {{beat}} is installed | ||
yum: name={{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %} state=present update_cache=yes | ||
- name: RedHat - Ensure {{ beat }} is installed | ||
yum: | ||
name: >- | ||
{{ beat }}{% if beats_version is defined and beats_version|length %}-{{ beats_version }}{% endif %} | ||
state: present | ||
update_cache: true | ||
register: beat_install | ||
until: beat_install is succeeded | ||
when: use_repository | ||
notify: restart {{beat}} | ||
notify: restart {{ beat }} | ||
|
||
- name: RedHat - lock {{beat}} version | ||
shell: yum versionlock add {{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %} | ||
- name: RedHat - lock {{ beat }} version | ||
shell: >- | ||
yum versionlock add | ||
{{ beat }}{% if beats_version is defined and beats_version|length %}-{{ beats_version }}{% endif %} | ||
when: version_lock | ||
changed_when: False | ||
changed_when: false | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- 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 %} state=present | ||
- 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 %} | ||
state: present | ||
register: beat_install | ||
until: beat_install is succeeded | ||
when: not use_repository | ||
notify: restart {{beat}} | ||
notify: restart {{ beat }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.