Skip to content

Commit

Permalink
Merge pull request #3 from gabops/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Gabriel Suarez authored Sep 6, 2019
2 parents d21f68c + 58ffcd6 commit 3fee75a
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 226 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ env:
matrix:
- TEST_DISTRO: centos:6
- TEST_DISTRO: centos:7
- TEST_DISTRO: amazonlinux:2016.09
- TEST_DISTRO: amazonlinux:2017.03
- TEST_DISTRO: amazonlinux:2017.09
- TEST_DISTRO: amazonlinux:2017.12
- TEST_DISTRO: amazonlinux:2018.03
- TEST_DISTRO: amazonlinux:1
- TEST_DISTRO: amazonlinux:2
- TEST_DISTRO: debian:8
- TEST_DISTRO: debian:9
- TEST_DISTRO: debian:10
- TEST_DISTRO: ubuntu:18.04

install:
Expand Down
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ gabops.papertrail
=================
[![Build Status](https://travis-ci.org/gabops/ansible-role-papertrail.svg?branch=master)](https://travis-ci.org/gabops/ansible-role-papertrail)

Installs and configure papertrail using remote_syslog2 (see
Installs and configures Papertrail (remote_syslog2) (see
[Papertrail official documentation](https://help.papertrailapp.com/kb/configuration/configuring-centralized-logging-from-text-log-files-in-unix/)
and [remote_syslog2 Github repo](https://github.com/papertrail/remote_syslog2)

Requirements
------------

None
None.

Role Variables
--------------

*Role defaults:*

| Variable | Value | Description |
| :--- | :--- | :--- |
| papertrail_version | "0.20" | Version to install. 0.20 is the latest at the moment |
Expand All @@ -36,25 +34,12 @@ Role Variables

> For more detailed information about remote_syslog2 configuration see https://github.com/papertrail/remote_syslog2/blob/master/README.md
*Role vars:*

Usually you will not need to modify never any of the next values when calling the role but just in case, apart of defining them I've added also the possibility of overwriting them for covering unexpected scenarios

| Variable | Value | Description |
| :--- | :--- | :--- |
| papertrail_download_url | "https://github.com/papertrail/remote_syslog2/releases/download/v{{ papertrail_version }}" | The url pointing to the remote_syslog2 version |
| papertrail_executable | /usr/local/bin/remote_syslog | The binary that the package installs |
| papertrail_systemd_unit_path | /etc/systemd/system | The path where store the systemd unit file is stored |
| papertrail_sysvinit_script_path | /etc/init.d | The path where the sysvinit script file is stored |
| papertrail_pid_directory | /var/run | The directory where the pid file is stored |
| papertrail_service_name | remote_syslog | The service name used for the remote_syslog2 process |
| papertrail_package_name | "remote_syslog2-{{ papertrail_version }}-1.{{ ansible_architecture }}.rpm" | The package name for RedHat based os |
| papertrail_package_name | "remote-syslog2_{{ papertrail_version }}_{{ installer_arch }}.deb" | The package name for Debian based os |
> This role also provides the possibility of overwriting any variable in the **vars/** directory. You **never should do it**. This feature only exists for covering any unexpected scenario you might find. For doing it, just declare the variable/variables without the double underscore on your group_vars, host_vars, command line etc as you would do for a variable in defaults/.
Dependencies
------------

None
None.

Example Playbook
----------------
Expand All @@ -63,7 +48,6 @@ Example Playbook
- hosts: servers
vars:
papertrail_version: "0.19"
papertrail_config_file_path: /etc/papertrail.yml
papertrail_destination_host: logs.papertrailapp.com
papertrail_destination_port: 12345
papertrail_custom_hostname: "host-01"
Expand Down
2 changes: 0 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
papertrail_version: "0.20"

papertrail_config_file_path: /etc/papertrail_conf.yml

papertrail_service_enabled: true
papertrail_service_started: true
papertrail_managed_conf_file: true
Expand Down
2 changes: 2 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ galaxy_info:
- 7
- name: Amazon
versions:
- 2016.09
- 2017.03
- 2017.09
- 2017.12
- Candidate
- name: Debian
versions:
- stretch
- buster
- name: Ubuntu
versions:
- bionic
Expand Down
1 change: 0 additions & 1 deletion molecule/default/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
hosts: all
vars:
papertrail_version: "0.19"
papertrail_config_file_path: /etc/papertrail_test.yml
papertrail_destination_host: localhost
papertrail_destination_port: 12345
papertrail_custom_hostname: "host-01"
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def test_papertrail_conf_file(host):
f = host.file('/etc/papertrail_test.yml')
f = host.file('/etc/log_files.yml')
assert f.exists
assert f.user == 'root'
assert f.group == 'root'
Expand Down
24 changes: 3 additions & 21 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Configure papertrail managed configuration file
- name: Configure Papertrail managed configuration file
template:
src: papertrail_conf.yml.j2
dest: "{{ papertrail_config_file_path }}"
Expand All @@ -10,31 +10,13 @@
notify: restart papertrail
when: papertrail_managed_conf_file | bool

- name: Configure papertrail service (systemd) unit
template:
src: papertrail.systemd.j2
dest: "{{ papertrail_systemd_unit_path }}/{{ papertrail_service_name }}.service"
owner: root
group: root
mode: 0644
when: ansible_service_mgr == "systemd"

- name: Configure papertrail service (sysvinit) script
template:
src: papertrail.sysvinit.j2
dest: "{{ papertrail_sysvinit_script_path }}/{{ papertrail_service_name }}"
owner: root
group: root
mode: 0755
when: ansible_service_mgr != "systemd"

- name: Enable papertrail service
- name: Enable Papertrail service
service:
name: "{{ papertrail_service_name }}"
enabled: true
when: papertrail_service_enabled | bool

- name: Start papertrail service
- name: Start Papertrail service
service:
name: "{{ papertrail_service_name }}"
state: started
Expand Down
4 changes: 2 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: Install papertrail (RedHat)
- name: Install Papertrail (RedHat)
yum:
name: "{{ papertrail_download_url }}/{{ papertrail_package_name }}"
state: present
when: ansible_os_family == "RedHat"

- name: Install papertrail (Debian)
- name: Install Papertrail (Debian)
apt:
deb: "{{ papertrail_download_url }}/{{ papertrail_package_name }}"
update_cache: true
Expand Down
25 changes: 5 additions & 20 deletions tasks/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,16 @@
papertrail_download_url: "{{ __papertrail_download_url }}"
when: papertrail_download_url is not defined

- name: Set papertrail config file path
set_fact:
papertrail_config_file_path: "{{ __papertrail_config_file_path }}"
when: papertrail_config_file_path is not defined

- name: Set papertrail package name
set_fact:
papertrail_package_name: "{{ __papertrail_package_name }}"
when: papertrail_package_name is not defined

- name: Set papertrail executable
set_fact:
papertrail_executable: "{{ __papertrail_executable }}"
when: papertrail_executable is not defined

- name: Set papertrail systemd unit path
set_fact:
papertrail_systemd_unit_path: "{{ __papertrail_systemd_unit_path }}"
when: papertrail_systemd_unit_path is not defined

- name: Set papertrail sysvinit script path
set_fact:
papertrail_sysvinit_script_path: "{{ __papertrail_sysvinit_script_path }}"
when: papertrail_sysvinit_script_path is not defined

- name: Set papertrail pid directory
set_fact:
papertrail_pid_directory: "{{ __papertrail_pid_directory }}"
when: papertrail_pid_directory is not defined

- name: Set papertrail service name
set_fact:
papertrail_service_name: "{{ __papertrail_service_name }}"
Expand Down
15 changes: 0 additions & 15 deletions templates/papertrail.systemd.j2

This file was deleted.

140 changes: 0 additions & 140 deletions templates/papertrail.sysvinit.j2

This file was deleted.

5 changes: 1 addition & 4 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
__papertrail_download_url: "https://github.com/papertrail/remote_syslog2/releases/download/v{{ papertrail_version }}"
__papertrail_executable: /usr/local/bin/remote_syslog
__papertrail_systemd_unit_path: /etc/systemd/system
__papertrail_sysvinit_script_path: /etc/init.d
__papertrail_pid_directory: /var/run
__papertrail_config_file_path: log_files.yml
__papertrail_service_name: remote_syslog

0 comments on commit 3fee75a

Please sign in to comment.