-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
164 additions
and
38 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.vagrant | ||
|
||
.molecule | ||
tests/.cache/v/cache | ||
tests/__pycache__ |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[defaults] | ||
roles_path = .molecule:../ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
ansible: | ||
config_file: ansible.cfg | ||
become: True | ||
|
||
molecule: | ||
test: | ||
sequence: | ||
- destroy | ||
- syntax | ||
- create | ||
- converge | ||
- verify | ||
|
||
vagrant: | ||
platforms: | ||
- name: trusty64 | ||
box: ubuntu/trusty64 | ||
|
||
- name: xenial64 | ||
box: ubuntu/xenial64 | ||
|
||
providers: | ||
- name: virtualbox | ||
type: virtualbox | ||
|
||
instances: | ||
- name: ansible-papertrail |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
- hosts: all | ||
gather_facts: False | ||
|
||
pre_tasks: | ||
|
||
# Check Ubuntu release version to determine if we need to install Python 2, | ||
# an ansible dependency that isn't included by default in Ubuntu 16.04 and | ||
# up. | ||
|
||
- name: Check Ubuntu release | ||
raw: cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2 | ||
register: ubuntu_release | ||
changed_when: false | ||
|
||
- debug: msg="Running ubuntu version {{ ubuntu_release.stdout }}" | ||
|
||
# Update apt cache and install python 2 for Ubuntu versions greater than 16.04 | ||
- name: Update APT cache | ||
raw: apt-get update | ||
become: True | ||
changed_when: false | ||
|
||
- name: Install Python | ||
raw: apt-get install -yq python | ||
become: True | ||
when: ubuntu_release.stdout | version_compare('16.04', '>=') | ||
|
||
# Gather facts once ansible dependencies are installed | ||
- name: Gather facts | ||
setup: | ||
|
||
roles: | ||
# Papertrail | ||
- { role: "ansible-papertrail" } | ||
|
||
tasks: | ||
- name: Configure remote_syslog | ||
template: src="log_files.yml.j2" | ||
dest="{{ papertrail_conf }}" | ||
notify: | ||
- Restart remote_syslog | ||
|
||
- name: Add Papertrail user to service group | ||
user: name=papertrail | ||
append=yes | ||
groups=adm | ||
state=present |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import pytest | ||
import re | ||
|
||
|
||
@pytest.fixture() | ||
def AnsibleDefaults(Ansible): | ||
""" Load default variables into dictionary. | ||
Args: | ||
Ansible - Requires the ansible connection backend. | ||
""" | ||
return Ansible("include_vars", "./defaults/main.yml")["ansible_facts"] | ||
|
||
|
||
def test_papertrail_user(User): | ||
"""Check that the Papertrail user exists with the right configuration""" | ||
papertrail = User('papertrail') | ||
assert papertrail.exists | ||
assert papertrail.home == "/var/lib/papertrail" | ||
assert papertrail.shell == "/bin/false" | ||
assert papertrail.name == "papertrail" | ||
|
||
|
||
def test_papertrail_bundle(File): | ||
"""Check that the Papertrail certificate bundle exists""" | ||
assert File('/etc/papertrail-bundle.pem').exists | ||
|
||
|
||
def test_rsyslog_gnutils(Package): | ||
"""Check that the rsyslog TLS support is installed""" | ||
assert Package("rsyslog-gnutls").is_installed | ||
|
||
|
||
def test_services(Service): | ||
"""Check that syslog/remote syslog are running""" | ||
assert Service("rsyslog").is_enabled | ||
assert Service("remote_syslog").is_enabled | ||
|
||
|
||
def test_papertrail_configuration(File, AnsibleDefaults): | ||
"""Check make sure the proper Papertrail configuration exists""" | ||
papertrail_config = File(AnsibleDefaults["papertrail_conf"]) | ||
papertrail_host = AnsibleDefaults["papertrail_host"] | ||
papertrail_port = AnsibleDefaults["papertrail_port"] | ||
|
||
assert papertrail_config.exists | ||
assert re.search("host: {}".format(papertrail_host), | ||
papertrail_config.content_string) is not None | ||
assert re.search("port: {}".format(papertrail_port), | ||
papertrail_config.content_string) is not None | ||
|
||
|
||
def test_rsyslog_configuration(File, AnsibleDefaults): | ||
"""Check make sure the proper rsyslog configuration exists""" | ||
rsyslog_config = File("/etc/rsyslog.d/90-papertrail.conf") | ||
papertrail_host = AnsibleDefaults["papertrail_host"] | ||
papertrail_port = AnsibleDefaults["papertrail_port"] | ||
|
||
assert rsyslog_config.exists | ||
assert re.search("\*\.\* @@{}:{}".format(papertrail_host, papertrail_port), | ||
rsyslog_config.content_string) is not None |